Class: ActionController::Routing::RouteSet::Mapper
- Inherits:
-
Object
- Object
- ActionController::Routing::RouteSet::Mapper
- Defined in:
- lib/extensions/action_controller/routing/route_set.rb
Instance Method Summary collapse
-
#connect_rtml(options = {}) ⇒ Object
Modifies your route set to produce TML-compatible routes.
Instance Method Details
#connect_rtml(options = {}) ⇒ Object
Modifies your route set to produce TML-compatible routes. Also connects the default TML request (/index.tml) to the options you provide, if any.
Unlike the rest of Rails routing, if you call #connect_rtml multiple times with different options, the /index.tml path will be updated to reflect the new options.
To use, just add the following to your /config/routes.rb file: map.connect_rtml :controller => “start_page”
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/extensions/action_controller/routing/route_set.rb', line 14 def connect_rtml( = {}) make_rtml_connection('/:controller/:action.:format', '/rtml/index.rtml') make_rtml_connection('/:controller/:action.:id.:format', '/rtml/index.1.rtml') make_rtml_connection('/:controller/:action/:id', '/rtml/index/1') = !.empty? ActionController::Routing::Routes.routes.each do |route| segs = route.segments.to_s[0...-1] if segs =~ /^\/index.tml(\/|)$/ && route.requirements.merge! .reverse_merge(:format => 'rtml') = false end end if connect '/index.tml', .reverse_merge(:format => 'rtml') unless .empty? end end |