Ask A Question


You’re not receiving notifications from this thread.

Polymorphic Search

Dan Tappin asked in Databases

I have a basic model structure like this:

class History < ActiveRecord::Base
  belongs_to :historical, polymorphic: true, touch: true

with several related models:

has_many :history, :as => :historical, :dependent => :destroy

It seem to me that there is no easy way to search the History model AND the related models. For example each related model has a name and notes field. Can I do some sort of crazy multiple join and use conditions on the join?

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,770+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.