Forum: Ruby on Rails routing error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7e9a27082d5ef910d7e90949777ee795?d=identicon&s=25 Sony Sebastian (zonyzeb)
on 2009-02-20 04:49
Hello,

       I have set up an application using scaffolding, which have all
basic method(index/new/edit/show/..). But when I tried to add a new
method it showing routing errors.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class ItemsController < ApplicationController
def index
..
end
def new
..
end
....
...

def list
(New method which I have created)
end

end


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error what I am getting is that,

Couldn't find Item with ID=list


How can I configure my routes.rb to avoid the issue.

Waiting for ur reply...
Aa9827db239813ad6c1bd1fcefd2c983?d=identicon&s=25 LaughingNinja (Guest)
on 2009-02-20 21:51
(Received via mailing list)
Try this:

  map.with_options :controller=>'ItemsController' do | ItemsController
|
   ItemsController.new   "/new",   :action => 'new'
   ItemsController. list  "/list",  :action => 'list'
  end

On Feb 19, 7:49 pm, Sony Sebastian <rails-mailing-l...@andreas-s.net>
Af10464d988bde1b15b1a324237bad84?d=identicon&s=25 Dharmdip Rathod (dharmdip)
on 2009-02-21 12:07
which  version of rails r u using ?
648a71a35ce6e4a1c5cd63451a2a20df?d=identicon&s=25 Gavin (Guest)
on 2009-02-21 14:24
(Received via mailing list)
Hi Sony - Have you specified the route in your routes.rb file?

Try adding

map.resources :items, :member => {:list => :get}

or

map.resources :items, :collection => {:list => :get} if this action is
not for one specific object at a time.

this will give you list_item_path(@item) or list_items_path


That might help with the routing issue.

Here's a great tutorial on routes:
http://guides.rubyonrails.org/routing_outside_in.html

On Feb 20, 3:49 am, Sony Sebastian <rails-mailing-l...@andreas-s.net>
This topic is locked and can not be replied to.