polyamorous icon indicating copy to clipboard operation
polyamorous copied to clipboard

undefined method `polymorphic?

Open igorkasyanchuk opened this issue 6 years ago • 1 comments

With the latest version of gem

  1) Account::ArticlesController As admin GET #index returns http success
     Failure/Error: = f.select :cities_id_in, City.joins(:articles).ordered.distinct.collect{|e| [e.name, e.id]}, {include_blank: 'Select City'}, class: 'form-control', style: 'width: 200px'
     
     ActionView::Template::Error:
       undefined method `polymorphic?' for #<ActiveRecord::Reflection::PolymorphicReflection:0x0000000015772d50>
     # /usr/local/rvm/gems/ruby-2.6.1/gems/polyamorous-2.3.0/lib/polyamorous/activerecord_5.2.0_ruby_2/reflection.rb:4:in `build_join_constraint'
     # /usr/local/rvm/gems/ruby-2.6.1/gems/polyamorous-2.3.0/lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb:53:in `make_constraints'
     # /usr/local/rvm/gems/ruby-2.6.1/gems/polyamorous-2.3.0/lib/polyamorous/activerecord_5.2.1_ruby_2/join_dependency.rb:36:in `join_constraints'
     # ./app/views/account/articles/index.html.slim:26:in `collect'

Schema is:

City
  has_many :city_relations, dependent: :destroy
  has_many :articles, through: :city_relations, source: :relationable, source_type: 'Article'

class CityRelation
  belongs_to :city
  belongs_to :relationable, polymorphic: true

class Article
  has_many :city_relations, as: :relationable, dependent: :destroy
  has_many :cities, through: :city_relations

igorkasyanchuk avatar Aug 19 '19 19:08 igorkasyanchuk

I too am getting this error after updating ransack (and polyamorous).

kuzmik avatar Sep 19 '19 20:09 kuzmik