我正在从 TasksController 的 show 动作中实例化一个评论表单,但参数并没有传递给表单。
class TasksController < ApplicationController
def show
@task = Task.find(params[:id])
@comment = Comment.new(task_id: @task.id)
end
意见/任务/show.html.erb:
<%= form_for @comment, html: {class: "centrera_parent"}, remote: true do |f| %>
<%= f.text_area :content, placeholder: "Add a comment", class: "centrera_child" %><br />
<%= f.submit "Post Comment" %>
<% end %>