C
C
Ciscoridze2016-03-23 08:31:01
Ruby on Rails
Ciscoridze, 2016-03-23 08:31:01

How does form_for work for linked models?

Newbie on rails. Explain how form_for works in this case?

<%= form_for([@post, @post.comments.build]) do |c| %>

What's in the object @post? Why @post.comments.build?@postis it taken from the controller when the submit button is clicked?
There is a post with comments. The modules are linked, as usual:
Comment belong_to Post
Post has_many Comment

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question