404 errors with Phusion Passenger when deployed in subdirectory
When deploying a Devise app w/ Rails 3 under Phusion Passenger in a subdirectory (e.g. RailsBaseURI /myapp), all Devise routes give 404 errors. Installing as a dedicated virtual server instead of a subdirectory works fine.
Example production_log for a fail case:
Started GET "/myapp/users/sign_in" for 192.168.1.10 at Fri Jun 18 09:36:48 -0400 2010
Processing by Devise::SessionsController#new as HTML
Completed in 0ms
AbstractController::ActionNotFound (AbstractController::ActionNotFound):
/usr/local/lib/ruby/gems/1.8/gems/devise-1.1.rc1/lib/devise/controllers/internal_helpers.rb:57:in `is_devise_resource?'
See more discussion of the problem (two people reporting problem so far) here: http://groups.google.com/group/plataformatec-devise/browse_thread/thread/9693003716700c11
Have you tried other rails engines to check if they work? Maybe passenger is setting relative_url_root too late and consequently it's not propagating to Devise controllers.
I'm experiencing this problem suddenly too. Upgraded to 1.1rc2 and suddenly all my devise paths are broken in Passenger. Webrick works fine though.
I've switched my site to using a dedicated virtual site instead of a sub-path. Works around the problem (and is what I'd intended to do long-term anyway) but doesn't resolve the problem. Not sure if it's something to do with Passenger's Rack initialization timing, or something else...
Also seeing this problem, not working on a local machine
Could someone please investigate it deeper?
Hi, having the same problem here ruby 1.9.2p3 / rails3b4 / devise 1.1rc2 / WEBrick 1.3.1 / project with namespaces I'd love to help but don't know where to start (a bit new to rails) tell me if you want some more precisions
"yo dawg, i heard you like path_prefix so i put a path_prefix in your path_prefix so you could map while you route..." joke aside, i was digging around and i think i'am on something here (for my env check my post just above this one)
so here's the thing:
the url i'm accessing : /fr/client/users/sign_up
my devise route: scope ':locale', :constraints => { :locale => /(fr)|(en)/ } do namespace :client do devise_for :users end
end
the error says "some exception in is_devise_resource?" so i've started from there: obviously devise_mapping has to return something, but it does not (and allowed controller include? fails too but i'll talk about it a bit later)
devise_mapping lead me to mapping.find_by_path where i've "puts'ed" this
def self.find_by_path(path)
puts "some path to search in mappings : #{path}"
puts "split path : #{path.split("/").inspect}"
Devise.mappings.each_value do |mapping|
puts "a mapping #{mapping.inspect}"
puts "a mapping seg pos #{mapping.segment_position.inspect}"
puts "a mapping path #{mapping.path.inspect}"
route = path.split("/")[mapping.segment_position]
puts "a route #{route.to_sym.inspect}"
return mapping if route && mapping.path == route.to_sym
end
nil
end
the result is:
some path to search in mappings : /fr/client/users/sign_up split path : ["", "fr", "client", "users", "sign_up"] a mapping #<Devise::Mapping:0x3a9a5f8 bla bla bla bla> a mapping seg pos 1 a mapping path :users
a route :fr
segment_position is bad, it should be "3" ("users") so it could match a route and return the mapping since segment_position relies on path_prefix which is not set in my case by 'scope' and 'namespace'
i've tried to put : devise_for :users, :path => 'users', :class_name => 'User', :path_prefix => ':locale/client', :controllers => { :sessions => 'client/devise/sessions', :registrations => 'client/devise/registrations' }
it's better, but routes are still messed up (undefined method `new_user_registration_path' in app/views/client/devise/shared/_links.erb)
as for the allowed_controllers problem, well its kinda the same : i want "client/devise/session" and its compared to "devise/session"
but only when i put devise_for in scope/namespace
so what's the problem here ? am i doing something wrong with my routes ? caus' the scope/namespace seems to be the right rails3-way-to-go (that's why i put devise_for there in first place)
thanks
oups, a bit messed up...just dont pay attention to bold font style / text separators sorry
@zomfg Unfortunately Devise does not support to be nested in scope ":locale". I think your issue is another issue (that I can try to tackle) and is not related with passenger.
Devise should respect script_name and path_info contracts. This closed by 421256d294c8a31122f38cae2ab11b5ccad74f2d, a long standing bug with Passenger.