Problem with namespace routes not working with Passenger

46 views
Skip to first unread message

John

unread,
Jan 19, 2009, 9:43:25 PM1/19/09
to Phusion Passenger Discussions
I've been trying to deploy my application to a production server
running apache/passenger 2.0.6 on redhat server 5

In my routes file, i use namespace routes like this:

map.namespace :admin do |admin|
# Directs /admin/states/* to Admin::StatesController (app/
controllers/admin/states_controller.rb)
admin.resources :states, :collection=>{:list=>:get}
admin.resources :roles, :collection=>{:list=>:get}
end

if I check rake routes .. i see
list_admin_roles GET /admin/roles/
list {:controller=>"admin/
roles", :action=>"list"}


this works fine in development environment (mongrel on a mac) when i
use
<%= link_to_remote 'Roles', :url =>{:action=>:list, :controller=>'/
admin/roles'}%>

.. produces this : in development.log (as expected)
Processing Admin::RolesController#list (for 127.0.0.1 at 2009-01-19
11:21:43) [POST]

but in production, I get this in the log
Processing AdminController#states (for 67.187.255.21 at 2009-01-19
13:20:19) [POST]
...
ActionController::UnknownAction (No action responded to roles):


WHY????? it is the same code - is this working for anyone?

I had rails 2.2.2 installed and rolled back to 2.1.0 to see if it
would fix it - it does not

I saw on the web some reference to using ProxyPass, etc - but when I
try putting that in my httpd-vhosts.conf file, and restarting apache,
it complains:
Invalid command 'ProxyPass', perhaps misspelled or defined by a module
not included in the server configuration

ugggg... anyone?

Thanks in advance

Cody Caughlan

unread,
Jan 19, 2009, 10:04:09 PM1/19/09
to phusion-...@googlegroups.com
It looks like you are using namespaced controllers, and it appears
that you have an app/controllers/admin directory with your admin
controllers, so you should fully specify the the controller in
routes.rb

map.resources :admin, :controller => 'admin/admin' do |admin|
admin.resources :states, :collection => {:list => :get}
....
end

And then you should be using just named paths in your views:

link_to("Remote", list_admin_roles_path() )

I dont know why it works in Mongrel and not in Passenger

/Cody

John

unread,
Jan 19, 2009, 10:22:15 PM1/19/09
to Phusion Passenger Discussions
you are correct...

I have app/controllers/admin folder with controllers in that admin
folder


trying your suggestion ... I changed
map.namespace :admin do |admin|
to
map.resources :admin, :controller => 'admin/admin' do |admin|
(even though using .namespace is the way it is identified in the
routes.rb file and in other documentation)

I still get

Processing AdminController#roles (for 67.187.255.21 at 2009-01-19
21:17:23) [POST]


instead of
Processing Admin::RolesController#list (for 127.0.0.1 at 2009-01-19
11:21:43) [POST]

as I get with mongrel on my mac...

any more things to try?



On Jan 19, 7:04 pm, "Cody Caughlan" <tool...@gmail.com> wrote:
> It looks like you are using namespaced controllers, and it appears
> that you have an app/controllers/admin directory with your admin
> controllers, so you should fully specify the the controller in
> routes.rb
>
> map.resources :admin, :controller => 'admin/admin' do |admin|
> admin.resources :states, :collection => {:list => :get}
> ....
> end
>
> And then you should be using just named paths in your views:
>
> link_to("Remote", list_admin_roles_path() )
>
> I dont know why it works in Mongrel and not in Passenger
>
> /Cody
>

Cody Caughlan

unread,
Jan 19, 2009, 10:38:12 PM1/19/09
to phusion-...@googlegroups.com
So I am incorrect. You dont want to use map.resources :admin in your
case because your admin is not an object you want to expose as a
resource. So your original

map.namespace :admin

is correct.

However I just used your exact code with .namespace and am able to execute

= link_to("Admin", list_admin_roles_path())

just fine and this with Passenger 2.0.6

So in a nutshell, ignore everything I said and go back to your
original code but when you use link_to() try the named route helper

list_admin_roles_path()

instead of directly referencing a hash in your link_to

/Cody

John

unread,
Jan 19, 2009, 10:46:16 PM1/19/09
to Phusion Passenger Discussions
this is a remote link..

link_to_remote vs link_to ...

...but I went ahead and created another link using
<%= link_to_remote 'Roles', :url =>list_admin_roles_path() %>

i tested it on my mongrel dev setup, works fine, the same...
Processing Admin::RolesController#list (for 127.0.0.1 at 2009-01-19
19:41:08) [POST]


but on the passenger/production setup... I still get
Processing AdminController#roles (for 67.187.255.21 at 2009-01-19
21:43:14) [POST]

next?



On Jan 19, 7:38 pm, "Cody Caughlan" <tool...@gmail.com> wrote:
> So I am incorrect. You dont want to use map.resources :admin in your
> case because your admin is not an object you want to expose as a
> resource. So your original
>
> map.namespace :admin
>
> is correct.
>
> However I just used your exact code with .namespace and am able to execute
>
> = link_to("Admin", list_admin_roles_path())
>
> just fine and this with Passenger 2.0.6
>
> So in a nutshell, ignore everything I said and go back to your
> original code but when you use link_to() try the named route helper
>
> list_admin_roles_path()
>
> instead of directly referencing a hash in your link_to
>
> /Cody
>

John

unread,
Jan 19, 2009, 11:10:56 PM1/19/09
to Phusion Passenger Discussions
ah ha... this post
http://groups.google.com/group/phusion-passenger/browse_thread/thread/aa161789874482ba/c9aad1532f5de15d?lnk=gst&q=namespace#c9aad1532f5de15d

mentions using a work-around to the normal way would constuct this
route...

instead of the map.namespace block...

I created (not in a block, just normal route specification)
map.adminroles 'admin/role/:action/:id' , :controller=> '/admin/
roles'

and now it works on passenger/production

also, because this is not the normal way, I guess, the url link path
helper will not work...
so i need to use
link_to_remote 'Roles', :url =>{:action=>:list, :controller=>'admin/
roles'

and everything seems to be working as expected...

its too bad that passenger is failing to correctly allow the namespace
block to work...i'd like to not have to fake it.

thanks and I hope this helps someone else...
Reply all
Reply to author
Forward
0 new messages