[英]NoMethodError, undefined method `name' for nil:NilClass -rails 3
[英]Rails 4 - rake db:seed NoMethodError: undefined method `name' for nil:NilClass
成功運行rake db:migrate
,嘗試運行rake db:seed --trace
但出現特殊錯誤NoMethodError: undefined method 'name' for nil:NilClass
。
不完全確定問題是什么。 任何建議將不勝感激。 謝謝!!
/usr/local/bundle/gems/activerecord-4.1.1/lib/active_record/associations/has_many_association.rb:74: warning: circular argument reference - reflection
/usr/local/bundle/gems/activerecord4.1.1/lib/active_record/associations/has_many_association.rb:78: warning: circular argument reference - reflection
/usr/local/bundle/gems/activerecord4.1.1/lib/active_record/associations/has_many_association.rb:82: warning: circular argument reference - reflection
/usr/local/bundle/gems/activerecord4.1.1/lib/active_record/associations/has_many_association.rb:101: warning: circular argument reference - reflection
rake aborted!
NoMethodError: undefined method `name' for nil:NilClass
/usr/local/bundle/gems/activerecord-4.1.1/lib/active_record/associations/has_many_association.rb:79:in `cached_counter_attribute_name'
/usr/local/bundle/gems/activerecord-4.1.1/lib/active_record/associations/has_many_association.rb:75:in `has_cached_counter?'
/usr/local/bundle/gems/activerecord-4.1.1/lib/active_record/associations/has_many_association.rb:83:in `update_counter'
/usr/local/bundle/gems/activerecord-4.1.1/lib/active_record/associations/has_many_through_association.rb:65:in `insert_record'
/usr/local/bundle/gems/activerecord-4.1.1/lib/active_record/associations/collection_association.rb:522:in `block (2 levels) in concat_records'
#db/seeds.rb
APP_KEYWORDS = YAML.load_file("#{Rails.root}/db/app_keywords.yml")
User.create(email: 'name@name.com', password: 'passwrd', password_confirmation: 'passwrd')
User.create(email: 'name@name.com', password: 'psswrd', password_confirmation: 'psswrd')
User.create(email: 'name@name.com', password: 'password', password_confirmation: 'password')
User.create(email: 'name@name.com', password: 'password', password_confirmation: 'password')
APP_KEYWORDS["app"].each do |key,value|
app = App.find_or_create_by(name:key.downcase)
value.each do |val|
app.app_keywords.find_or_create_by(keyword:val.downcase)
end
end
["admin","moderator","venue_editor","user"].each do |role|
Role.find_or_create_by(name:role)
end
user = User.first
user.add_role :admin
遵循問題: https : //github.com/activescaffold/active_scaffold/issues/380
嘗試更新Rails 4.1.2版本
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.