Changeset 4259
- Timestamp:
- 04/24/06 21:30:18 (4 years ago)
- Files:
-
- plugins/simply_restful/lib/simply_restful/routes.rb (modified) (5 diffs)
- plugins/simply_restful/README (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/simply_restful/lib/simply_restful/routes.rb
r4258 r4259 4 4 plural = entity.to_s.pluralize 5 5 6 collection = options.delete(:collection) || {} 7 member = options.delete(:member) || {} 8 new = options.delete(:new) || true 9 prefix = options.delete(:prefix) 6 collection = options.delete(:collection) || {} 7 member = options.delete(:member) || {} 8 new = options.delete(:new) || true 9 path_prefix = options.delete(:path_prefix) 10 name_prefix = options.delete(:name_prefix) 10 11 11 12 member[:edit] = :get … … 23 24 (member_methods[:delete] ||= []).unshift :delete 24 25 25 path = "#{p refix}/#{plural}"26 path = "#{path_prefix}/#{plural}" 26 27 27 28 collection_path = path … … 34 35 route_options = requirements_for(method) 35 36 list.each do |action| 36 map.named_route("#{ action}_#{plural}", "#{collection_path};#{action}", route_options.merge(:action => action.to_s))37 map.named_route("#{name_prefix}#{action}_#{plural}", "#{collection_path};#{action}", route_options.merge(:action => action.to_s)) 37 38 end 38 39 map.connect(collection_path, route_options.merge(:action => primary)) unless primary.blank? 39 40 end 40 41 41 map.named_route( plural, collection_path, :action => "index", :require => { :method => :get })42 map.named_route("#{name_prefix}#{plural}", collection_path, :action => "index", :require => { :method => :get }) 42 43 43 44 new_methods.each do |method, list| … … 47 48 name = "new_#{entity}" 48 49 name = "#{action}_#{name}" unless action == :new 49 map.named_route( name, path, route_options.merge(:action => action.to_s))50 map.named_route("#{name_prefix}#{name}", path, route_options.merge(:action => action.to_s)) 50 51 end 51 52 end … … 55 56 primary = list.shift.to_s if method != :get 56 57 list.each do |action| 57 map.named_route("#{ action}_#{entity}", "#{member_path};#{action}", route_options.merge(:action => action.to_s))58 map.named_route("#{name_prefix}#{action}_#{entity}", "#{member_path};#{action}", route_options.merge(:action => action.to_s)) 58 59 end 59 60 map.connect(member_path, route_options.merge(:action => primary)) unless primary.blank? 60 61 end 61 62 62 map.named_route( entity.to_s, member_path, :action => "show", :require => { :method => :get })63 map.named_route("#{name_prefix}#{entity}", member_path, :action => "show", :require => { :method => :get }) 63 64 end 64 65 end plugins/simply_restful/README
r4258 r4259 78 78 routes: 79 79 80 map.resource :message, :p refix => "/thread/:thread_id"80 map.resource :message, :path_prefix => "/thread/:thread_id" 81 81 # --> GET /thread/7/messages/1 82 82 … … 97 97 # also adds a url named "preview_new_message" 98 98 # --> /messages/new can be invoked via any request method 99 100 map.resource :message, :controller => "categories", 101 :path_prefix => "/category/:category_id", 102 :name_prefix => "category_" 103 # --> GET /categories/7/messages/1 104 # has named route "category_message"