Update Operations for Secondary Resources in rails

  question, ruby

I now have a primary resource @post. what should I do with the form_for of the secondary resource @comment?

#update controller
 def update
 @comment = Post.find(params[:post_id]).comments.find(params[:id])
 
 # @comment.update(comment_params)
 # redirect_to post_path(@post)
 end
#edit form
 <%= form_for @comment do |c|%>
 <% end %>

Although @comment resource is defined in the controller, it is empty in the view.
But debugging in the error console can find this resource?

Post.find(params[:post_id]).comments.find(params[:id])
 => #<Comment id: 25, user: "12", body: "", post_id: 9, created_at: "2017-07-08 08:43:38", updated_at: "2017-07-08 08:43:38">

How should this update form (edit.html.erb) be written
Thanks in advance

I solved it myself.
The problem is an error in understanding rails routing.
Edit controller corresponds to edit.html.erb view
In the edit.html.erb form, we need to formulate form_for like this. The corresponding update action causes the data to be submitted to the update controller, thus entering the update control logic.

<%= form_for @comment, url: {action: 'update'} do |c|%>
 <%= c.text_field :user%>
 < %= c.submit' update'% >
 <% end %>

Edit controller corresponds to edit.html.erb, while update has no corresponding view. update is only responsible for the operation logic of the model.

def edit
 @comment = @comments.find(params[:id])
 end
 
 def update
 @comment = @comments.find(params[:id])
 @comment.update(comment_params)
 redirect_to post_path(@comment.post)
 end