Tell me how to use ActiveRecord#after_add
Posted
by Small Wolf
on Stack Overflow
See other posts from Stack Overflow
or by Small Wolf
Published on 2010-06-03T09:15:18Z
Indexed on
2010/06/03
10:54 UTC
Read the original article
Hit count: 228
Hey,Guys! Now I hava a problem,how can I make the callback#after_add receive a reference to the join model in a has_many :through association? my code like this:
class Emergency
has_many :departments, :through => :eme_references, :after_add => Proc.new { |eme_reference| eme_reference.eme_flag = 1}
end
the attribute eme_flag is the model EmeReference's attribute! but in the block ,i get the eme_reference.class is Emergency. I want to set the attribute eme_flag of the model EmeReference. That is my question! cheers!
© Stack Overflow or respective owner