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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:50:20+00:00 2026-06-04T13:50:20+00:00

I have this route namespace :api, defaults: {format: ‘json’} do namespace :v1 do post

  • 0

I have this route

namespace :api, defaults: {format: 'json'} do
   namespace :v1 do
      post .....
      get .....
   end
end

So instead of typing localhost:3000/api/v1/func is there a way to make the v1 defaulted (by routes) which then all I have to type is localhost:3000/api/func?

This way if I come out with api v2, all I have to do is change the route in one place.

Thanks!

  • 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-04T13:50:21+00:00Added an answer on June 4, 2026 at 1:50 pm

    If you’re eventually going to release a new API, then in all likelyhood the routes will probably be different, and the code that calls the routes will probably end up being different too.

    I would prefer to take the approach of passing the API version with the request, and then responding accordingly. Depending on the structure of your API, could could just need an API version with the first request, and then the rest would use that, via being saved in a session, etc. This is how long-standing APIs such as Paypal work.

    Saying that, if you want to do it, this question provides a way: API Versioning for Rails Routes

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

Sidebar

Related Questions

In my routes I have: resources :accounts This produces: accounts GET /accounts(.:format) accounts#index POST
I have a route defined like this: GET /question/:q_id controllers.Questions.viewQuestion(q_id: Long) Then in my
I have a route which routes a request to somepath/:id(.:format) to somecontroller#show . This
I have this route: # config/routes.rb map.namespace :backshop, :path_prefix => '/:shop_id/admin' do |backshop| backshop.resources
I have the following routes in my app: GET /admin/comments(.:format) {:controller=>admin/comments, :action=>index} admin_comments POST
I already have this in my routes file: namespace :api do root :to =>
I have this setup in my routes: namespace :admin do resources :posts end so
I have a Rails route definition that looks something like this: namespace :admin do
I have a route which looks something like this: map.namespace :a do |a| a.namespace
I made this namespace and route: namespace :api do resource :create_kpi, :except => [:edit,

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.