# Has\_many / has\_one polymorphic with conditions

**URL:** <https://www.ruby-forum.com/t/has-many-has-one-polymorphic-with-conditions/92596>\
**Category:** Rails\
**Created:** [April 21, 2007, 8:08am UTC](https://www.ruby-forum.com/t/has-many-has-one-polymorphic-with-conditions/92596 "2007-04-21T08:08:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [April 21, 2007, 8:08am UTC](https://www.ruby-forum.com/t/has-many-has-one-polymorphic-with-conditions/92596/1 "2007-04-21T08:08:04Z")

</div>

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
