Problem linking tables and accessing relationship heirarchy

I'm reposting this her as somebody suggested I posted in the wrong forum
before.

I'm not quite understanding this relationship thing between models and
tables. What I am trying to do within my view is get the price
information
by referring to it like this:

<%= @item.itemprice.Qty1 %>

In each of my individual views for the item_master table and the
itemprice
table I can get the info directly, but I can't figure out how to access
the
price that corresponds to the item.

Here is my item.rhtml view test page:

The has_manys you've added mean that @item.itemprices will be an array of Itemprice objects, @item.itemprice (as you have found out) does not exist.

Fred

Frederick Cheung wrote:

[...]

The has_manys you've added mean that @item.itemprices will be an array
of Itemprice objects, @item.itemprice (as you have found out) does not
exist.

And what if there is a 1 to 1 relationship between tables? Then what
statement would be used in the item_master.rb instead of has_many?

Frederick Cheung wrote:

[...]

The has_manys you've added mean that @item.itemprices will be an
array
of Itemprice objects, @item.itemprice (as you have found out) does
not
exist.

And what if there is a 1 to 1 relationship between tables? Then what
statement would be used in the item_master.rb instead of has_many?

belongs_to or has_one (the difference is where the foreign key is
located - the documentation on associations has got a bit about this)

Fred

Frederick Cheung wrote:

belongs_to or has_one (the difference is where the foreign key is
located - the documentation on associations has got a bit about this)

Fred

Thank you Fred,

That helped quite a bit. One problem is that I had a table called
itemmaster with two fields one called ItemSerial and another called
ItemMasterID. This caused confusion with Ruby/Rails because my foreign
key was ItemSerial column.

I had to rename the ItemSerial field to id. Then when referencing the
price table Ruby/Rails wanted to reference a column called
item_master_id, so I had to rename my ItemSerial field to item_master_id
in the price table.

This was all confusing with the naming since I have a different column
called ItemMasterID that has nothing to do with the serial number.

It is confusing having to rename table columns, and not to be able to
directly reference them instead of using the default naming assumption.

-Brian