github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

caring / default_routing

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 24
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

SEO Plugin for Ruby-on-Rails to enable more compact routes by declaring a nested resource as the default. — Read more

  cancel

http://caring.lighthouseapp.com/projects/12742-default_routing

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

This commit allows the index action of the nested resource to take 
priority over the 
chriseppstein (author)
Mon Jun 16 07:59:46 -0700 2008
commit  9aa485807130206e0074c78037013d40d622f6bc
tree    b3a53a7a91529f78d58f0020b81b829aff36aa5e
parent  2b767cb106892582a1023df1812be5147df75a71
default_routing /
name age
history
message
file MIT-LICENSE Loading commit data...
file README
file Rakefile
file init.rb
directory lib/
directory test/
README
DefaultRouting
==============

This is an SEO Optimization plugin that allows you to specify that one or more nested routes will not have
a path segment added to their url.

When combined with acts_as_url_param (or some other pretty url plugin), this results in nice tight urls without any 
extra folders in them in the cases where you can safely get away with it.

This plugin adds new new routing options:
* :default - When true, causes the resource to not generate a namespace prefix
* :show - a symbol identifying a nested resource whose index action should *replace* this resources show action.

It's important to note that using a :default nesting results in a url collision that hides the index action of the 
nested resource. If routing to the index action is more desirable, use the :show option instead.

Example
=======

map.namespace :forum do |forum|
  forum.resources :boards, :default => true, :show => :threads do |boards|
    boards.resources :threads, :show => posts do |threads|
      threads.resources :posts
    end
  end
end

% rake routes | grep forum | grep -v format

                forum_boards GET    /forum
                             POST   /forum
             new_forum_board GET    /forum/new
            edit_forum_board GET    /forum/:id/edit
                             PUT    /forum/:id
                             DELETE /forum/:id
         forum_board_threads GET    /forum/:board_id             # prevents recognition of forum_board
                             POST   /forum/:board_id
      new_forum_board_thread GET    /forum/:board_id/new
     edit_forum_board_thread GET    /forum/:board_id/:id/edit
                             PUT    /forum/:board_id/:id
                             DELETE /forum/:board_id/:id
    forum_board_thread_posts GET    /forum/:board_id/:thread_id  # prevents recognition of forum_board_thread
                             POST   /forum/:board_id/:thread_id
 new_forum_board_thread_post GET    /forum/:board_id/:thread_id/new
edit_forum_board_thread_post GET    /forum/:board_id/:thread_id/:id/edit
     forum_board_thread_post GET    /forum/:board_id/:thread_id/:id
                             PUT    /forum/:board_id/:thread_id/:id
                             DELETE /forum/:board_id/:thread_id/:id
          forum_board_thread GET    /forum/:board_id/:id
                 forum_board GET    /forum/:id

% script/console
>> app.forum_board_thread_post_path(Board.first, Thread.first, Post.first)
=> "/forum/star-wars/droids/r2d2-rocks-c3po-sucks"

Copyright (c) 2008 Chris Eppstein, released under the MIT license
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server