Help from rubyonrails 2.1

hi every one !
receintly i am working on rails 2.1,i have start it from scaffold
,besides from the pages which is created by scaffold automatically ,i
have created the page “ingrendient.html.erb” and i have added the method
ingredient
def ingredient

end
but i have faced the error massage when i tried to open the page
ingredient.html.erb
error massage is
“Couldn’t find Drug with ID=ingredient”
can anyone help me .please

On Wed, Aug 20, 2008 at 8:15 AM, Rustam M. <
[email protected]> wrote:

ingredient.html.erb
error massage is
“Couldn’t find Drug with ID=ingredient”
can anyone help me .please

The scaffold in Rails 2.1 uses what is called Resources (
http://api.rubyonrails.org/classes/ActionController/Resources.html). In
your config/routes.rb, you should see a line like:

map.resources :recipes

To add a custom method outside the standard 7 (index, show, new, create,
edit, update, destroy), you need to tell resources about it. There are
2
different types of methods on a resource: collection and member. If the
action acts on multiple models, it’s a collection, if it acts on a
single
model (requires params[:id]), then it is a member.

map.resources :recipes, :collection => {:ingredients => :get}

Hope that helps,
Brandon

Sessions by Collective Idea: Ruby on Rails training in a vacation
setting
http://sessions.collectiveidea.com

thanks Brandon it helped me out!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs