class Allowedevent < ActiveRecord::Base
:belongs_to :room
:belongs_to :event
end
class Room < ActiveRecord::Base
:has_many :allowedevents
:has_many :events => :through => allowedevents
end
class Event< ActiveRecord::Base
:has_many :allowedevents
:has_many :rooms=> :through => allowedevents
end
I'm having difficulty putting the above relationships into a form or playing around with them in the console.
Questions:
Now say I save a room, do I have to explicitly add IDs into the
allowedevents
table? do I have to do this?room = Room.new; room.title = "test"; room.allowedevents = ""...?
as you can see from above, I am lost as to how to save the actual record.
basically I want to ask how to save a room into the database that has many
allowedevents
using the above relationships. Do I have to loop through the user input and save each one toallowedevents
? is there a better way?I got the above from railscasts episode, is there an episode on railscasts that actually puts this in perspective on how to use it in the front end?