nested include

I'm trying to access data from the skins table through a nested include
with no luck. The association is all through imageasset but I do not
know how to figure it out. Any help is highly appreciated.

######the controller code#######
@furnii_from_furnii = Furni.find :all, :include => [{:raider =>
:imageasset}, :skin ]

This won't work unless Furni has an association called imageasset,
which it doesn't. If you want Activerecord to go through image asset
you're going to need to either write

:include => [{:raider => :imageasset}, {:imageasset => :skin}]

or

:include => {:raider => {:imageasset => :skin}}

Either way you have to have a skin (or skins, in which case
replace :skin by :skins in the above examples) association on
imageasset.

Fred

Fred,

Tried both your options and I'm still getting the error "Association
named 'skin' was not found; perhaps you misspelled it?"

furni has the association imageasset as belongs_to :imageasset. I'm not
sure that changes anything

I am Trying to get the data in the skins table. the Association between
furni, raider and skin is through imageasset id. Hope I make sense.

Sam Ginko wrote:

I am Trying to get the data in the skins table. the Association between
furni, raider and skin is through imageasset id. Hope I make sense.

When I said

This won't work unless Furni has an association called imageasset,
which it doesn't

I should of couse have said that ImageAsset should have a skin (or
possibly a skins association). You won't be getting anywhere without
one.

Fred

So in other words you mean that the imageasset model should have a
has_many :skin or should the association be in the imageasset table with
a skin id?

Frederick Cheung wrote:

So in other words you mean that the imageasset model should have a
has_many :skin or should the association be in the imageasset table with
a skin id?

Either a has_many or a has_one. you need to tell activerecord how to
find a skin from an imageasset (it isn't enough to just say that
imageasset belongs_to :skin, rails won't guess the association in the
other direction).

Fred

Got it.

this works to by the way :include =>[:raider, {:imageasset => :skin} ]

Frederick Cheung wrote: