Ruby on Rails
Saturday, November 2, 2019
@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 (<fugee279@gmail.com>) escribió:
--The I'm getting error isundefined 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 rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/98eed4a3-d1dc-4a3e-a0af-058d0f10740b%40googlegroups.com.
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAPS3bcB%2BXNyGzA%3D9sq2rDCc_TVvm3rOdjXoLNuiSxC%3DubH8p3g%40mail.gmail.com.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment