You just check this
I installed the rails app to use custom subdomains after this amazing RailsCast tutorial by Ryan Bates. Users can visit company.lvh.mehaps000 and view all relevant information. Now I would like to add the admin subdomain on the front of the user subdomain (admin.company.lvh.mehaps000).
, /. , , //admin/blogs_controller.rb /views/admin/blogs/show.html.erb.
admin Rails, , , :
namespace :admin, path: '/', constraints: { subdomain: 'admin.DYNAMIC' } do
match '/', to: 'blogs#show', via: 'get'
end
, admin.company , , ? ( "admin." + Subdomain ..) , : ?
namespace :admin, path: '/', constraints: { subdomain: Subdomain } do
match '/', to: 'blogs#show', via: 'get'
end
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain != "www"
end
end
Relevant Routes
Prefix Verb URI Pattern Controller
admin GET / admin/blogs