Forum: Ruby on Rails has_many / has_one polymorphic with conditions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
James R. (Guest)
on 2007-04-21 10:08
I'm looking for a way to make this work (I think the code is more
explanatory at this point):

## THIS WORKS
has_many :images, :as => :imageable, :dependent => :destroy, :order =>
'position ASC'

# @product.images =>  #

## THIS DOESNT
has_one :featured_image, :as => :imageable, :conditions => "position =
1"

# @product.featured_image => NameError: uninitialized constant
Product::FeaturedImage

...I could always add a "featured_image" method to the product model,
but I wanted to see if this was possible first.

Thanks

J
This topic is locked and can not be replied to.