Search code examples
ruby-on-railsrubyroutescontrollers

Rails Faux-Rename Controller


The title might be a little misleading, and I apologize for that. What I want to do is something like how Reddit renames their controller for their subreddits. They use the form /r/programming, instead of the longer /subreddit/programming. I know that they don't use Rails, but how would I go about doing that with Rails?

Thanks!


Solution

  • You can just use a matcher in your routing for this.

    In routes.rb

    resources :subreddits, :path => "/r"

    Further Reading: http://guides.rubyonrails.org/routing.html