RailsCasts Pro episodes are now free!

Learn more or hide this

jalagrange's Profile

GitHub User: jalagrange

Comments by

Avatar

ok, I managed to fix it. I had to tell rails to load my lib directory in my config/application.rb file by adding these lines:

ruby
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += Dir["#{config.root}/lib/**/"]

and using:

ruby
constraints(Subdomain) do
  match '/' => 'schools#show'
end

in my routes.rb

Hope this helps

Avatar

Hello, I am trying to implement the subdomains on my app. I am using rails 3.1.rc5. The problem is that "constraints" in my route.rb does not work and i am redirected to my app root. However if I use "constraint" (singular), my subdomain is parsed and i am succesfully routed to the show action of the controller i wanted (SchoolsController). The problem with this is that when i do not use a subdomain and therefore wish to be redirected to the root of my app, i get an "ActiveRecord::RecordNotFound" because it cannot find a School with that subdomain.

Anybody else having a similar issue? any ideas?