Order Route Typus

It used to be that you could load Typus routes exactly where you needed them by placing

  Typus::Routes.draw(map)

at the appropriate point in your route.rb file. It seems like this is no longer supported and that they always load after all the application routes. This causes problems with the main routes that should be determined last. Does anyone know how to now control the boot order for typus? Is there a way to define them before any of the application routes, and not after? Thank!

+3
source share
2 answers

I went around it, leaving all my routes at the end of my apps.rb routes, but excluding it from matching for Typus URLs:

# A catch all route
match '*path' => 'content#show', :constraints => lambda{|request|
  !request.path.starts_with?("/admin") # excluded if typus will be taking it...
}

It may or may now work for you ...

+3
source

.

typus config/routes.rb routes.rb catchall.

, , .

:

  # TODO: KLUDGE: MANUALLY BRING THE TYPUS ROUTES IN
  #       Typus used to provide :
  #           Typus::Routes.draw(map)
  #       But that is no longer the case.
  scope "admin", :module => :admin, :as => "admin" do

    match "/" => "dashboard#show", :as => "dashboard"
    match "user_guide" => "base#user_guide"

    if Typus.authentication == :session
      resource :session, :only => [:new, :create, :destroy], :controller => :session
      resources :account, :only => [:new, :create, :show, :forgot_password] do
        collection do
          get :forgot_password
          post :send_password
        end
      end
    end

    Typus.models.map { |i| i.to_resource }.each do |resource|
      match "#{resource}(/:action(/:id(.:format)))", :controller => resource
    end

    Typus.resources.map { |i| i.underscore }.each do |resource|
      match "#{resource}(/:action(/:id(.:format)))", :controller => resource
    end
  end
  # END KLUDGE

  # Catch all to the state page handler
  match '/:page' => 'pages#show', :as => 'page'
0

Source: https://habr.com/ru/post/1792124/


All Articles