【发布时间】:2014-05-12 15:06:08
【问题描述】:
也许有更好的方法来做到这一点。我希望能够动态加载一些路由。我计划在routes.rb 中使用静态路由,在custom_routes.rb 中使用自定义路由。然后在routes.rb的底部,我会这样做:
CustomRoutes.create if defined?(CustomRoutes)
为了使它工作,我必须要求 custom_routes.rb 仅当文件存在时,但如何?
custom_routes.rb
class CustomRoutes
def self.create
MyApplication.routes.draw do
#...more routes here
end
end
end
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3.2 ruby-1.8.7