Sha256: f80742f851a64caf42993ee2dc1efb2b604aab8398fa3657b1501bc3ca7b279f

Contents?: true

Size: 816 Bytes

Versions: 3

Compression:

Stored size: 816 Bytes

Contents

Rails.application.routes.draw do

  resources :blogs
  resources :posts

  class BlogConstraint
    def initialize; end
    def matches?(request)
      Blog.where(:slug => request.path.split('/')[1]).first
    end
  end

  constraints(BlogConstraint.new) do
    get ':blog_slug', :to => 'blogs#show'
    get ':blog_slug/archive', :to => 'blogs#archive'
    get ':blog_slug/search', :to => 'blogs#search', :as => :search_blog
    get ':blog_slug/feed', :to => 'blogs#feed', :format => [:rss]
    get ':blog_slug/:post_slug', :to => 'posts#show'
  end

  class AdminConstraint
    def initialize; end
    def matches?(request)
      request.subdomain =~ /admin/
    end
  end

  constraints(AdminConstraint.new) do
    namespace :admin do
      resources :blogs do
        resources :posts
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blog_logic-0.7.4 config/routes.rb
blog_logic-0.7.3 config/routes.rb
blog_logic-0.7.2 config/routes.rb