Skip to content

Instantly share code, notes, and snippets.

@neaf
Created December 19, 2009 20:01
Show Gist options
  • Select an option

  • Save neaf/260226 to your computer and use it in GitHub Desktop.

Select an option

Save neaf/260226 to your computer and use it in GitHub Desktop.
Merb::Router::Behavior.class_eval do
def add_resource(*key)
register_resource(*key)
end
end
Merb.logger.info("Compiling routes...")
Merb::Router.prepare do
slice(:merb_auth_slice_password, :name_prefix => nil, :path_prefix => "")
identify(User => :id) do |r|
match('/clients').to(:controller => :users, :action => :index).add_resource("users")
match('/client/:id').to(:controller => :users, :action => :show).add_resource("User", :identifiers => [:id])
match('/register').to(:controller => :users) do
match(:method => 'get').to(:action => :new).add_resource("user", "new")
match(:method => 'post').to(:action => :create).add_resource("user", "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
match('/').to(:controller => 'users', :action =>'index').name(:home)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment