Collecting first segments of all routes in rails 3
问题 I'm trying to implement routes where the first segment is the profile's alias or id: resources :profiles, :path => '' do ... end And I need to validate that alias is not already taken by first segments of other(higher) routes. What I have now is: validates :alias, :exclusion => {:in => Rails.application.routes.routes.map{|r| r.path.spec.to_s.split('(').first.split('/').second}.compact.uniq }, .... In development everything is ok. In production Rails.application.routes.routes.map... returns