dimanche 17 janvier 2016

In rails, how to create forms for routes which are members of a resource?

I want to create a form for "Comments" route which is a member of Article Resources:

 resources :articles do
  member do
   post 'comments'
  end
 end

I want the comment form to be in Articles#Show page. The problem i got an error:

First argument in form cannot contain nil or be empty

If the for is like this:

<div>
  <%= form_for @comm do |c| %>
  <%= c.label :Your_comment %>
  <%= c.text_area :commBody %>
  <%= c.submit 'submit' %>
  <% end %>
</div>

So how to do it ?

Aucun commentaire:

Enregistrer un commentaire