check out the cocoon gem, it made nested forms really simple. On Saturday, November 2, 2019 at 9:17:31 AM UTC-4, Ariel Juodziukynas wrote: > > @item.item_item_properties.item_property_id is wrong, > @item.item_item_properties is a collection, use ` > iip.object.item_property.name` and `iip.object.item_property_id` instead. > > imagine @item.item_item_properties is something like an array > [item_item_property1, item_item_property2], you can't call > `item_property_id` on an array, you have to call it on one of the items > inside it, and that "iip" variable, if you call `.object` on it you get > that item from within the array. > > El sáb., 2 nov. 2019 a las 4:38, fugee ohu (<fuge...@gmail.com > <javascript:>>) escribió: > >> The I'm getting error is >> >> undefined method `item_property_id' for >> #<ItemItemProperty::ActiveRecord_Associations_CollectionProxy:0x007f82c41438d8> >> >> >> def new >> @item = Item.new(item_params) >> ItemProperty.where(item_type: params[:item][:item_type]).each do >> |ip| >> @item.item_item_properties.build(item_property_id: ip.id) >> end >> end >> >> >> <%= f.fields_for :item_item_properties do |iip| %> >> <div class="item_item_property"> >> <%= iip.label >> "#{ItemProperty.find(@item.item_item_properties.item_property_id).name}" >> %> <%= iip.hidden_field :item_property_id, value: >> @item.item_item_properties.item_property_id %> <%= iip.text_field >> :text_value %> >> </div> >> <% end %> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonra...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/rubyonrails-talk/98eed4a3-d1dc-4a3e-a0af-058d0f10740b%40googlegroups.com >> >> <https://groups.google.com/d/msgid/rubyonrails-talk/98eed4a3-d1dc-4a3e-a0af-058d0f10740b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >
-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7a60a14a-5cf0-403b-9d9c-8136546104eb%40googlegroups.com.