Sha256: 01c5a0991c6b291eb117cabcca8b83a15c7b8c8a5a55d2ccc1004c027d7af583

Contents?: true

Size: 847 Bytes

Versions: 11

Compression:

Stored size: 847 Bytes

Contents

module MuckContents
  module Routes
    extend ActiveSupport::Concern
    
    included do
      add_routes
    end
    
    def add_routes
      routes.each do |route|
        match route[:uri] => 'contents#show', :defaults => { :id => route[:id], :scope => route[:scope] }
      end
    end
    
    def routes
      content_routes = []
      contents = Content.no_contentable.find(:all, :include => 'slugs')
      contents.each do |content|
        content_route = { :uri => content.uri,
                          :scope => content.scope,
                          :id => content.id }
        if !content_routes.include?(content_route)
          content_routes << content_route
        end
      end
      content_routes
    end
    
  end
end

module ActionDispatch::Routing
  class Mapper #:nodoc:
    include MuckContents::Routes
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
muck-contents-3.1.7 lib/muck-contents/routes.rb
muck-contents-3.1.6 lib/muck-contents/routes.rb
muck-contents-3.1.5 lib/muck-contents/routes.rb
muck-contents-3.1.4 lib/muck-contents/routes.rb
muck-contents-3.1.3 lib/muck-contents/routes.rb
muck-contents-3.1.2 lib/muck-contents/routes.rb
muck-contents-3.1.1 lib/muck-contents/routes.rb
muck-contents-3.1.0 lib/muck-contents/routes.rb
muck-contents-3.0.2 lib/muck-contents/routes.rb
muck-contents-3.0.1 lib/muck-contents/routes.rb
muck-contents-3.0.0 lib/muck_contents/routes.rb