Matt Elhotiby
Matt Elhotiby

Reputation: 44066

custom routing in rails

I have a rails application that has a model named graphic and as any rails application there is normal routing like this

something.com/graphics/1
something.com/graphics/2
something.com/graphics/3

which will take you to the appropriate show pages. That I understand this is done in my routes by this statement

resources :graphics

Now come to find out the client wants to have the url to be like this

something.com/1
something.com/2
something.com/3

so if there is a number directly after the root url then like it to the graphic show action....any ideas on how to do this without messing up any other models

Upvotes: 1

Views: 136

Answers (1)

m4risU
m4risU

Reputation: 1241

Seems like you are looking for:

match "/:id" => "graphics#show"

You can refer to http://guides.rubyonrails.org/routing.html for any further modifications.

Upvotes: 6

Related Questions