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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:03:16+00:00 2026-05-20T15:03:16+00:00

Is it possible to forces Rails to use dashes (-) instead of underscores when

  • 0

Is it possible to forces Rails to use dashes (-) instead of underscores when referring to controllers.

There currently exists a nice function of the Inflector called parameterize. It allows for very nice permalinks with all special characters removed and replaced with dashes…

However, when using controllers that have multiple words (like contact_methods_controller.rb for example), you define your route:

resources :contact_methods

This creates a map to /contact_methods (NOT /contact-methods). When I mix these two, I get ugly URLs like:

/contact_methods/1-preferred-email

I’d like to have Rails map controllers with dashes instead of underscores. All my research says to individually map each controller:

match 'contact-methods(/:action)' => 'contact_methods'

but that is really stupid, in my opinion, and it becomes messy if I’m nesting resources… I shouldn’t have to define these as custom routes. Is there a setting in ActionDispatch that automatically rewrites these things? I can’t find one…

  • 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-20T15:03:17+00:00Added an answer on May 20, 2026 at 3:03 pm

    In your route.rb

    resources "contact-methods", :controller => :contact_methods, :as => :contact_methods
    

    Edit: You have to specify the :as => ... path or else ActionDispatch throws a fit…

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

Sidebar

Related Questions

I am currently in the process of learning Ruby on Rails. I have been
Is it possible to simulate custom forces (in my case, electromagnetic) using the SolidWorks
I currently work in an organization that forces all software development to be done
What message queues are people using for their Rails apps and what was the
Rails does model loading on demand. For a rake task that I'm writing, I
I am a newbie working in a simple Rails app that translates a document
I have a git repo which has a few branches - there's the master
Is it possible to do selects or polls on file descriptors in bash? The
Possible Duplicate: Simulating a BlueScreen Hello SO, I'm trying to induce a BSOD somehow
This is a question about the use of type classes in Haskell. I get

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.