Rails 3:未定义方法“remote_form_for”
我在共享/用户下的部分 HAML 中有一个相当简单的 Rails 远程表单:
- remote_form_for :user, :url => { :controller => "users", :action => "create" } do |f|
.field
= f.label :name, t('name')
= f.text_field :name
.field
= f.label :email, t('email')
= f.text_field :email
.actions
= f.submit
无论我如何摆弄它,这都行不通。我总是收到以下错误:
undefined method `remote_form_for' for #<#<Class:0x1036e8e40>:0x1036dfd90>
我在做一些愚蠢的事情吗?它与 form_for 完美配合。
I have a fairly simple Rails remote form in HAML in a partial under shared/users:
- remote_form_for :user, :url => { :controller => "users", :action => "create" } do |f|
.field
= f.label :name, t('name')
= f.text_field :name
.field
= f.label :email, t('email')
= f.text_field :email
.actions
= f.submit
No matter how much I fiddle with it, this just won't work. I alway get the following error:
undefined method `remote_form_for' for #<#<Class:0x1036e8e40>:0x1036dfd90>
Am I doing something stupid? It works perfectly with form_for.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Remote_form_for 不再存在。
尝试添加
为 form_for 的选项,
请参阅:
http://api.rubyonrails.org/classes/ActionView /Helpers/FormHelper.html#method-i-form_for
remote_form_for no longer exists.
Try adding
as an option to form_for
see:
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html#method-i-form_for
这是因为这个方法在Rails 3上被删除,
现在使用
你的代码变成:
并且你需要rails.jquery.js或原型中的相同方法才能使用它。这是UJS对铁轨的改进。
It's because this method is delete on Rails 3
Use now
Your code becomes :
And you need the rails.jquery.js or same in prototype to use it. It's the UJS improvement in rails.