Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6681019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:32:33+00:00 2026-05-26T04:32:33+00:00

This is in my routes.rb file: resources :orders do member do get ‘confirm’ get

  • 0

This is in my routes.rb file:

resources :orders do
  member do
    get 'confirm'
    get 'cancel'
  end
end

Of course I wrote the ‘confirm’ and ‘cancel’ actions in my orders_controller.rb:

def confirm
  @order = Order.find(params[:id])
  #...
end

def cancel
  @order = Order.find(params[:id])
  #...
end

..and created both “confirm.html.erb” and “cancel.html.erb” files in my “app/views/orders/” folder.

But when I try to access confirm_order_url or cancel_order_url I am always running into this routing error:

No route matches {:action=>"confirm", :controller=>"orders"}

Can’t figure out what’s missing!
Any idea please?

PS: I’m using RoR v.3.1.0

EDIT#1:
It seems the routes are set properly:

$ rake routes
[..]
 confirm_order GET    /orders/:id/confirm(.:format) {:action=>"confirm", :controller=>"orders"}
  cancel_order GET    /orders/:id/cancel(.:format)  {:action=>"cancel", :controller=>"orders"}
        orders GET    /orders(.:format)             {:action=>"index", :controller=>"orders"}
               POST   /orders(.:format)             {:action=>"create", :controller=>"orders"}
     new_order GET    /orders/new(.:format)         {:action=>"new", :controller=>"orders"}
    edit_order GET    /orders/:id/edit(.:format)    {:action=>"edit", :controller=>"orders"}
         order GET    /orders/:id(.:format)         {:action=>"show", :controller=>"orders"}
               PUT    /orders/:id(.:format)         {:action=>"update", :controller=>"orders"}
               DELETE /orders/:id(.:format)         {:action=>"destroy", :controller=>"orders"}
[...]

EDIT#2:
Maybe when I call confirm_order_url Rails doesn’t know how to generate the route which should be like “orders/:id/confirm” because @order.id hasn’t been assigned yet.
But I am calling this method after @order.save.
Namely, here:

  if @order.save
  response = PAYPAL_EXPRESS_GATEWAY.setup_purchase(@order.price_in_cents,
  :ip                => @order.ip_address,
  :return_url        => confirm_order_url,
  :cancel_return_url => cancel_order_url 
  )
  redirect_to PAYPAL_EXPRESS_GATEWAY.redirect_url_for(response.token)

So this leads to a subquestion: is @order.id set after the call to @order.save?
And if not, how can I set it properly before calling an helper method such ad confirmation_order_url?

SOLUTION
Thanks to Jayendra Patil i fixed my code this way:

  if @order.save
  response = PAYPAL_EXPRESS_GATEWAY.setup_purchase(@order.price_in_cents,
  :ip                => @order.ip_address,
  :return_url        => confirm_order_url(@order),
  :cancel_return_url => cancel_order_url(@order) 
  )
  redirect_to PAYPAL_EXPRESS_GATEWAY.redirect_url_for(response.token)

I was wrongly assuming that Rails could guess for which @order I was calling a “member” url, so the answer is to pass @order as the argument for member routes. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:32:34+00:00Added an answer on May 26, 2026 at 4:32 am

    This generates routes as –

    confirm_order GET    /orders/:id/confirm(.:format) {:action=>"confirm", :controller=>"orders"}
    cancel_order GET    /orders/:id/cancel(.:format)  {:action=>"cancel", :controller=>"orders"}
    

    you should use the order object or id with these routes –

    confirm_order_url(:id => @order.id)
    confirm_order_url(@order)
    

    Also Rails automatically assigns the id to the instance after it is saved so @order.id should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this piece of code: ActionController::Routing::Routes.draw do |map| map.resources :line_items map.resources :orders map.resources :products
I currently have a routes.rb file that looks like this: map.resources :profiles do |profile|
I have got this in my routes file: resources :users match '/@:id' => 'users#show'
I have an engine, with this routes file: Rails.application.routes.draw do resources :comments, :controller =>
I have the following in my routes file: resources :timelogs do member do post
In my routes.rb I have this: map.namespace :admin do |admin| admin.resources :galleries do |galleries|
I have the following nested resources in my routes.rb file. The inner resource specifies
I already have this in my routes file: namespace :api do root :to =>
I have some resources in my routes file: resources :snippets resources :pastes Users can
I have a problem to upgrade my routes.rb file. I converted this route: map.resource

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.