Not sure if this is a bug, but it seems odd.

In config/environments/development.rb I have:

Rails.application.configure do
    config.relative_url_root = '/myurl'
    ...
end

Sometime after config/application.rb runs, but BEFORE 
config/environments/development.rb Rails runs RouteSet::Initialize (lines 
374-390 in action_dispatch/routing/route_set.rb) .
The RouteSet::initialize method sets up an instance variable @config and at 
this point relative_url_root is nil because it is defined in 
config/environments/developer.rb which has NOT been called yet.
This means that any gem or rails code that calls the method 
RouteSet::relative_url_root (lines 398-400) will get nil for 
relative_url_root even though it is defined in 
config/environments/developer.rb

I noticed this when using the gem devise_cas_authenticatable which has to 
build up a service url to return to my app after going out to the CAS 
server for authentication. The code in devise_cas_authenticatable 
ultimately ends up calling RouteSet::relative_url_root and gets nil which 
means the service url it builds is incorrect.

Everything else works as expected in that all my generated routes have 
myurl/ prepended to them EXCEPT for the service_url created by 
devise_cas_authenticatable (DCA) but DCA calls out to rails 
ActionDispatch::Routing::RoutesProxy which calls 
ActionDispatch::RouteSet::NamedRouteCollection::URlHelper, which ultimately 
calls ActionDispatch::RouteSet::url_for....yada 
yada...ActionDispatch::RouteSet::relative_url_root which returns nil


Easy workaround is to define relative_url_root in config/application.rb but 
I don't see this mentioned anywhere in the guides and this seems like 
subtle bug.


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/0fcb741c-2911-4f2f-82d2-0fa41ed00d06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to