Skip to content

hungrymachine/acts_as_routing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ActsAsRouting
=============

This plugin allows you to define a generic block of routing logic in a plugin and then apply it to multiple resources in your routes file.


Rails Example
============

	# in acts_as_commentable plugin
	ActionController::Routing.routes_for_acts_as(:commentable) do |map|
		map.resources :comments
		map.best_comment '/best-comment', :controller => 'comments', :action => 'best'
	end

	# in acts_as_reviewable plugin
	ActionController::Routing.routes_for_acts_as(:reviewable) do |map|
		map.resources :reviews
	end

	# in config/router.rb
	ActionController::Routing::Routes.draw do |map| 
	  map.resources :people, :acts_as => [:commentable, :reviewable]
	end

	# in some view
	<%=person_comments_path(Person.first)%>
	<%=person_reviews_path(Person.first)%>
	<%=person_best_comment_path(Person.first)%>


Merb Example
============

	# in acts_as_commentable plugin
	Merb::Router.routes_for_acts_as(:commentable) do |map|
		map.resources :comments
		map.match('/best-comment').to(:controller => 'comments', :action => 'best').name(:best_comment)
	end

	# in acts_as_reviewable plugin
	Merb::Router.routes_for_acts_as(:reviewable) do |map|
		map.resources :reviews
	end

	# in config/router.rb
	Merb::Router.prepare do
	  resources :people, :acts_as => [:commentable, :reviewable]
	end

	# in some view
	<%=url(:person_comments, :person => Person.first)%>
	<%=url(:person_reviews, :person => Person.first)%>
	<%=url(:person_best_comment, :person => Person.first)%>


Copyright (c) 2008 HungryMachine, released under the MIT license

About

Support :acts_as in rails/merb routing.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages