如果Devise Exist对路线施加约束

时间:2016-03-07 16:19:33

标签: ruby-on-rails ruby devise routes

我有一个我在许多应用程序中使用的通用引擎,有些需要类似于设计并需要子域约束。

在主应用程序routes.rb中我试过但没有用。

constraints(Devise::Constraints::SubdomainRequired) do  
    mount Example::Engine, :at => '/'
end

引擎routes.rb

    Phcmembers::Engine.routes.draw do

        if defined?(Devise) 
            constraints(Devise::Constraints::SubdomainRequired) do

                # Application Client Backend
                namespace :members do

                    # Members Main Index
                    root 'mains#index'

                    # Member Routes
                    resources :mains do 
                        resources :listings
                        resources :contacts
                    end

                end

                namespace :directory do

                    # Directory Main Index
                    root 'categories#index'

                    # Directory Routes
                    resources :categories do
                        resources :catlists
                    end
                end
            end

        else

                # Application Client Backend
                namespace :members do

                    # Members Main Index
                    root 'mains#index'

                    # Member Routes
                    resources :mains do 
                        resources :listings
                        resources :contacts
                    end

                end

                namespace :directory do

                    # Directory Main Index
                    root 'categories#index'

                    # Directory Routes
                    resources :categories do
                        resources :catlists
                    end
                end



        end

    end

我真的不知道如何去做,希望有人可以给我一些指示并澄清一些事情。提前谢谢。

1 个答案:

答案 0 :(得分:1)

if defined?(Devise)

您正在寻找什么