On 30 March 2010 12:03, Nipuna Weerasinghe <[email protected]> wrote:
> Colin Law wrote:
>>...
>> I think we had better start again, show me the relationships you have
>> defined between your models, such as
>> x has many y, y belongs to x, or whatever it is, and what fields are
>> in the tables (just the important ones)
>>
> Thanks for keeping in touch.
> eg - order tabel- order id, desc, date, ....
>     item table- itemno,name,price,oder id...
>
> order id is common for both table, that is the link. One order has one
> or more items.
>
> want to show  relevant item/s details (relevant to particular order)
> when I click the show button in the order index form. I want to display
> both order and relevant item/s data in one form.

Did you have a look at the guides I suggested?  You do not appear to
be following the rails conventions.  For example the order table
should not have a field called order_id, it should just be id.  Also
the tables should be called orders and items, not order and item.
You have not told me the relationships (see the guide on ActiveRecord
relationships as I suggested).  It is presumably something like order
has_many items and item belongs_to order.  If you set this up
correctly then if you have an order in @order the items are
automatically available in the array @order.items.  Please spend a few
of days working through some of the guides and trying examples from
the guides.  It will be time well spent.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to