I have a polymorphic asset model but would like two different versions of it for an asset class. Something like:
class Location < ActiveRecord::Base
has_many :assets, :as => :assetable, :order => 'position'
has_many :assets :known_as => :cover_images, :as => :assetable, :order => 'position'
I saw this question: Rails Polymorphic Association with multiple associations on the same model but when I implemented in Rails 3.1 with my models, it looked like:
has_many :assets, :as => :assetable, :order => 'position'
has_one :header_photo, :class_name => 'Asset', :as => 'assetable', :conditions => {:assetable_type => 'header_asset'}, :dependent => :destroy
Looking in console, I see:
SELECT `assets`.* FROM `assets` WHERE `assets`.`assetable_id` = 37 AND `assets`.`assetable_type` = 'Location' AND `assets`.`assetable_type` = 'header_asset' LIMIT 1
which is not what I want.
How would I do this? Is there syntax for handling this?
thx