My Valentine’s Day letter to Ruby on Rails:
“Dear Rails, remember the first time we met?
You were just 1.2, and I was in an unhealthy relationship with Perl and PHP.
I saw you in the library and I immediately fell in love.
For seven years, you made my code more readable and my skills stronger.
You are the most beautiful framework and always will be.
I cannot wait to see you turn 5.0.” – Claudio
Apparently I’m not the only one in love with Ruby on Rails. 36 programmers contributed to Rails this week, 10 of them for the first time. Keep loving!
The new method is perfect to cache results that are meant to never expire, such as static pages.
You can now reference with a symbol any database type that is specific to your adapter, such as:
ActiveRecord::Type.register(:money, MyMoneyType)
Wrapping a block with suppress
will prevent any save operation from hitting the database. Check the PR for a real-world example.
You can now touch an ActiveRecord instance with a different time than the current time.
The helpers div_for
and content_tag_for
will be gone in Rails 5. Grab the record_tag_helper gem if you still need them!
If you ever used person.errors.get(:name)
or to read an error message, you should now person.errors[:name]
switch to . person.errors.messages[:name]
add_on_empty
and add_on_blank
are gone too.
Update: you should be using person.errors[:name]
after all! Use person.errors.add(:name, ...)
to append.
That’s all for This week in Rails. As always, there are more changes than we have room to cover here, but feel free to check them out yourself!
P.S. If you enjoyed this newsletter, why not share it with your friends? :) If you wish to be part of this project please don’t hesitate to contact Godfrey – there’re a lot of ways you could help make this newsletter more awesome!