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

查看:93
本文介绍了Rails 4:将route.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:

  • How to split routes.rb into smaller files
  • Splitting Routes File Into Multiple Files

在rails 4中如何做到这一点的正确方法,以及如何控制路线加载的顺序?

What would be the correct way to do this in rails 4 + how to get control over the order the routes get loaded?

提出了3个问题:

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
`recue in execute_if_updated':
Rails: : Application :: RoutesReloader#execute_if_updated委托给
updater.execute_if_updated,但更新程序为nil:

/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 = [#] >
(RuntimeError)

@route_sets=[#]> (RuntimeError)


推荐答案

已于6月从Rails 4中删除。 2012。 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:将route.rb拆分为多个较小的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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