Hi,

You must have defined has_many and belongs_to association for Country
and Product.

So now you can directly write:
@product.country.name

-Hemali Chauhan

On May 24, 3:14 pm, Mike75 <youp....@gmail.com> wrote:
> hi
> i'm trying things out with rails, and I'm having trouble with showing
> a list of products.
> i hope someone can help me out with this..
>
> my tables are simple and it contains the following fields
>
> product table : id | Name | Price | Country_id
> country table : id | CountryName
>
> and I input products info with selected id numbers from the "country"
> table and insert the country.id into products.Country_id.
>
> I am trying to show countryName from the country table on the products
> list.
>
> it would be wonderful if anyone can help me out with this..
>
> thank you

--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to