我创建了一个表单以保存信息,一切正常,但我的问题是,是否存在以其他方式保存参数?
以下是观点:
<% form_for @job, :url => {:controller=>"subject",:action=>'create'} do |f|%>
<%= f.text_field :subject %>
<%= text_field_tag "new_subject",:new_subject %>
<% end %>
有没有其他方法可以保存没有f.text_field:new_subject?
这是日志
Processing SubjectController#create (for 127.0.0.1 at 2014-06-16 11:22:00) [POST]
Parameters: {"subject"=>{"subject"=>"This is a test"}, "new_subject"=>"This is other text", "commit"=>"Crea Factura", "authenticity_token"=>"LOL"}
Subject Columns (0.5ms) SHOW FIELDS FROM `subjects`
SQL (0.1ms) BEGIN
Test Create (0.2ms) INSERT INTO `subjects` (`subject`, ` new_subject`, `created_at`, `updated_at`) VALUES('This is a test', NULL,'2014-06-16', '2014-06-16 16:22:00')
SQL (26.1ms) COMMIT
就像日志所说:
Is saving NULL because is not inside the first bracket
我也试过了:
<input id="new_subject" name="new_subject" type="text" />
请有人帮助我吗?
答案 0 :(得分:1)
试试这个:
<input id="new_subject" name="subject[new_subject]" type="text" />