rails 4:将 routes.rb 拆分为多个较小的文件 [英] rails 4: split routes.rb into multiple smaller files

查看:33
本文介绍了rails 4:将 routes.rb 拆分为多个较小的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 rails 4 应用程序中拆分我的路线.对于 rails 3,这个问题已经回答了几次,比如:

I would like to split my routes in rails 4 application. For rails 3 the question has been answered a few times like:

在 rails 4 中执行此操作的正确方法是什么 + 如何控制路由加载的顺序?

来自 rails 的 3 个问题的建议:

Suggested from the rails 3 questions:

application.rb

    config.paths['config/routes'] = Dir["config/routes/*.rb"]

失败:

/Users/jordan/.rvm/gems/ruby-2.0.0-head@books/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in`在execute_if_updated 中救援':Rails::Application::RoutesReloader#execute_if_updated 委托给updater.execute_if_updated,但更新程序为零:

/Users/jordan/.rvm/gems/ruby-2.0.0-head@books/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:10:in `rescue in execute_if_updated': Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil:

@route_sets=[#]>(运行时错误)

@route_sets=[#]> (RuntimeError)

推荐答案

这已于 2012 年 6 月从 Rails 4 中删除.5e7d6bba 还原较早的提交,删除对加载多个外部路由文件作为 config.rb 的一部分的支持.

This was removed from Rails 4 in June of 2012. 5e7d6bba reverts an earlier commit, removing support for loading multiple external route files as part of config.rb.

如需进一步阅读,请查看关于此提交的评论.

For further read, check out the comments on this commit.

这篇关于rails 4:将 routes.rb 拆分为多个较小的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆