R
R
RStudent2014-06-01 17:40:09
Ruby on Rails
RStudent, 2014-06-01 17:40:09

How to properly implement nested forms?

I'll try to explain.
I have a list of products that looks like this:

- @shop.items.each do |item|
 = item.name

Inside the loop there is a form that should submit the edited data.
Those. there is a cycle that displays 5 items of goods, each of the goods can be edited.
Now I tried to do this, but it doesn't work.
= form_for [@shop, @item] do |f|
 = f.label :name
 = f.text_field :name

Writes First argument in form cannot contain nil or be empty
General view.
- @shop.items.each do |item|
 = item.name
 = form_for [@shop, @item] do |f|
 = f.label :name
 = f.text_field :name

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Snegirev, 2014-06-01
@RStudent

[@shop, @item ] - I suspect one of these nil variables

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question