Listing 'rake routes' for a mountable Rails 3.1 engine

前端 未结 6 1813
悲&欢浪女
悲&欢浪女 2020-12-14 17:38

I\'m working on a mountable engine for use with Rails 3.1, and I want to list the engine\'s routes.

I created the engine using:

$ rails plugin new ra         


        
6条回答
  •  天涯浪人
    2020-12-14 18:19

    If you copy code from the standard Rails 3.1.0 rake routes task into your Rakefile, and change the top part to read:

    task :routes => 'app:environment' do
      Rails.application.reload_routes!
      all_routes = RailsBlogEngine::Engine.routes.routes
    

    ...replacing RailsBlogEngine with the name of your engine, then you can get a rudimentary list of routes by running:

    rake routes
    

    Note that in Rails 3.1.1 and later, you'll need a newer version of the rake routes task.

提交回复
热议问题