Moving from Rails 2.0.x to Rails 2.1 [Updated]
Wednesday, June 4th, 2008 by Thilo UtkeWe are in the process of moving our production code from autoki to the shiny new rails 2.1 and thanks to our unit tests/(r)specs we encountered some gotchas and wows we’d like to share.
Here are some things that change in rails you shold be aware of.
If you are using custom callbacks for you rails observer you now have to tell rails about these callbacks first. Simply add a define_callbacks :your_callback, :your_other_callback in models with custom callbacks.
class GroupMembership < ActiveRecord::Base
belongs_to :member, :foreign_key => :user_id, :class_name => ‘User’
…
define_callback :after_confirm # required since 2.1
…
def confirm!
update_attribute :status, ‘active’
callback :after_confirm # custom callback
end
end
class GroupMembershipObserver < ActiveRecord::Observer
def after_confirm(group_membership) # will be called from confirm! in the GroupMembership
some code here
end
end



