2011-11-09 113 views
0

我創建一個簡單的CMS和Rails 3.我routes.rb文件我有以下的條目來捕獲所有路線:Rails3中路由優先級

match '*url', :controller => 'site', :action => 'dynamic_page' 

我使用ckeditor寶石的編輯器支持。我rake routes如下:

     root  /(.:format)        {:action=>"index", :controller=>"site"} 
           /*url(.:format)       {:action=>"dynamic_page", :controller=>"site"} 
     ckeditor_pictures GET /ckeditor/pictures(.:format)    {:action=>"index", :controller=>"ckeditor/pictures"} 
     ckeditor_pictures POST /ckeditor/pictures(.:format)    {:action=>"create", :controller=>"ckeditor/pictures"} 
     ckeditor_picture DELETE /ckeditor/pictures/:id(.:format)   {:action=>"destroy", :controller=>"ckeditor/pictures"} 
ckeditor_attachment_files GET /ckeditor/attachment_files(.:format)  {:action=>"index", :controller=>"ckeditor/attachment_files"} 
ckeditor_attachment_files POST /ckeditor/attachment_files(.:format)  {:action=>"create", :controller=>"ckeditor/attachment_files"} 
ckeditor_attachment_file DELETE /ckeditor/attachment_files/:id(.:format) {:action=>"destroy", :controller=>"ckeditor/attachment_files"} 

我的問題是,你可以看到:

/*url(.:format)  {:action=>"dynamic_page", :controller=>"site"} 

..loads的CKEditor的路線之前,因此CKEditor的路線不工作。有人可以幫我加載ckeditor路線之前:

/*url(.:format)  {:action=>"dynamic_page", :controller=>"site"} 

在此先感謝。

回答

1

我想出了被添加的CKEditor路由到routes.rb文件中手動

這樣

namespace :ckeditor, :only => [:index, :create, :destroy] do 
    resources :pictures 
    resources :attachment_files 
end 

match '*url', :controller => 'site', :action => 'dynamic_page' 

現在,它的做工精細

1

路由文件按照從上到下的順序進行處理,所以只要改變路由的順序,讓你的catch-all在ckeditor的東西后面。

+0

嗨@Richard,感謝您的答案的解決方案,但問題是'ckeditor'路線來自'ckeditor'寶石的路線。但我所有的其他路由都在config/routes.rb中, – sameera207