ActiveRecord to_i method removed in Rails 3.2.9
ruby-on-rails-3.2
Solution
The `#to_i` method never existed, however the way assigning objects to values has changed in Rails 3.2.8.
Given the following:
class Lecture < ActiveRecord::Base
has_one :professor
end
Previously you could assign a professor to a lecture like this:
@lecture.professor = Professor.find_by_id(1)
Or like this:
@lecture.professor_id = Professor.find_by_id(1)
In the first case everything is simple as the `professor` association expects a professor object. In the second case though ActiveRecord performed some magic to coerce the id from the professor, as `professor_id` expects a integer instead.
In Rails 3.2.8 and above that magic no longer works. It is nice in a way as it is a hint you are probably doing something wrong. For example, if there isn't a `professor_id` column in the database, but just `professor` which expects an integer, assigning like this will no longer work.
It looks like this will be reverted to the previous behaviour in Rails 3.2.11.
Problem
Upgraded to Rails 3.2.9 today from 3.2.7 and it appears that the method "to_i" has been removed from ActiveRecord. Is this by design? Or is it a bug? I cannot find any mention of it in the change notes. This is going to impact a lot of code. thanks!