Tom
Tom

Reputation: 34366

Rails routing optional prefix

I have events which are accessible at /events/eventname I would also like the same events to be available at /events/PREFIX-eventname

I'm currently using the default:

resources :events in routes.rb

Initially idea was to add another routing statement

get "/events/prefix-:id" => "events#show"

Will adding an additional rule conflict with the resource statement? What's the best way of achieving this?

Upvotes: 0

Views: 207

Answers (1)

Rodrigo
Rodrigo

Reputation: 4802

You're right! Just add another routing statement:

resources :events
get "/events/prefix-:id" => "events#show"

This will create two routes to #show action.

Upvotes: 1

Related Questions