Michael Koper
Michael Koper

Reputation: 9781

Rails subdomains are not working

I have modified etc/hosts to map app.website.local to my localhost 127.0.0.1. This works and it gets redirected to my localhost.

The problem is that request.subdomain is empty, so i can't do anything with it.

class ApplicationController
  before_filter :ensure_domain

  private 

  def ensure_domain
    # do something with the request 
    # here is request.subdomain empty
  end
end

my etc/hosts:

127.0.0.1 localhost
255.255.255.255 broadcasthost
::1             localhost
fe80::1%lo0 localhost
127.0.0.1 app.website.local

Upvotes: 2

Views: 216

Answers (1)

Michael Koper
Michael Koper

Reputation: 9781

Ok I solved the problem myself. I took this project of somebody in the uk. There they use co.uk for domain names. He added the following config in development.rb

config.action_dispatch.tld_length = 3

Deleting this line solved it.

Upvotes: 2

Related Questions