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

undefined method `polymorphic? #54

Open

Description

@igorkasyanchuk

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

Activity

  1. kuzmik commented on Sep 19, 2019

    @kuzmik

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions