I have three models: group, event, note.
group has_many :events and has_many :notes
events belongs_to :group and has_many :events
notes belongs_to :group and belongs_to :event
in my routes I am nesting them like
resources :groups do resources :events do resources :notes end end
In my NotesController#create method, I can't get it to work in what I believe is the proper way. The commented line does NOT work - says there is no "notes" method in NotesController#create. I have to resort to the workaround below. Is there something I'm doing wrong here? doesn't the has_many: line in my group and events model create the "notes" method for those classes? Should I possibly eliminate the relationship between the groups and notes models and rely on events to bridge those two?
@group = Group.find(params[:group_id]) @event = Event.find(params[:event_id]) #@note = @group.events.notes.new(params[:note]) #that doesn't work, but this manual workaround does: @note = Note.new(params[:note]) @note.group_id = @group.id @note.event_id = @event.id