Nested Form missing params
I am having a problem getting the params of a nested form in the following case:
I have these 3 nested models:
Meeting:
class Meeting < ActiveRecord::Base
has_many :participants
end
Participant:
class Participant < ActiveRecord::Base
belongs_to :meeting
has_many :connections
end
and Connection:
class Connection < ActiveRecord::Base
belongs_to :participant, :foreign_key => 'connected_participant_id'
end
And these routes:
resources :meetings do
resources :participants
end
resources :participants do
resources :connections
end
I succesfully made a form to create participants and add them directly to a meeting with something like this:
In the view > meeting/show:
= link_to 'Add current user to meeting', new_meeting_participant_url(@meeting)
In the view > participant/new:
= form_for [@meeting, @participant] do |p|
*form details*
When creating i successfully receive params[:meeting_id], however when doing the same when creating a connection between participants with the following configurations I don't get the params I need
in the same view > meeting/show:
- @meeting.participants.each do |participant|
= link_to new_participant_connection_url(participant)
and again the form view > connection/new:
= form_for [@participant, @connection] do |c|
by debugging i noticed the needed params[:participant_id] are not set.
Can anyone please help me with my problem? I'm r开发者_高级运维eally stuck here.
Maybe you should take a look at ActiveRecord::NestedAttributes::ClassMethods accepts_nested_attributes_for
精彩评论