Change
<%= subscription.magazine_id %>
to
<%= subscription.magazine.name %>
-Nathan
Kevin Burk wrote:
I've got yet another basic syntax question....
I've been setting up web forms for my application so that I can easily
add and change data using web forms, including setting up the data
links for many-to-many relationships. After much trial and error, I've
finally got it all working.
Even though I don't have 'extra data' I'm using the :through model for
my HABTM relationships so I can create a form that will allow me to
add and edit these relationships.
Using the AWD2 example, I've got magazines, readers and subscriptions.
I've got the subscriptions controller set up so that when I create a
new subscription, I've got a pull-down list of all of the magazine
names, and a pull-down list of all of the reader names, and that
automatically inserts the correct magazine_id and reader_id in the
subscription table. (Thanks, by the way to everyone who helped me with
that collection!)
Now, when I view the subscriptions, however, what I get is the IDs,
which isn't very helpful. I'd like to change the code in the admin
view for the subscriptions so that instead of displaying the integer
for the magazine_id and the reader_id, it shows the magazine.name(:id)
and reader.name(:id).
How do I do this? I assume this will require both code in the view AND
changes to the show action in the subscription_controller file. I need
to know what both of those changes should be.
Thanks in advance!
Kevin Burk
_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby