samedi 9 mai 2015

I'am getting error

NoMethodError in Data#input

Showing /home/adijanuarsyah/Projects/Food/app/views/data/_idfood.html.erb

where line #8 raised:

undefined method `find' for #<TopFood:0x007fdfd558fa90>

When i'am used find method for getting query food = foods.find(rand_number) i'am getting error like above , but when using TopFood.find(rand_number), its working perfectly.

Here is my view

<h2>Suggestion Indonesian top dishes</h2>
<ul id="foodList">

        <% TopFood.where(:country => "ind").find_each do |foods |  %> 
        <% rand_number = rand(52) + 1 %> 
            <% @food = foods.find(rand_number)%>
                <li><%= @food.name  %></li> 
            <% puts @food.inspect %> 
    <% end %>

</ul>
<div id="loadMore">More sugesstions</div>
<div id="showLess">Show less</div>

Any clue as to what is going on here?

Thanks.

Aucun commentaire:

Enregistrer un commentaire