public
Description: Support :acts_as in rails/merb routing.
Homepage:
Clone URL: git://github.com/hungrymachine/acts_as_routing.git
acts_as_routing / README
100644 58 lines (42 sloc) 1.558 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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