任务模型只有一个字段:标题。
我制作了一个表格来添加一个带有一个字段的新任务:标题
但是在create方法中,我们可以看到title是用“test”填充的
但在查询中,我们可以看到“nil”……有什么想法吗?
谢谢
Started POST "/tasks" for 127.0.0.1 at 2013-01-03 13:16:44 -0500
Processing by TasksController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"iWaK1QX6VCyeUCueLrRNErJEtdm/ZNxg4d3LU0vKjnY=", "task"=>{"title"
=>"test"}, "commit"=>"Add a new task "}
(0.1ms) begin transaction
SQL (0.9ms) INSERT INTO "tasks" ("created_at", "title", "updated_at") VALUES (?, ?, ?) [["created_at", Thu, 03 Jan 2013 18:16:44 UTC +00:00], ["title", nil], ["updated_at", Thu, 03 Jan 2013 18:16:44 UTC +00:00]]
(0.8ms) commit transaction
Redirected to http://0.0.0.0:3000/tasks
Completed 302 Found in 8ms (ActiveRecord: 1.8ms)
这是创建方法
def create
@task = Task.new(params[:post])
if @task.save
redirect_to tasks_path, :notice => "Task successfully saved"
else
render "new"
end
end