私のコードは非常に単純ですが、エラーの原因がわかりません。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 の 1 行前に @client を調べると、次のようになります。
=> #<Client id: nil, name: nil, created_at: nil, updated_at: nil>
どんな助けでも大歓迎です。ありがとう
コードを簡素化するために編集