ユーザーのサインアップ後にユーザーのウォレットを作成する必要がある
ユーザーモデルを持っています:
has_one :wallet, :dependent => :destroy
after_create :create_wallet
def create_wallet
self.wallet.create(params[:wallet])
end
とウォレットモデル
class Wallet < ActiveRecord::Base
belongs_to :user
end
サインアップすると、このエラーが返されました
Started POST "/users" for 127.0.0.1 at 2012-08-03 13:40:41 +0300
Creating scope :page. Overwriting existing method User.page.
Processing by UsersController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"7rgoJQwWFFbo4Wv6gHF2AzwQpCQwB+Pp/kaNRw/YW/k=", "user"=>{"email"=>"rmagnum2002@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign Up"}
Creating scope :page. Overwriting existing method Product.page.
(0.2ms) BEGIN
(0.3ms) SELECT 1 FROM `users` WHERE `users`.`email` = BINARY 'rmagnum2002@gmail.com' LIMIT 1
(0.3ms) SELECT 1 FROM `users` WHERE `users`.`auth_token` = 'S5R9LGhWVn6ut6Uh4h7KCA==' LIMIT 1
SQL (0.2ms) INSERT INTO `users` (`auth_token`, `created_at`, `email`, `password_digest`, `password_reset_sent_at`, `password_reset_token`, `updated_at`) VALUES ('S5R9LGhWVn6ut6Uh4h7KCA==', '2012-08-03 10:40:41', 'rmagnum2002@gmail.com', '$2a$10$KnwA.xrFY4z6eao7SmjHM.dq4ypmZZv3Rnk5LT9pg1jpiwxbl2YkK', NULL, NULL, '2012-08-03 10:40:41')
Creating scope :page. Overwriting existing method Wallet.page.
Wallet Load (0.1ms) SELECT `wallets`.* FROM `wallets` WHERE `wallets`.`user_id` = 4 LIMIT 1
(27.2ms) ROLLBACK
Completed 500 Internal Server Error in 158ms
NameError (undefined local variable or method `params' for #<User:0x9af5894>):
app/models/user.rb:39:in `create_wallet'
app/controllers/users_controller.rb:57:in `block in create'
app/controllers/users_controller.rb:56:in `create'
app/controllers/application_controller.rb:78:in `catch_not_found'
app/middleware/flash_session_cookie_middleware.rb:17:in `call'
Rendered vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
Rendered vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms)
Rendered vendor/bundle/ruby/1.9.1/gems/actionpack-3.1.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (3.1ms)
私が構築したコードは、この回答に基づいています
私は何を間違っていますか。助けてください。ありがとうございました。