Created
June 17, 2013 20:52
-
-
Save adamkleingit/5800283 to your computer and use it in GitHub Desktop.
Routes for STI models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you want url_for(CoolProject) to give you 'cool_projects/1' but still go to ProjectsController then: | |
resources :cool_projects, :controller => :projects | |
# If you want url_for(CoolProject) to give you 'projects/1' and also go to ProjectsController then: | |
resources :cool_projects, :controller => :projects, :as => :projects | |
# If you want to reuse stuff inside resources: | |
projects_inner = lambda do | |
member do | |
resources :submodels | |
end | |
end | |
resources :cool_projects, :controller => :projects, :as => :projects, &projects_inner | |
resources :projects, &projects_inner | |
# If you want to pass a parameter of type then: | |
resources :cool_projects, :controller => :projects, :as => :projects, :type => 'CoolProject', &projects_inner | |
resources :projects, :type => 'Project', &projects_inner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment