First lets you set up your subdomain class. the following code should be sufficient
class Subdomain def self.matches?(request) request.subdomain.present? && request.subdomain != 'www' end end
then you should be able to call it on routes with the following
constraints(Subdomain) do resource :conference, path: "/" do member do get 'apply' post 'apply' => "conferences#save_apply" end end
Then in your controller you do the following:
Conference.find_by_slugged!(request.subdomain)
(I saw that you are using a friendly identifier, so I think your subdomain is sluggged conference.
source share