Routing and module constraints #4635

Closed
tanelsuurhans opened this Issue Jan 24, 2012 · 7 comments

Comments

Projects
None yet
4 participants

Given a route like this:

namespace :foo, :constraints => DomainChecker::Foo do
  ...
end

Previously what one could do is stuff the module under /lib and load it in an initializer.
Right now it would seem that the initializers are not being ran before the route drawing, thus ending up in an undefined
module error.

I could not find anything about the change of behavior in the changelog, is this change made on purpose? Or a side-effect?

Owner

pixeltrix commented Jan 24, 2012

Between which versions has this changed?

The project was converted from 3.1.3 to 3.2
The issue seems to be that the routes are loaded before initializers are.
Adding my /lib to autoload paths seemed to fix it.

Owner

tenderlove commented Jan 24, 2012

This is likely due to changes in the autoloader code. Maybe @josevalim knows. Anyway, why not just require the file you need? require should work fine inside routes.rb.

Owner

rafaelfranca commented Jan 25, 2012

@tanelsuurhans If you are using active_reload please remove it form your project. See plataformatec/devise#1597 (comment)

@rafaelfranca Indeed I am (and I did have a gutfeeling it might be the thing affecting me). Thank you for the hint.

Just to be clear - this is also causing routes being loaded before any initializers are ran? Or is this a separate, intentional change in 3.2?

Owner

rafaelfranca commented Jan 25, 2012

@tanelsuurhans @josevalim can explain better but yes, if active_reload is present in your project the routes will be loaded before any initializers and this is not intentional, is a side effect

Owner

rafaelfranca commented Jan 28, 2012

I think that this issue can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment