Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

undefined method `polymorphic? #54

Open
igorkasyanchuk opened this issue Aug 19, 2019 · 1 comment
Open

undefined method `polymorphic? #54

igorkasyanchuk opened this issue Aug 19, 2019 · 1 comment

Comments

@igorkasyanchuk
Copy link

igorkasyanchuk commented Aug 19, 2019

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
@kuzmik
Copy link

kuzmik commented Sep 19, 2019

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants