elixir - Adding data to nested model (phoenix-framework) -


so, have model order_items , order_attributes. , order_attributes model nested order_items.

schema "order_attributes"  belongs_to :order_item, myapp.orderitem  belongs_to :attribute, myapp.attribute  timestamps end  schema "order_items"  field :quantity, :integer, default: 1  belongs_to :order, myapp.order  belongs_to :food, myapp.food  has_many :order_attributes, myapp.orderattribute  timestamps end 

i struggling adding data model order_attributes. add data order_item, use hidden input insert data rather using new action. below.

<%= hidden_input f, :food_id, value: @chicken_id %> 

so when click menu item, insert data model order_items through hidden input. order_items, want insert data order_attributes model through hidden input. made

   <%= inputs_for f, :order_attributes, fn of -> %>    <%= hidden_input of, :attribute_id, value: 1 %>    <%= hidden_input of, :order_item_id, value: @order_item_id %>    <% end %> 

but code not working.... how should fix this? can use hidden input insert data nested model?

thanks