Refactoring Rails 3 Routes

Posted by Martin on Stack Overflow See other posts from Stack Overflow or by Martin
Published on 2011-01-30T07:23:43Z Indexed on 2011/01/30 7:25 UTC
Read the original article Hit count: 196

Hello, I have this in my routes:

get '/boutique/new' => 'stores#new', :as => :new_store, :constraints => { :id => /[a-z0-9_-]/ } 
post '/boutique' => 'stores#create', :as => :create_store, :constraints => { :id => /[a-z0-9_-]/ }
get '/:shortname' => 'stores#show', :as => :store, :constraints => { :id => /[a-z0-9_-]/ }
get '/:shortname/edit' => 'stores#edit', :as => :edit_store, :constraints => { :id => /[a-z0-9_-]/ }
put '/:shortname' => 'stores#update', :as => :update_store, :constraints => { :id => /[a-z0-9_-]/ }
delete '/:shortname' => 'stores#delete', :as => :destroy_store, :constraints => { :id => /[a-z0-9_-]/ }

Is there a cleaner way to do the same? It doesn't look any elegant and even less if I add some more controls/actions to it.

Thank you.

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby-on-rails-3