Rails 3, create a new route for every resource
问题 In a project I'm working on I'd like to add the same route for multiple resources. I know I can do this resources :one do collection do post 'common_action' end end resources :two do collection do post 'common_action' end end I have at least 10 different resources which all need the same route, as each controller will have the same action. Is there a way to define this less repetitively? 回答1: %w(one two three four etc).each do |r| resources r do collection do post 'common_action' end end end