In my application I have 2 models: Foreign keys between sushi (Table 1) and Type_ Susie (Table 2) Whenever I'm showing Table 1 data, it shows me sushi type like your ID (1, 2, 3), but I would like to show the name of this type of sushi:
Tipo Sushi ", for example (yaksoba, sashimi) and id (1, 4 for example).
Do you help me?
& lt;% @ sushis.each do | Sushi | & Gt%; & Lt;% = sushi.name% & gt; & Lt;% = sushi.price% & gt; & Lt;% = sushi. Tipo_sushi_id% & gt; - & gt; (I think I need to change something I & lt;% = link_to 'Show', Sushi% & gt; & lt;% = link_to 'edit', edit_sushi_path (sushi)%> gt; & lt;% = Link_to 'deleted', sushi, method :: delete, enter dot code here: 'confirm:' are you sure? '}% < > Update: I've updated "sushi.tipo_sushi_id" from "sushi.tipo_sushi.name" , but I ' Message found: Undefined method for tiposhi 'arel_table': module .
I solved the problem by adding to Model / SushiRbb, comand related_to: tipo_user, class_name: sushitipo
.
thanks guys!
No comments:
Post a Comment