I have some rails nested forms
= form_for @model do |f|
...
= f.fields_for :user_partnership do |builder|
- user_partners.each do |index|
= builder.hidden_field :user_partner_id
= content_tag(:li,index.name)
In my model I have set has_many :user_partner, through: :users_partnership.
So now I have two problems : the first, I have no input inside the fields_for process. So, following some SO posts, I had to add this
@model = model.new
@user_partners = User_Partner.all
@user_partners.count.times{@model.users_partnership.build}
but this really seam awkward. The secound question is how I get the enumerator of the fields_for block so I can set correctly index.name ?
Edit, here's my models
class model
has_many :user_partners, through: :users_partnerships
accepts_nested_attributes_for :users_partnerships
end
class User_Partner
has_many :models, through: :users_partnerships
end
class Users_Partnership
belongs_to :model
belongs_to :user_partner
end
modelclass is infact all lower-case, and the other two classes have underscore in them? Also, don't they inherit fromActiveRecord::Base? More importantly what I want another clarification is what isusersin your view, where does it come from?user_partnersand notusers. Btw, I tried ` = builder.options[:child_index]` to see if the index was showing, but nothong was displayed