Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/calliope/routes.rb

Instance Method Summary collapse

Instance Method Details

#calliope(*blogs) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/calliope/routes.rb', line 4

def calliope(*blogs)
  options = blogs.extract_options!
  
  _options = { :path => ":name", :only => [:edit, :update] }
  _options[:constraints] = {
    :name => Regexp.new(blogs.map { |b| Regexp.escape(b.to_s) }.join('|'))
  } if blogs.any?
  
  resource :blog, _options do
    resources :posts, :except => :index do
      commentable :commentable => 'post' unless options[:comments] == false
    end
    
    root :to => "posts#index", :via => :get
  end
  
#        match "/:blog/:year/:month/:day/:url_title" => "posts#show",
#          :constraints => options[:constraints], :as => "pretty_blog_post"
end