Okay, I think I get the concept of a RESTful many-to-many association
controller, but I've hit a bit of a wall actually implementing it. I've
been Googling for a while, but this simple question is starting to take
up too much time:

Heres where I am:

I have a Meeting model related to Users through Attendees. Simple enough
so far. I need to be able to create, update and destroy meeting
attendees:

in the controller I, of course have create, update and destroy actions
and the attendees are nested under meetings giving the following route:
POST /meetings/1/attendees (for create action).

def create
  @meeting = Meeting.find(params[:meeting_id]) # actually in
before_filter
  @meeting.users << current_user
  ...
  ...
end

Okay so far, however I also need to set additional attributes on the
Attendee object:

attendee.rsvp = "Yes" # for example

So rather than using << to associate the logged in user directly to the
meeting should I instead create the Attendee model directly set the
attributes and save?

def create
  attendee = Attendee.new(:meeting_id => params[:meeting_id], :user_id
=> current_user.id, rsvp => params[:rsvp])
  if attendee.save
    ...
  else
    ...
  end
end

Or am I way off base and there's a smart and simple way to accomplish
this?
-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to