Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Added the ability to have a polymorphic in a conditions hash

#712

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'

Reported by Mark · July 27th, 2008 @ 01:37 PM

State: duplicate
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. nikz
    nikz

    Hey Mark,

    Check out:

    http://rails.lighthouseapp.com/p...

    and

    http://rails.lighthouseapp.com/p...

    and the associated mailing list discussion :)

    Is this a duplicate of some of those?

    Cheers,

    Nik

    July 27th, 2008 @ 10:34 PM

  2. Tarmo Tänav
    Tarmo Tänav
    • State changed from new to duplicate
    • Tag changed from activerecord, enhancement to activerecord, enhancement

    Looks like a duplicate of #467 Hash Conditions belongs_to sugar

    September 18th, 2008 @ 06:19 AM