・前提・実現したいこと
Railsアプリでユーザー登録したい
・発生している問題・エラーメッセージ
Railsアプリを作ってる時にユーザー登録しようとするとエラーになってしまいました。
UserコントローラーのCreateメソッドにcontentはないのですが。
PostコントローラーのCreateメソッドにはcontentはあるので、それが影響しているのでしょうか。
すみませんが、アドバイスをお願いします。
・ソースコード
rails
1 def create 2 @user = User.new(name: params[:name], email: params[:email]) 3 @user.save 4 redirect_to users_path 5 end
https://github.com/mkakiz/DayShare
・問題の発生した環境
Rails5
Docker
Mac
・試したこと
rails
1$ rails console 2> user = User.new(name: 'cat', email: 'cat@example.com') 3> user.save 4 (0.6ms) BEGIN 5 (0.7ms) ROLLBACK 6NoMethodError: undefined method `content' for #<User:0x0000562feb919878> 7Did you mean? concern 8 from /usr/local/bundle/gems/activemodel-5.0.7.2/lib/active_model/attribute_methods.rb:433:in `method_missing' 9 from /usr/local/bundle/gems/activemodel-5.0.7.2/lib/active_model/validator.rb:149:in `block in validate' 10 from /usr/local/bundle/gems/activemodel-5.0.7.2/lib/active_model/validator.rb:148:in `each' 11 from /usr/local/bundle/gems/activemodel-5.0.7.2/lib/active_model/validator.rb:148:in `validate' 12 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:405:in `public_send' 13 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:405:in `block in make_lambda' 14 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:169:in `block (2 levels) in halting' 15 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:547:in `block (2 levels) in default_terminator' 16 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:546:in `catch' 17 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:546:in `block in default_terminator' 18 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:170:in `block in halting' 19 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:454:in `block in call' 20 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:454:in `each' 21 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:454:in `call' 22 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:101:in `__run_callbacks__' 23 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/callbacks.rb:750:in `_run_validate_callbacks' 24... 23 levels... 25 from /usr/local/bundle/gems/railties-5.0.7.2/lib/rails/commands/console_helper.rb:9:in `start' 26 from /usr/local/bundle/gems/railties-5.0.7.2/lib/rails/commands/commands_tasks.rb:78:in `console' 27 from /usr/local/bundle/gems/railties-5.0.7.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!' 28 from /usr/local/bundle/gems/railties-5.0.7.2/lib/rails/commands.rb:18:in `<top (required)>' 29 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `require' 30 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `block in require' 31 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:259:in `load_dependency' 32 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `require' 33 from /app/bin/rails:9:in `<top (required)>' 34 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:287:in `load' 35 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:287:in `block in load' 36 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:259:in `load_dependency' 37 from /usr/local/bundle/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:287:in `load' 38 from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require' 39 from /usr/local/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:54:in `require' 40 from -e:1:in `<main>'
回答1件
あなたの回答
tips
プレビュー