I tried putting the routes as you mentioned, still It doesn't seems to
work, let me put some more details of this problem.

The error -
----
ActiveRecord::RecordNotFound in OrdersController#show

Couldn't find Order with ID=pending_orders

F:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
base.rb:1586:in `find_one'
F:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
base.rb:1569:in `find_from_ids'
F:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/
base.rb:616:in `find'
F:/rails_app/../.../app/controllers/orders_controller.rb:29:in `show'

Request

Parameters:

{"id"=>"pending_orders"}
----

The routes:

map.resources :orders
map.resources :orders, :collection => { :pending_orders => :get }

Controller:

  def pending_orders
    @orders = Order.all(:joins =>
[:product, :customer, :unit], :include => :delivery, :conditions
=>[ may have some conditions ])
  end

Regards,
Sachin

On Feb 23, 12:55 pm, SachinJ <[email protected]> wrote:
> Hi Kurt, Robert,
> Thanks for the guidance, I will try it.
>
> Regards,
> Sachin
>
> On Feb 23, 3:34 am, "[email protected]" <[email protected]> wrote:
>
> > On Feb 22, 5:34 am, SachinJ <[email protected]> wrote:
>
> > > I have a Controller named Orders which has apending_ordersmethod
> > > which is expected to fetch some records from the database.
>
> > > If i dont write a route for this method, I get the following error
> > > when i call this method.
>
> > > Couldn't find Order with ID=pending_orders
> > > I am using rails 2.3.5, in the previous versions i use to get this
> > > I am not getting whether its new version requirement...
>
> > So your route table has:
> >   map.resources :orders
>
> > But you also want
> > /orders/pending_orders
>
> > rake routes shows:
> >      order GET    /orders/:id(.:format)
> > {:controller=>"orders", :action=>"show"}
>
> > So when you are trying to do /orders/pending_orders, it is trying to
> > look up the id='pending_orders'.
> > Not what you want.
>
> >http://guides.rubyonrails.org/routing.html
> > 3.11.2 Adding Collection Routes
>
> > To add a collection route, use the :collection option:
>
> > map.resources :photos, :collection => { :search => :get }
> > This will enable Rails to recognize URLs such as /photos/search using
> > the GET HTTP verb, and route them to the search action of the Photos
> > controller. It will also create a search_photos route helper.
>
> > So you want:
> >   map.resources :orders, :collection => { :pending_orders=> :get }
>
> > ---
> > Kurt Werle
> > I am looking for a new Rails job:http://www.CircleW.org/kurt/pages/resume

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to