0

I seem to be getting a little muddled here, so clarification more than anything needed here please.

I have a simple recipe app that enable users to upload recipes, and i have a section where all recipes with the category Dessert are listed

This class method (just a scope really) gives all recipes that have the category Dessert

def self.dessert_recipes
self.where(:category => "Desserts")

end

Within the controller I can then call this data to display in the view

@desserts = Recipe.dessert_recipes

And then in my view i can see the name of the recipe that has the category dessert

 <% @desserts.each do |r| %>
<p><%= link_to r.dish_name, recipe %></p>
  <p> <%= r.author %></p> # this doesnt exsist yet but it will
 <% end %>

What i want to do is click on the name of the recipe and it then take me to the show action for that particular recipe so that i can see the whole recipe from dish name to ingredients etc.

 <b><%= @recipe.dish_name %></b>
 <b><%= @recipe.catgegory %></b>

etc etc

The show action in the controller looks like this

 @recipe = Recipe.find(params[:id])

Im guessing that i cant access the whole of the recipe as im trying to access it within a different instance class? Some pointers on this would help so that i can get my head around what is happening

4

1 回答 1

1

Thank you to MrTheWalrus for this answer

link_to(r.dish_name, r)

于 2012-12-04T08:34:59.167 回答