Cyr*_*rus 9 ruby ruby-on-rails ruby-on-rails-3 ruby-on-rails-4
我正在将rails 3应用程序升级到rails 4.0.1.
在我的rails 3应用程序中,我在my application.rb中使用以下代码来使用多个路由文件.
config.paths ["config/routes"] + = Dir [Rails.root.join('config','routes','*.rb').to_s]
但是当我尝试在rails 4中使用相同的东西时会引发异常.
有小费吗?
Mic*_*nch 26
在我的一个较大的应用程序中,我在config/routes.rb文件中使用以下代码段.
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes/#{routes_name}.rb")))
end
end
YourApplication::Application.routes.draw do
# Loads config/routes/common.rb
draw :common
# Loads config/routes/another.rb
draw :another
end
Run Code Online (Sandbox Code Playgroud)
Rails 4最初获得了支持,draw :routeName但它被删除了,因为它没有显示出任何改进. (我不知道^.^)你可以在这里查看git commit:https://github.com/rails/rails/commit/5e7d6bba79393de0279917f93b82f3b7b176f4b5
| 归档时间: |
|
| 查看次数: |
4569 次 |
| 最近记录: |