finding a specific category

For the following controller:

thufir@arrakis ~/oreilly-recipes-categories $ cat app/controllers/ recipes_controller.rb -n | head -n 18 | tail -n 3     16 @recipe = Recipe.find(params[:id])     17 @categories= Category.find_all     18 end thufir@arrakis ~/oreilly-recipes-categories $

http://oreilly-recipes-categories.googlecode.com/svn/trunk/app/ controllers/recipes_controller.rb

I just want to pull up the Category instance which belongs to this Recipe instance. What should be on line 17 for that, please?

thanks,

Thufir

For the following controller:

thufir@arrakis ~/oreilly-recipes-categories $ cat app/controllers/ recipes_controller.rb -n | head -n 18 | tail -n 3    16 @recipe = Recipe.find(params[:id])    17 @categories= Category.find_all    18 end thufir@arrakis ~/oreilly-recipes-categories $

http://oreilly-recipes-categories.googlecode.com/svn/trunk/app/ controllers/recipes_controller.rb

I just want to pull up the Category instance which belongs to this
Recipe instance. What should be on line 17 for that, please?

@recipe.categories or @recipe.category depending on whether it's a
belongs_to or a has_many.

Fred

And then in the view (show), basically, the @category instance can be used just as the @recipe instance is used?

thufir@arrakis ~/oreilly-recipes-categories $ cat app/controllers/ recipes_controller.rb -n | head -n 18 | tail -n 4     15 def show     16 @recipe = Recipe.find(params[:id])     17 @category = @recipe.category     18 end thufir@arrakis ~/oreilly-recipes-categories $ cat app/models/recipe.rb class Recipe < ActiveRecord::Base         belongs_to :category end thufir@arrakis ~/oreilly-recipes-categories $

thanks,

Thufir

@recipe.categories or @recipe.category depending on whether it's a belongs_to or a has_many.

And then in the view (show), basically, the @category instance can be used just as the @recipe instance is used?

of course.

Fred