Rails route to model instance - by domain name Rails route to model instance - by domain name nginx nginx

Rails route to model instance - by domain name


Assuming each area has some sort of domain_name field, it seems like you should be able to do something like this:

class HotelsController < ApplicationController  def index    @hotels = Area.find_by_domain_name(request.subdomains.first).hotels  endend

You could even refactor it into a named_scope using a lambda if you like.