Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError: undefined method `delete_prefix' #14

Closed
touseefmurtaza-dev opened this issue May 14, 2021 · 2 comments
Closed

NoMethodError: undefined method `delete_prefix' #14

touseefmurtaza-dev opened this issue May 14, 2021 · 2 comments
Assignees
Labels
wontfix This will not be worked on

Comments

@touseefmurtaza-dev
Copy link

Describe the bug
When trying to add the project it throws an error

NoMethodError: undefined method `delete_prefix' for "/projects/{{Project ID}}/":String

Full Trace

irb(main):016:0> @lokalise_client.project {{Project ID}}
NoMethodError: undefined method `delete_prefix' for "/projects/{{Project ID}}/":String
	from /Users/macbook/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-lokalise-api-3.1.0/lib/ruby-lokalise-api/request.rb:55:in `prepare'
	from /Users/macbook/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-lokalise-api-3.1.0/lib/ruby-lokalise-api/request.rb:13:in `get'
	from /Users/macbook/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-lokalise-api-3.1.0/lib/ruby-lokalise-api/resources/base.rb:67:in `find'
	from /Users/macbook/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-lokalise-api-3.1.0/lib/ruby-lokalise-api/client.rb:47:in `construct_request'
	from /Users/macbook/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/ruby-lokalise-api-3.1.0/lib/ruby-lokalise-api/rest/projects.rb:20:in `project'
	from (irb):16
	from /Users/macbook/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/railties-4.2.11.3/lib/rails/commands/console.rb:110:in `start'
	from /Users/macbook/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/railties-4.2.11.3/lib/rails/commands/console.rb:9:in `start'
	from /Users/macbook/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/railties-4.2.11.3/lib/rails/commands/commands_tasks.rb:68:in `console'
	from /Users/macbook/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/railties-4.2.11.3/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
	from /Users/macbook/.rbenv/versions/2.4.9/lib/ruby/gems/2.4.0/gems/railties-4.2.11.3/lib/rails/commands.rb:17:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'

FYI: {{Project ID}} is my Lokalize project ID

Your environment:

  • OS (MacOS BigSur 11.3)
  • Ruby version (2.4.9)
@touseefmurtaza-dev touseefmurtaza-dev added the bug Something isn't working label May 14, 2021
@bodrovis
Copy link
Collaborator

bodrovis commented May 15, 2021

Good day! This is because delete_prefix is not available in Ruby 2.4, and the latest version of this gem is not intended to work with Ruby < 2.5 as mentioned in the changelog (actually, even 2.5 has reached end of life and is no longer supported by the core team). The last version to support Ruby 2.4 should be ruby-lokalise-api v3.0.0.

Another simple solution is to directly monkey patch the String class somewhere in your app and add support for these new methods (or add a refine block). Here's an example: https://github.com/ruby/csv/blob/master/lib/csv/delete_suffix.rb

However, I'd really recommend migrating to a newer Ruby version.

@bodrovis bodrovis added wontfix This will not be worked on and removed bug Something isn't working labels May 15, 2021
@touseefmurtaza-dev
Copy link
Author

Thank you for clarification @bodrovis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Development

No branches or pull requests

2 participants