Hi,
I have the regular has_many through setup:
user:
has_many subscriptions
has_many magazines, through subscriptions
subscription holds important data like expiration date and other
pieces of information.
I am looking to display the subscription information without having to
resort to an extra query for each magazine.
For my particular case I have a RESTful magazines controller where I
run :
@magazines = current_user.magazines. In my view I need to display the
subscription data for each magazine.
Doing something like @magazine.subscriptions would return all
subscriptions and @magazine.subscriptions.find(:first, :conditions =>
[ ‘magazine_id = xx AND user_id = xxx’ ]) would have to make a query
for each item.
How would you do it?
–
M