So I have this Event has_many :assistance has_many :users, :through => :assistance User has_many :assistance has_many :assisted_events, :through => :assistance, :source => :assistance Assistance belongs_to :user belongs_to :event Users assisting to events are assigned using @event.users << user BUT assistance model also have an status attribute, so I need to fill it at the same time of doing @event.users << user, is it possible to make it on the same line? I actually dont know how to assign that attribute -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Aug 9, 2011 at 1:56 PM, Tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Users assisting to events are assigned using > > @event.users << user > BUT assistance model also have an status attribute, so I need to fill it > at the same time of doing @event.users << user, is it possible to make > it on the same line? I actually dont know how to assign that attributehttp://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html Look for "Association callbacks" -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.