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 8853827
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:44:36+00:00 2026-06-14T13:44:36+00:00

I am trying to add an custom action to a resource but I get

  • 0

I am trying to add an custom action to a resource but I get a routing error No route matches [GET] "/products/list/up". I have tried commenting out the URI in routes.rb, but they also don’t work. What am I doing wrong?

I have this in the routes.rb:

 namespace :api, :defaults =>{format: 'json'} do
 scope module:  :v1 ,constraints: ApiConstraints.new(version:1, default: true) do

resources :products do
member do
  match  "/list/up" =>"products#product_list" ,:via=>:get
  #get "/list/up" , :action=>"product_list"
  #get "/list/up" , :to=>"product_list"
end
end
 end
 end

in the products_controller.rb:

def product_list
  @products= Product.all
  respond_to do |format|
    format.json { render json: @products.to_json}
  end
end
  • 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-06-14T13:44:37+00:00Added an answer on June 14, 2026 at 1:44 pm

    Try collection instead of member as you don’t provide any id in the path:

    resources :products do
        collection do # <-----<
            get  "/list/up" =>"products#product_list"
        end
    end
    

    Running rake routes gives:

    list_up_products GET    /products/list/up(.:format)  products#product_list
            products GET    /products(.:format)          products#index
                     POST   /products(.:format)          products#create
         new_product GET    /products/new(.:format)      products#new
        edit_product GET    /products/:id/edit(.:format) products#edit
             product GET    /products/:id(.:format)      products#show
                     PUT    /products/:id(.:format)      products#update
                     DELETE /products/:id(.:format)      products#destroy
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a custom action to a core controller by extending it
I'm trying to add a custom action to Devise's registration controller which allows users
Have had no luck trying to add a reference to a custom.css file to
I am trying to add custom icons to a Shared Add-in for Microsoft Word.
I'm creating a custom WP theme and trying to add custom menus to the
I'm trying to add a custom class to the jQuery Mobile theme. The CSS
I am trying to add a custom log handler to my java application. I
I am trying to add a custom field to the user form in the
I'm trying to add a custom catalog index based on the recommendation here: http://collective-docs.readthedocs.org/en/latest/searching_and_indexing/indexing.html#custom-index-methods
I am trying to add a custom UIBarButtonItem to my navigationItem. This button will

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.