我正在使用Rails 3创建一个简单的CMS。在我的routes.rb
文件中,我有以下条目来捕获所有路径:
match '*url', :controller => 'site', :action => 'dynamic_page'
我正在使用ckeditor
gem来获得编辑器支持。我的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"}
..在ckeditor路由之前加载,因此ckeditor路由不起作用。有人可以帮助我在加载ckeditor路线之前:
/*url(.:format) {:action=>"dynamic_page", :controller=>"site"}
提前致谢。
答案 0 :(得分:1)
路由文件按从上到下的顺序处理,所以只需改变路由的顺序,这样你的全部内容就在ckeditor之后。
答案 1 :(得分:1)
我提出的解决方案是手动将ckeditor路由添加到routes.rb
文件
namespace :ckeditor, :only => [:index, :create, :destroy] do
resources :pictures
resources :attachment_files
end
match '*url', :controller => 'site', :action => 'dynamic_page'
现在工作正常