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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:11:21+00:00 2026-06-06T18:11:21+00:00

I have a Rails app that does everything I need it to do via

  • 0

I have a Rails app that does everything I need it to do via a HTML interface, now I’d like to bolt on an API providing access to bits of the functionality.

How would I do this selective forwarding of some API controller actions to another controller’s actions using the Routes.rb?

I have tried the following:

My regular controller routes work fine using:

match 'stuff' => 'stuff#index'
get 'stuff/index'
get 'stuff/some_get_action'
post 'stuff/some_post_action'

But then when I try for my API:

match 'api' => 'api#index'
match 'api/some_get_action' => 'stuff#some_get_action', :via => :get
match 'api/some_post_action' => 'stuff#some_post_action', :via => :post

or…

match 'api' => 'api#index'
get 'api/some_get_action', :to => 'stuff#some_get_action'
post 'api/some_post_action', :to => 'stuff#some_post_action'

I get an error. When I navigate to /api/index to server a HTML page that contains forms for testing the API URLs the url_for raises a ‘Routing error’ exception saying ‘No route matches…’.

  • 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-06T18:11:22+00:00Added an answer on June 6, 2026 at 6:11 pm

    You may want to include ‘:as => ‘ and define your route names that you may be using as your link paths.

    get 'api/some_get_action' => 'stuff#some_get_action', :as => 'some_get_action'
    

    and the link path in your index file will have ‘some_get_action_path’. Not sure that ‘match’ or ‘get’ automatically resolves to a path name, which by setting ‘:as’ it definitely will.

    I like your idea for setting up this page for testing. I’m always doing it in the console, which is surely more difficult than simply clicking a link. Your links probably need to infer that they are :json requests, not :http.

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

Sidebar

Related Questions

I have a Rails app that archives high-res images (and thumbs) on S3 (via
I have a rails app that makes web api call , the rails app
I have a medium-complex Rails app. The main controller (the one that does what
I have a Rails app that sets a cookie and does a redirect to
I have a simple rails app that is like an event system which has
I have a rails app that has asynchronous processing, and I'm having trouble getting
I have a Rails app that needs to expose values from a database as
We have a Rails app that instantiates a SWF object 16 times (it has
I have a rails app that I'm moving to another server and I figure
I have a rails app that I'm going to host on engineyard and want

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.