Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

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

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 MIT-LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
Octocat-spinner-32 init.rb
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
Something went wrong with that request. Please try again.