Rails Restful Routing and Subdomains

后端 未结 5 668
悲&欢浪女
悲&欢浪女 2020-12-28 17:57

I wondered if there were any plugins or methods which allow me to convert resource routes which allow me to place the controller name as a subdomain.

Examples:

5条回答
  •  -上瘾入骨i
    2020-12-28 18:51

    This is possible without using plugins.

    Given the directory structure app/controllers/portal/customers_controller.rb And I want to be able to call URL helpers prefixed with portal, i.e new_portal_customer_url. And the URL will only be accessible via http://portal.domain.com/customers. Then... use this:

    constraints :subdomain => 'portal' do
      scope :module => 'portal', :as => 'portal', :subdomain => 'portal' do
        resources :customers
      end
    end
    

提交回复
热议问题