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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:20:07+00:00 2026-05-23T13:20:07+00:00

I have a controller in Ruby on Rails and I would like to do

  • 0

I have a controller in Ruby on Rails and I would like to do the following:

When a user is trying to access the controller I want to match some parameters. For example

domain.com/hello/19213/sayHello

I want to translate this to:

domain.com/hello/:id/:method

in my routes files.

Keep in mind that :method parameter might not exist but :id will always be there.

In addition if it is possible I would like to match the specific :method with a method in my controller. If not I plan to use a switch case.

Can someone provide an example for this and what I have to put in my routes.rb?

I found this:

match ':controller(/:action(/:id(.:format)))'

But I believe that this is somehow different as I only want to match router for the specific controller not every controller in my project.

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-05-23T13:20:08+00:00Added an answer on May 23, 2026 at 1:20 pm

    By method, I assume you mean a method you have in your model. If that is the case, I believe you want something like this in your routes.rb

    match ':controller/:id(/:method)'
    

    The parentheses around :method mean that it is optional.

    If you do not include a method, it will evaluate your SHOW action with params[:id] = :id

    If you do include a method, it will evaluate the :method with params[:id] = :id

    This is for methods you have defined in your controller

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

Sidebar

Related Questions

I am using Ruby on Rails 3.0.7 and I would like to find some
I am using Ruby on Rails 3 and I would like to know some
I would like for a user within my ruby on rails app to be
In Ruby on Rails, I would like to add a before_filter to every controller
In Ruby on Rails, I have an update method in a controller, that is
Ruby on Rails controllers will automatically convert parameters to an array if they have
I have a controller action which I would like to call another controller action.
I have a controller with that I want to pass off some data to
I am creating a website in Ruby on Rails. I have a controller action
I have built a blog application w/ ruby on rails and I am trying

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.