Controlling routes loading order from Engines

前端 未结 3 412
轻奢々
轻奢々 2020-12-28 08:32

So in Rails3 Engines come with their own models/controllers/views and of course routes. Now the question is: How do you ensure that Engine routes will be loaded before (or a

3条回答
  •  温柔的废话
    2020-12-28 08:57

    I'm not an expert, but I was playing with sferik/rails_admin yesterday when I came across their routing solution. With their rails_admin:install rake task, they directly modify your config/routes.rb file by adding mount RailsAdmin::Engine => '/admin', :as => 'rails_admin' at the beginning of the file so they are sure their routes always have the highest priority. That mount method refers to their own routes.rb :

    RailsAdmin::Engine.routes.draw do
      # Prefix route urls with "admin" and route names with "rails_admin_"
      scope "history", :as => "history" do
        controller "history" do
          [...]
        end
      end
    end
    

    Could this be your solution?

提交回复
热议问题