2011-11-09 114 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