from the rails recipes i have a has_many through “working”.
I can list a user and what magazines he subscribes to. but I can’t
seem to figure out how to get the other attributes from subscriptions.
(like last_renewed_on)
i’m obviously lost.
i perused the has many through blog and flipped through my books and
googled. I also have a hard time turning the “command line” examples
into “views”
from the rails recipes i have a has_many through “working”.
I can list a user and what magazines he subscribes to. but I can’t
seem to figure out how to get the other attributes from subscriptions.
(like last_renewed_on)
First off, your iterator code isn’t as clear as it could be.
Is @readers a collection?
If it’s not, then it should probably read…
@reader.magazines.each do |magazine|
Since within the block you are working with magazines and not readers
(directly).
You should be able to access the subscription model directly from both
your reader and magazine models. If you can’t, you probably don’t have
it setup properly.
I’d suggest playing around in the console to make absolutely certain
everything works before writing views. (Actually, I’d really suggest
you write unit tests to make sure everything works (and continues to
work as you write more code).)
If you are using edge Rails, it makes it a lot easier to handle this
kind of relationship. I would look at the DHH’s Railsconf 2006 pdf
presentation online. It has similar examples. Another great resource
is Peepcode screencast on RESTful Rails.
Since the has_many through plugin has become part of the edge Rails,
will it create any problem if I have the plugin installed and use the
edge Rails at the same time?