成功运行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
答案 0 :(得分:0)
问题出现后:https://github.com/activescaffold/active_scaffold/issues/380
尝试更新rails 4.1.2版本