Skip to content

Instantly share code, notes, and snippets.

@yaotti
Created December 4, 2013 10:46
Show Gist options
  • Save yaotti/7785642 to your computer and use it in GitHub Desktop.
Save yaotti/7785642 to your computer and use it in GitHub Desktop.
Rails 4.0.1以降へのアップデート後に`ARModel.create`が`NoMethodError: undefined method '[]' for nil:NilClass`というエラーを吐く ref: http://qiita.com/yaotti/items/73305e3719c309f8d0d6
[1] pry(main)> User.create
NoMethodError: undefined method `[]' for nil:NilClass
from /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activerecord-4.0.2/lib/active_record/attribute_methods/read.rb:86:in `block in read_attribute'
NoMethodError:
undefined method `[]' for nil:NilClass
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activerecord-4.0.2/lib/active_record/attribute_methods/read.rb:86:in `block in read_attribute'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activerecord-4.0.2/lib/active_record/attribute_methods/read.rb:84:in `fetch'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activerecord-4.0.2/lib/active_record/attribute_methods/read.rb:84:in `read_attribute'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activerecord-4.0.2/lib/active_record/attribute_methods/time_zone_conversion.rb:38:in `notification_last_seen='
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/attribute_assigner.rb:16:in `block (2 levels) in object'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/attribute_assigner.rb:15:in `each'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/attribute_assigner.rb:15:in `block in object'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/attribute_assigner.rb:14:in `tap'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/attribute_assigner.rb:14:in `object'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/evaluation.rb:12:in `object'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/strategy/create.rb:9:in `result'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/factory.rb:42:in `run'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/factory_runner.rb:23:in `block in run'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/notifications.rb:161:in `instrument'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/factory_runner.rb:22:in `run'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/factory_girl-4.3.0/lib/factory_girl/strategy_syntax_method_registrar.rb:20:in `block in define_singular_strategy_method'
# /Users/yaotti/src/qiita/spec/spec_helper.rb:99:in `foo'
# /Users/yaotti/src/qiita/spec/spec_helper.rb:62:in `block (2 levels) in <top (required)>'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:21:in `instance_eval'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:21:in `run'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:100:in `run'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/hooks.rb:418:in `run_hook'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:320:in `block in run_before_all_hooks'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/memoized_helpers.rb:96:in `block in isolate_for_before_all'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/memoized_helpers.rb:92:in `instance_eval'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/memoized_helpers.rb:92:in `isolate_for_before_all'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:319:in `run_before_all_hooks'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/example_group.rb:370:in `run'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `block (2 levels) in run'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `map'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:28:in `block in run'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/reporter.rb:34:in `report'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/command_line.rb:25:in `run'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:80:in `run'
# /opt/boxen/rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec/core/runner.rb:17:in `block in autorun'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment