我的代码非常简单,但我不知道错误来自哪里。我正在访问 localhost:3000/clients/new 并出现错误wrong number of arguments (3 for 1)
堆栈跟踪的顶部
ArgumentError - wrong number of arguments (3 for 1):
(gem) actionpack-3.2.12/lib/action_view/helpers/form_helper.rb:378:in `form_for'
(gem) haml-3.1.8/lib/haml/helpers/action_view_mods.rb:183:in `form_for_with_haml'
(gem) haml-3.1.8/lib/haml/helpers/xss_mods.rb:132:in `form_for_with_haml_xss'
app/views/clients/new.html.haml:1:in `_app_views_clients_new_html_haml__386962141__622328728'
/app/controllers/clients_controller.rb
class ClientsController < ApplicationController
def new
@client = Client.new
end
end
/app/models/client.rb
class Client < ActiveRecord::Base
attr_accessible :name
end
/app/views/clients/new.html.haml
= form_for @client, remote: true do |f|
= f.text_field :name
= f.submit
如果我在 form_for 之前只检查 @client 一行,我会得到:
=> #<Client id: nil, name: nil, created_at: nil, updated_at: nil>
任何帮助,将不胜感激。谢谢
编辑以简化代码