Created
February 27, 2010 19:20
-
-
Save neaf/316890 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| Merb::Router::Behavior.class_eval do | |
| def add_resource(*key) | |
| register_resource(*key) | |
| end | |
| end | |
| Merb.logger.info("Compiling routes...") | |
| Merb::Router.prepare do | |
| identify(User => :id) do | |
| match('/signup').to(:controller => :users) do | |
| match(:method => 'get').to(:action => :new).add_resource("users", "new") | |
| match(:method => 'post').to(:action => :create).add_resource("users", "create") | |
| end | |
| match('/account').to(:controller => :users) do | |
| match(:method => 'get').to(:action => :edit).add_resource("user", "edit") | |
| match(:method => 'put').to(:action => :update).add_resource("user", "update") | |
| end | |
| end | |
| authenticate do | |
| identify(Gun => :id) do | |
| match('/guns').to(:controller => :guns) do | |
| match('/').to(:action => :index).add_resource("guns") | |
| match('/new') do | |
| match(:method => 'get').to(:action => :new).add_resource("guns", "new") | |
| match(:method => 'post').to(:action => :create).add_resource("guns", "create") | |
| end | |
| match('/edit') do | |
| match(:method => 'get').to(:action => :edit).add_resource("gun", "edit") | |
| match(:method => 'put').to(:action => :update).add_resource("gun", "update") | |
| end | |
| match('/:id').to(:action => :show).add_resource("Gun", :identifiers => [:id]) | |
| match('/:id/move_up/:direction').to(:action => :move).add_resource("Gun", "move_up", :identifiers => [:id]) | |
| match('/:id/add_pictures') do | |
| match(:method => 'get').to(:action => :add_pictures).add_resource("Gun", "add_pictures", :identifiers => [:id]) | |
| match(:method => 'put').to(:action => :store_pictures) | |
| end | |
| end | |
| end | |
| end | |
| # Adds the required routes for merb-auth using the password slice | |
| slice(:merb_auth_slice_password, :name_prefix => nil, :path_prefix => "") | |
| match('/').to(:controller => :pages, :action => :home).name(:home) | |
| match('/').to(:controller => :users, :action => :new).name(:help) | |
| match('/').to(:controller => :users, :action => :new).name(:contact) | |
| match('/').to(:controller => :users, :action => :new).name(:about) | |
| match('/').to(:controller => :users, :action => :new).name(:features) | |
| match('/').to(:controller => :users, :action => :new).name(:tos) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment