formerly, I used Rails 3.2.13 with Ruby 2.0.0 and this worked fine :
In my application.rb, I had:
def set_locale
I18n.locale = http_accept_language.compatible_language_from([:en, :de])
end
I use 2 locales, de.yml and en.yml
Now that I upgraded to Rails 3.2.22 and Ruby 2.2.4, I was forced to also upgrade gem i18n to version 0.7.0, and I get the error message "I18n::InvalidLocale (:en is not a valid locale)" if I choose a client in 'en' or another language. 'de' works.
I tried various combinations of parameters in application.rb
config.i18n.enforce_available_locales = true
config.i18n.available_locales = ["en", "de"]
config.i18n.default_locale = :'de'
but to no avail...
If I use a client in 'de', it works, but if I use a client in 'en' or another language, I get the above error message. Formerly, if I chose another client language, it would default to 'de'
Downgrading i18n version to 0.6.4 and upgrading it again to 0.7.0 did the trick. I have no idea why.
I'm still not entirely satisfied with the result, though, since I cannot currently predict what happens if a client uses a language for which there is no locale in my app. Sometimes it picks :en, sometimes :de. I would prefer to be able to control the default language.
Related
Things were working fine until I started the upgrade from Rails 4.2 to 5.0
Using qbo_api gem (1.8.1) which also now needs the simple_oauth (0.3.1) as well as the oauth (0.5.4) gem. (The faraday gem (0.14.0) is loaded as another dependency.)
I can successfully do get requests for invoice, customer, etc., so the keys and initialization of the qbo_api object are all working for qbo_api.get() but when I try to create an invoice with qbo_api.create(:invoice, payload: ...), I get the error:
Operation Could not find resource for relative : /v3/company/123145710499109/invoice of full path: https://sandbox.qbo.intuit.com/qbo50/v3/company/123145710499109/invoice is not supported.
The same qbo_api object is working for get, I see nothing obviously wrong with the URL, and it is unreleated to the JSON payload. I'm not sure where to look to debug this problem.
BTW, clicking on the URL above seems to go to QB just fine, returning a validation error as you would expect.
This turns out to be a problem in the 1.8.0 and 1.8.1 versions of the qbo_api gem. Minimul has released version 1.8.2 which fixes this problem.
Kudos to Minimul for a quick response to this.
check your realmId. Most probably realmId is not match to your connected intuit app. This is why its tells that Operation Could not find resource for relative.
I have a Ruby on Rails app that runs feature tests using Capybara, Poltergeist and PhantomJS.
Version 2.0.0 of PhantomJS has a rather significant bug that breaks a lot of tests (https://github.com/ariya/phantomjs/issues/12506) so I'd like to force the app to use a different version of PhantomJS when running the tests.
Is this possible from within Poltergeist's configuration, to raise an error or a warning if this buggy version is used, or is my best bet simply putting a note in the app's readme saying 'don't use version 2.0.0 due to this bug'?
at the moment my Capybara/Poltergeist configuration is very basic:
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, :timeout => 90)
end
As #pguardiario commented, you can just do something like
if `phantomjs -v`.start_with? '2'
#output whatever kind of warning you want
end
however the Poltergeist master branch has a fix for that particular issue so you could just try using that instead
Our rails 4.2 app consists of several rails engines with or without gem 'protected_attributes'. What we find out is that in app's application.rb, it has to be:
config.active_record.whitelist_attributes = false
Otherwise, any create/update can not be carried out because the params can not be assigned to instance variable. Our question is that, if there is no gem protected_attributes in rails app, do we still need config.active_record.whitelist_attributes = false in application.rb? Is this for Rails 3.x or app with gem protected_attributes?
I've looked through several rails 4 apps I have, none of them contained that config, and when I googled the config name, the protected_attributes gem came in the results, so I think you could assume that it's only related to the protected_attributes gem and that you don't need it
This comes from the protected_attributes gem.
When whitelist_attributes = true it causes attr_accessible(nil) to be added by default for all models meaning you ca not mass assign any attributes for any models unless it has its own attr_accessible or attr_protected
This can be seen in an older version of the README.md
As of version 1.1.2 this is now depreciated and does nothing other than log a depreciation warning
So if you are on a Rails 4+ application and do not have the protected_attributes gem then you can safely remove it
I am running JRuby version 1.6.7 with Rails 3.2.3 and when I launch my rails server rails s I get the following error:
/config/routes.rb:8: syntax error, unexpected ':'
match '/about', to: 'pages#about'
However, if I change to match '/about' :to => 'pages#about' I don't get the error. Since this shorthand format is supported in the version of Rails in use, what is the problem and how do I resolve it?
The hash syntax comes from Ruby implementations, not Rails. JRuby can run in either 1.9 or 1.8 mode. It runs in 1.8 mode by default. You can read about configuring JRuby to run in 1.9 mode on the wiki.
The key: value syntax was introduced by Ruby 1.9 to supersede 1.8's :key => value syntax. The version of Rails is irrelevant; unless your version of Ruby is at least 1.9, you cannot use the new key: value syntax for hashes.
I'm trying to create a custom model to interface with a database that isn't supported navtively by Rails or through the OpenLink ODBC driver. For some reason, I'm getting the following error:
no such file to load -- odbc
I'm at a lost as to why this is occurring as the ruby-odbc gem is in the GEM_PATH and I have a small script that tests this to ensure that the connection works and it worked perfectly. Does Rails ignore the gem_path? Is there something else I need to configure? I checked the GEM_PATH in Rails by writing it out to the browser and it matches what I saw in a terminal window.
FYI: I'm using rvm to manage ruby and all of my gems. Not sure if this makes any difference, though it really shouldn't from what I can tell.
Does your Gemfile include something like the following
gem 'ruby-odbc'