Loading polymorphic belongs_to associations sometimes fails in Rails 4
Closed this issue · 0 comments
jturkel commented
Goldiloader fails to load polymorphic belongs_to associations in Rails 4 when the values have a mix of nil and non-nil values.
The corresponding stack trace is:
NoMethodError: undefined method `limit_value' for nil:NilClass
/Users/jturkel/.rvm/gems/ruby-2.0.0-p481@rails-4-upgrade/gems/goldiloader-0.0.7/lib/goldiloader/association_info.rb:30:in `limit?'
/Users/jturkel/.rvm/gems/ruby-2.0.0-p481@rails-4-upgrade/gems/goldiloader-0.0.7/lib/goldiloader/active_record_patches.rb:62:in `eager_loadable?'
/Users/jturkel/.rvm/gems/ruby-2.0.0-p481@rails-4-upgrade/gems/goldiloader-0.0.7/lib/goldiloader/active_record_patches.rb:51:in `auto_include?'
/Users/jturkel/.rvm/gems/ruby-2.0.0-p481@rails-4-upgrade/gems/goldiloader-0.0.7/lib/goldiloader/association_loader.rb:59:in `load?'
/Users/jturkel/.rvm/gems/ruby-2.0.0-p481@rails-4-upgrade/gems/goldiloader-0.0.7/lib/goldiloader/association_loader.rb:9:in `block in load'
/Users/jturkel/.rvm/gems/ruby-2.0.0-p481@rails-4-upgrade/gems/goldiloader-0.0.7/lib/goldiloader/association_loader.rb:8:in `select'
/Users/jturkel/.rvm/gems/ruby-2.0.0-p481@rails-4-upgrade/gems/goldiloader-0.0.7/lib/goldiloader/association_loader.rb:8:in `load'
/Users/jturkel/.rvm/gems/ruby-2.0.0-p481@rails-4-upgrade/gems/goldiloader-0.0.7/lib/goldiloader/active_record_patches.rb:78:in `load_with_auto_include'
/Users/jturkel/.rvm/gems/ruby-2.0.0-p481@rails-4-upgrade/gems/goldiloader-0.0.7/lib/goldiloader/active_record_patches.rb:92:in `find_target_with_auto_include'
/Users/jturkel/.rvm/gems/ruby-2.0.0-p481@rails-4-upgrade/gems/activerecord-4.0.10/lib/active_record/associations/association.rb:147:in `load_target'