That's not how :through works. has_many :through associations are only
used when there is an intermediate model between them.

What you can do is:

has_many :medias, :class_name => "Media" # Will return all media,
including paintings and videos
has_many :paintings, :class_name => "Painting"
has_many :videos, :class_name => "Video"

HTH

On Oct 12, 7:11 pm, Christian Fazzini <[email protected]>
wrote:
> Artist.first.medias returns all medias. Media is an STI. Media can be
> video or painting.
>
> How do I return all paintings of an artist? Only paintings, not
> videos?
>
> In my Artist model, I tried putting:
>
>   has_many :paintings, :through => :medias
>
> In console, I do:
>
>   Artist.first.paintings.all
>
> And I get:
>
>   ActiveRecord::HasManyThroughSourceAssociationNotFoundError: Could
> not find the source association(s) :painting or :paintings in model
> Media.  Try 'has_many :paintings, :through => :medias, :source =>
> <name>'.  Is it one of :artist?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to