category.supplier is the whole supplier record, so if you want the
name it is just
category.supplier.company_name
Such is the magic of Rails.
As a beginner I suggest you work right through a good tutorial in
order to get the basics or Rails. The one I suggest is
railstutorial.org (which is free to use online).
As a beginner I suggest you work right through a good tutorial in
order to get the basics or Rails. The one I suggest is
railstutorial.org (which is free to use online).
Colin
Thanks colin I already tried this but it give me the error:
Please quote the previous message when posting, this is a mailing list
not a forum (though you may be accessing it via a forum like
interface).
If the statement
category.supplier.company_name
gives the error undefined method `company_name' for nil:NilClass then
that means that category.supplier is nil, or to put it another way, it
means that category does not have an associated supplier. You
probably need something like
<td><%= category.supplier.company_name if category.supplier %></td>
which will only attempt to determine the name if category.supplier is not nil
As a beginner I suggest you work right through a good tutorial in
order to get the basics or Rails. The one I suggest is
railstutorial.org (which is free to use online).
Colin
Thanks colin I already tried this but it give me the error:
undefined method `company_name' for nil:NilClass
Please quote the previous message when posting, this is a mailing list
not a forum (though you may be accessing it via a forum like
interface).
If the statement
category.supplier.company_name
gives the error undefined method `company_name' for nil:NilClass then
that means that category.supplier is nil, or to put it another way, it
means that category does not have an associated supplier. You
probably need something like
<td><%= category.supplier.company_name if category.supplier %></td>
which will only attempt to determine the name if category.supplier is
not nil
Colin
Sory none of them worked, pls chk my app,
Just copy/paste the error here and the few lines of code around the failure.