activerecord - Rails 3 - problem with associations -


i have following structure:

class delivery < activerecord::base   belongs_to :shop end 

and

class shop < activerecord::base   has_many :delivery end 

and in view

<% @shops.each |shop| %>   <% @deliveries.each |dlv| %>     <div><%= dlv.shop.type %></div>   <%end%> <% end %> 

getting error

undefined method `type' "#":shop

i printing data table shops , each item table want display items tabe "deliveries". though associations right, if getting error above, not sure already...

i ask help, wrong. thank in advance.

<% @shops.each |shop| %>   <% shop.delivery.each |dlv| %>     <div><%= dlv.type %></div>   <%end%> <% end %> 

the point of associations can access instance of model. note, has_many associations should pluralized.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -