Rails 4 form_for名称问题

时间:2014-04-23 10:32:00

标签: ruby-on-rails-4

伙计们我可以为我的 rails表单设置特殊名称 ??

我尝试使用此命令,但总是失败

<%= form_for(@contact,:name =>"FormContact", :remote => true)   do |f| %> 

OR

<%= form_for(:FormContact,@contact, :remote => true)   do |f| %> 

OR

<%= form_for(@contact,name: "FormContact", :remote => true)   do |f| %> 

1 个答案:

答案 0 :(得分:1)

尝试:

<%= form_for(@contact, html: { name: "FormContact" }, remote: true) do |f| %>
  ...
<% end %>

参考:http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html

希望有所帮助:)