eddie
1
Hi. Please help guide me.
In my model ‘ads’…there’s a column for ‘user_id’…
In the user model, there’s is a column for ‘feedback_id’…
i’d like for my ads to display the user,
and the feedback score from the feedback model…
so should i include in my ‘ads’ model a column for ‘feedback_id’ too? or
is ‘user_id’ enough, and i’ll do a :through…
(i’m not even sure if it’s possible if :through can work like that. It’d
be cool if it did…)
eddie
2
Hi,
I am not sure that I follow everything you say but I think that if you
have the following:
class Feedback < ActiveRecord::Base
has_many :user
end
class User < ActiveRecord::Base
belongs_to :feedback
has_many :ads
end
class Ads < ActiveRecord::Base
belongs_to :user
end
Then you should be able to do something like
ads.user.feedback
to get the user feedback off of an ads object.
Disclaimer: I am rather new to all of this myself, so I could be
wrong…
Eric
Eddie wrote:
Hi. Please help guide me.
In my model ‘ads’…there’s a column for ‘user_id’…
In the user model, there’s is a column for ‘feedback_id’…
i’d like for my ads to display the user,
and the feedback score from the feedback model…
so should i include in my ‘ads’ model a column for ‘feedback_id’ too? or
is ‘user_id’ enough, and i’ll do a :through…
(i’m not even sure if it’s possible if :through can work like that. It’d
be cool if it did…)