Skip to content

Instantly share code, notes, and snippets.

@elricstorm
Created December 29, 2010 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elricstorm/758952 to your computer and use it in GitHub Desktop.
Save elricstorm/758952 to your computer and use it in GitHub Desktop.
# my forum software is called kirin
# this is an example routes engine file
# to see what the routes look like, just run rake routes from your app
Rails.application.routes.draw do
mount_at = Kirin::Engine.config.mount_at
match mount_at => 'kirin/widgets#index'
# administrative forum control panel
match mount_at + 'administration/cpanel' => 'kirin/admin#index'
scope mount_at do
resources :widgets, :only => [ :index, :show ],
:controller => "kirin/widgets",
:as => "kirin_widgets"
resources :forum_categories,
:controller => "kirin/forum_categories",
:as => "kirin_forum_categories" do
resources :forums, :controller => "kirin/forums"
end
resources :forums,
:controller => "kirin/forums",
:as => "kirin_forums" do
resources :moderators, :controller => "kirin/moderators"
resources :topics, :except => [:index], :controller => "kirin/topics"
end
resources :topics, :except => :index,
:controller => "kirin/topics",
:as => "kirin_topics" do
resources :posts, :except => [:index, :show], :controller => "kirin/posts"
end
resources :posts, :except => [:index,:show],
:controller => "kirin/posts",
:as => "kirin_posts"
# End of Scope - as you can see it has many resources nested in the one scope so it's very dry
end
# I've added some example custom controller routes where you might want to name a route specifically.
# In the two examples below, it will output the named routes as:
# create_new_kirin_topic /kirin/forum/:forum_id/topic/new(.:format)
# {:controller=>"kirin/topics", :action=>"new"}
# AND
# post_new_kirin_reply /kirin/forum/:forum_id/:topic_id/topic/reply(.:format)
# {:controller=>"kirin/posts", :action=>"new"}
controller "kirin/topics" do
scope '/', :as => 'create' do
scope :path => '/', :as => :new_kirin_topic do
match mount_at + '/forum/:forum_id/topic/new', :to => :new
end
end
end
controller "kirin/posts" do
scope '/', :as => 'post' do
scope :path => '/', :as => :new_kirin_reply do
match mount_at + '/forum/:forum_id/:topic_id/topic/reply', :to => :new
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment