This project is archived and is in readonly mode.

#712 ✓duplicate

Added the ability to have a polymorphic in a conditions hash

Reported by Mark | July 27th, 2008 @ 01:37 PM | in 2.x

Pretty simple enhancement:

If you have:

class Tagging < ActiveRecord::Base
  belongs_to :taggable, :polymorphic => true

class Post < ActiveRecord::Base
  has_many :taggings, :as => :taggable

You can do:

Tagging.find :all, :conditions => {:taggable => Post.find 1 }

and you will get a find with this sql along the lines of:

SELECT * FROM taggings WHERE taggable_id = 1 AND taggable_type = 'Post'

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>

People watching this ticket