Skip to content

Instantly share code, notes, and snippets.

@fujin
Created September 22, 2008 05:48
Show Gist options
  • Save fujin/11948 to your computer and use it in GitHub Desktop.
Save fujin/11948 to your computer and use it in GitHub Desktop.
~ Started request handling: Mon Sep 22 17:47:00 +1200 2008
~ Params: {"action"=>"index", "controller"=>"admin/dashboard"}
~ Named route admin_dashboard could not be generated with {} - (Merb::Router::GenerationError)
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/dispatch/router/route.rb:85:in `generate'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/controller/abstract_controller.rb:442:in `url'
/home/aj/www/junglist/app/helpers/global_helpers.rb:106:in `menu_items'
/home/aj/www/junglist/app/helpers/global_helpers.rb:27:in `render_menu'
/home/aj/www/junglist/app/views/layout/admin.html.erb:12:in `__home__aj__www__junglist__app__views__layout__admin_html_erb'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/controller/mixins/render.rb:130:in `send'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/controller/mixins/render.rb:130:in `render'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/controller/mixins/render.rb:204:in `display'
/home/aj/www/junglist/app/controllers/admin/dashboard.rb:8:in `index'
/home/aj/www/junglist/gems/gems/merb-action-args-0.9.8/lib/merb-action-args/abstract_controller.rb:35:in `__send__'
/home/aj/www/junglist/gems/gems/merb-action-args-0.9.8/lib/merb-action-args/abstract_controller.rb:35:in `_call_action'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/controller/abstract_controller.rb:254:in `_dispatch'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/controller/merb_controller.rb:190:in `_dispatch'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/dispatch/dispatcher.rb:117:in `dispatch_action'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/dispatch/dispatcher.rb:61:in `handle'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/dispatch/dispatcher.rb:29:in `handle'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/rack/application.rb:7:in `call'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/rack/middleware/static.rb:22:in `call'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/rack/handler/mongrel.rb:72:in `process'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:159:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:158:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel.rb:268:in `run'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/rack/adapter/mongrel.rb:22:in `start'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core/server.rb:60:in `start'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/lib/merb-core.rb:108:in `start'
/home/aj/www/junglist/gems/gems/merb-core-0.9.8/bin/merb:11
bin/merb:27:in `load'
bin/merb:27
~ Params: {"format"=>[], "action"=>"index", "controller"=>"admin/dashboard"}
##
# This builds the menu list from the menu items, returning the markup
def render_menu
menu = ""
menu_items.each_with_index do |item, index|
menu += "<li>#{link_to item[:text], item[:url]} #{render_link_dot(index, menu_items.size - 1)}</li>"
end
menu
end
##
# This returns all menu items, including those provided by plugins
def menu_items
items = []
items << {:text => "Dashboard", :url => url(:admin_dashboard)}
items << {:text => "Articles", :url => url(:admin_articles)}
items << {:text => "Plugins", :url => url(:admin_plugins)}
items << {:text => "Settings", :url => url(:admin_configurations)}
items << {:text => "Users", :url => url(:users)}
if self.current_user == :false
items << {:text => "Login", :url => url(:login)}
else
items << {:text => "Logout", :url => url(:logout)}
end
Hooks::Menu.menu_items.each { |item| items << item }
items
end
Named Routes
merb_auth_signup: /admin/signup
delete_admin_article: /admin/articles/:id/delete(.:format)
delete_admin_dashboard: /admin/dashboard/:id/delete(.:format)
admin_dashboard: /admin/dashboard/:id(.:format)
merb_auth_edit_user: /admin/users/:id/edit
new_admin_plugin: /admin/plugins/new(.:format)
admin_configuration: /admin/configurations/:id(.:format)
merb_auth_login: /admin/login
admin_articles: /admin/articles(/index)(.:format)
admin_categories: /admin/categories(/index)(.:format)
month: /:year/:month
merb_auth_default: /admin/:controller(/:action(/:id))(.:format)
merb_auth_delete_user: /admin/users/:id/delete
edit_admin_plugin: /admin/plugins/:id/edit(.:format)
admin_plugin: /admin/plugins/:id(.:format)
edit_admin_configuration: /admin/configurations/:id/edit(.:format)
default: /:controller(/:action(/:id))(.:format)
merb_auth_logout: /admin/logout
admin_article: /admin/articles/:id(.:format)
admin_plugins: /admin/plugins(/index)(.:format)
new_admin_category: /admin/categories/new(.:format)
year: /:year
merb_auth_users: /admin/users/
delete_admin_plugin: /admin/plugins/:id/delete(.:format)
delete_admin_configuration: /admin/configurations/:id/delete(.:format)
admin_category: /admin/categories/:id(.:format)
admin_configurations: /admin/configurations(/index)(.:format)
new_admin_article: /admin/articles/new(.:format)
new_admin_dashboard: /admin/dashboard/new(.:format)
merb_auth_new_user: /admin/users/new
edit_admin_category: /admin/categories/:id/edit(.:format)
new_admin_configuration: /admin/configurations/new(.:format)
merb_auth_user_activation: /admin/users/activate/:activation_code
edit_admin_article: /admin/articles/:id/edit(.:format)
edit_admin_dashboard: /admin/dashboard/:id/edit(.:format)
day: /:year/:month/:day
merb_auth_user: /admin/users/:id
delete_admin_category: /admin/categories/:id/delete(.:format)
Anonymous Routes
/:permalink
/admin/configurations(.:format)
/admin/configurations/:id(.:format)
/admin/configurations/:id(.:format)
/admin/dashboard(/index)(.:format)
/admin/dashboard(.:format)
/admin/dashboard/:id(.:format)
/admin/dashboard/:id(.:format)
/admin/categories(.:format)
/admin/categories/:id(.:format)
/admin/categories/:id(.:format)
/admin/plugins(.:format)
/admin/plugins/:id(.:format)
/admin/plugins/:id(.:format)
/admin/articles(.:format)
/admin/articles/:id(.:format)
/admin/articles/:id(.:format)
/admin
/^/admin/users(/|/index)?(\.:format)?$/
/^/admin/users/new$/
/^/admin/users/:id(\.:format)?$/
/^/admin/users/:id/edit$/
/^/admin/users/:id/delete$/
/^/admin/users/?(\.:format)?$/
/^/admin/users/:id(\.:format)?$/
/^/admin/users/:id(\.:format)?$/
/
Merb.logger.info("Compiling routes...")
Merb::Router.prepare do
# This deferred route allows permalinks to be handled, without a separate rack handler
match('/:permalink').defer_to do |request, params|
unless (article = Article.find_by_permalink(params[:permalink])).nil?
{:controller => "articles", :action => "show", :id => article.id}
end
end
# Admin namespace
namespace :admin do
resources :configurations
resources :dashboard
resources :categories
resources :plugins
resources :articles
match("").to(:controller => "dashboard", :action => "index")
end
# Mount merb-auth.
add_slice :MerbAuth, "admin"
# Year/month/day routes
match("/:year").to(:controller => "articles", :action => "index").name(:year)
match("/:year/:month").to(:controller => "articles", :action => "index").name(:month)
match("/:year/:month/:day").to(:controller => "articles", :action => "index").name(:day)
# Default routes, and index
default_routes
match('/').to(:controller => 'articles', :action =>'index')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment