我特林設置一個路由,像這樣:結合期權路線2.3
GET /設置/ PUT /設置/ GET /設置/照片 PUT /設置/照片
這是路由代碼,我已經安裝了它:
#I just do this for code reuse
get = { :method => :get }
put = { :method => :put }
pub.settings '/settings', :controller => :settings, :action => :index, :conditions => get
pub.with_options :controller => :settings, :path_prefix => "/settings", :name_prefix => "settings_" do |settings|
settings.update '', :action => :update, :conditions => put
settings.photos '/photos', :action => :photos, :conditions => get
settings.photos_update '/photos', :action => :photos_update, :conditions => :put
end
這工作,但如果你注意到第一條路線「pub.settings」是mapped_options塊之外。
如果我是待辦事項
pub.with_options :controller => :settings, :path_prefix => "/settings", :name_prefix => "settings_" do |settings|
settings.root '', :action => :index, :conditions => get
settings.update '', :action => :update, :conditions => put
settings.photos '/photos', :action => :photos, :conditions => get
settings.photos_update '/photos', :action => :photos_update, :conditions => :put
end
然後我會得到(在耙路線)的路徑設置將是「settings_root_path」,而不是「settings_path」
有誰知道如何把它列入到該塊仍然具有路由功能名稱「settings_path」?
這樣的定義給出了一個錯誤 settings.root:動作=>:指數:name_prefix =>零,:條件=> GET給出root_path而不是settings_path – Bohdan 2010-08-19 00:13:02