I18n strange behaviour - ruby-on-rails

I am using I18n with Redis store, and have a strange behavior after updating to Rails 3.2.13
[6] pry(main)> I18n.t("my_website_field")
=> "M"
[7] pry(main)> $redis.get("en.my_website_field")
=> "\"My website\""
I am getting only the first letters of the translations

To my knowledge I believe that redis-store has issues with certain versions of Rails (3.2.13 happens to be one of those).
Since I was really curious about why this would be happening I opened up the Github change log and took a look at the logic they changed in the 3.2.12 -> 3.2.13 update.
The main change that I noticed was the dependency chain in ActiveSupport for i18n.
The code was changed FROM
s.add_dependency('i18n', '~> 0.6')
TO
s.add_dependency('i18n', '= 0.6.1')
The only other changes were (from the changelog):
Add i18n scope to `distance_of_time_in_words
So if I had to take an educated guess I would say that the forcing of the use of i18n to 0.6.1 created some type of conflict with redis-store.
Note: I will continue to look into the issue with the change logs to i18n and post if I have any more information on the subject.
Can't find the specific issue in commit history and they don't keep a changelog (havent for 3 years :/) but I'd be curious to see if forcing the old version control would allow i18n to function properly.

Related

Factory_girl deprecation for rails 5

I'm currently upgrading my rails application from rails 4 to rails 5. Is it necessary to change from Factory_girl to Factory_bot? What will happen if I proceed with a deprecation warning? further, I might be upgrading that application to rails 6, so would factory_girl work for rails 6?
FactoryGirl was renamed to FactoryBot in October 2017. (The original name was based on some inside joke/pop culture reference, which some argued was a poor decision.)
This has got nothing to do with upgrading rails, and everything to do with upgrading factory_girl/factory_bot.
Use the new name. It makes no sense to keep the old name - and regardless, your code will break at some point when updating versions, if you don't perform the rename.
The change is quite straightforward, and there are various guides people have written about the upgrade, such as this.
Essentially, all you need to do is:
Rename factory_girl and/or factory_girl_rails in the Gemfile, to factory_bot and factory_bot_rails.
Rename any mention of FactoryGirl to FactoryBot. (You could use git grep to ensure nothing is missed.)

Alternative to turn gem for rails MiniTest

I've recently upgraded to Rails 4.2.0 and MiniTest ~> 5, and that broke the Turn gem. I noticed that it is no longer being maintained due to the developers getting fed up with API changes https://github.com/turn-project/turn , so I pulled it out of my project.
I'm really missing the better test output that Turn provided. What are some great alternatives to get customizable, colorized, well-structured MiniTest output?
Take a look at minitap and tapout - it's not a simple plug-and-play gem like turn was, but you can get it very nice with a bit of trial and error.

After installing paper_trail, get "irb: warn: can't alias context from irb_context." from rails console

I've tested this by running rails c both before and after git stash. On Rails 4.1 in Mavericks, after following the instructions to add the versions table and adding has_paper_trail to three models, whenever I run rails c I get
irb: warn: can't alias context from irb_context.
I've spent some time Googling without much luck, there's old threads talking about rspec, but I don't see how that's relevant since I'm not using it. Any ideas why this is happening?
RSpec used to polute provide Object top-level methods, e.g. describe, context, etc. Fortunately they've got rid of all the monkey patching in version 3, and now all these methods are namespaced under RSpec.
One can change this behaviour through the expose_dsl_globally config flag. For backwards compatibility, it defaults to true.
The warning shows up when you open the console because paper_trail automatically loads its rspec helpers when rspec is found. And it calls RSpec.configure before you have the chance to tweak your own configuration.
One possible solution would be paper_trail to disable the automatically loading and let users to load it themselves when they see fit. However, I am not aware of the internals of the library, so I can't guarantee this wouldn't break other things.
Best!
This is now fixed in papertrail 4.0.0, here's the commit.

Rails, Formtastic - model name not showing on form buttons

I have just deployed an existing app to a new server and have noticed that where model names are automatically generated (by Formtastic) it instead outputs {{model}} rather than the expected name.
For example, in the linked image it should read 'Create Category' but instead reads 'Create {{model}}'
https://skitch.com/simon180/rr4w9/example
I don't know where to start in figuring what causes this.
Rails version is 2.3.5 (vendored) and gems vendored too.
Any suggestions gratefully received!
Thanks
Simon
Have a look in the formtastic gem, depending on what version you have, the file will be
/lib/formtastic/i18n.rb
or
formtastic/lib/locale/en.yml
it should have something like this:
'Create %{model}'
but yours will have:
'Create {{model}}'
Thats the old format. Change occurrences of {{foo}} to %{foo}
or
Updating the formtastic gem should do the trick
Another option is to downgrade the i18n gem to 0.4.1 this problem will disappear.
The problem is with the i18n gem version. From version 0.4.1 on, the way of accessing variables isn't {{variable}} anymore.

Tracking down and fixing i18n deprecation warnings in rails 3 (cucumber 0.9.3 to blame?)

My cucumber test passes, but leaves this ridiculous stack trace. Just your basic The {{key}} interpolation syntax in I18n messages is deprecated. Please use %{key} instead. error message, but how am I to find the culprit in that list?
I never used the {{key}} syntax myself, so some gem I'm using is outdated. Please tell me which one. It's really frustrating to have so much kruft every time I run a test.
I was getting that error with Authlogic and it turned out that the more recent versions of the I18n gem (0.4.x, I think) deprecated the call.
I avoided the problem by "rolling back" my I18n gem to version 0.3.7.
As to which plugin, at a guess this is the key line (line 15 on your gist):
/Library/Ruby/Gems/1.8/gems/responders-0.6.0/lib/responders/flash_responder.rb:115:in `set_flash_message!
Since it is the first one that is after the I18n lines, I suspect it is the one that is calling translate with the deprecated interpolation.
(Update a few minutes later):
Looking at: http://github.com/plataformatec/responders/commits/master, ...it looks like you could just upgrade to responders 0.6.2. Their commit on June 24th seems to address the issue.

Resources