Rails routing not working properly


#1

hello,

I installed a rails app I’m building following the wiki entry on it, and it went pretty smoothly, in its first version.

Now I uploaded a second version, which works alright locally, but can’t get routing to work the same as before, though it works locally. I think I double-checked all gotchas mentioned about rails deployment on DH - such as permissions, checking that dispatch.fcgi runs on the command-line, checking .htaccess, killing all dispatch processes before reloading, checking logs, running webbrick… and no luck yet.

I believe it might have something to do with the routing scheme I’m using, gotten from the Comatose CMS, which I’m adapting for my own needs:

in /config/routes.rb I have:

map.content_root ‘’

and then there are two route_mappers, required from environment.rb, which are loaded depending on the version of rails

[code]# Adds the content_root mapping support to the Rails Routset
class ActionController::Routing::RouteSet
def content_root( path, options={} )
opts = {
:index => ‘’,
:layout => ‘content’,
:use_cache => ‘true’,
:cache_path => nil,
:force_utf8 => Comatose::Options.force_utf8.to_s,
:named_route=> nil
}.merge(options)

Ensure the controller is aware of the mount point…

ContentController.add_root(path, opts[:index])

Add the route…

opts[:controller] = 'content’
opts[:action] ='show’
route_name = opts.delete(:named_route)
unless route_name.nil?
named_route( route_name, “#{path}/*page”, opts )
else
if opts[:index] == ‘’ # if it maps to the root site URI, name it content_root
named_route( ‘content_root’, “#{path}/*page”, opts )
else
connect( “#{path}/*page”, opts )
end
end
end

def method_missing( name, *args )
if name.to_s.starts_with?( ‘’ )
opts = (args.last.is_a?(Hash)) ? args.pop : {}
opts[:named_route] = name.to_s #[9…-1]
content_root( *(args << opts) )
else
(1…2).include?(args.length) ? named_route(name, *args) : super(name, *args)
end
end

end

[/code]and

[code]# For use with 'Edge Rails’
class ActionController::Routing::RouteSet::Mapper
def content_root( path, options={} )
opts = {
:index => ‘’,
:layout => ‘content’,
:use_cache => ‘true’,
:cache_path => nil,
:force_utf8 => Comatose::Options.force_utf8.to_s,
:named_route=> nil
}.merge(options)

Ensure the controller is aware of the mount point…

ContentController.add_root(path, opts[:index])

Add the route…

opts[:controller] = 'content’
opts[:action] ='show’
route_name = opts.delete(:named_route)
unless route_name.nil?
named_route( route_name, “#{path}/*page”, opts )
else
if opts[:index] == ‘’ # if it maps to the root site URI, name it content_root
named_route( ‘content_root’, “#{path}/*page”, opts )
else
connect( “#{path}/*page”, opts )
end
end
end

def method_missing( name, *args, &proc )
if name.to_s.starts_with?( ‘’ )
opts = (args.last.is_a?(Hash)) ? args.pop : {}
opts[:named_route] = name.to_s #[9…-1]
content_root( *(args << opts) )
else
super unless args.length >= 1 && proc.nil?
@set.add_named_route(name, *args)
end
end
end
[/code]before I was running Comatose as a plugin, and now I’ve broken it down into a regular rails application. the strange thing is, when using as a plugin, the routing worked fine on DH. now I’m testing the app version, it only works on my computer (Rails 1.1.2 running on Locomotive 2)

any pointers or ideas would be greatly appreciated, I’m stuck :slight_smile:

thanks
Oliver


#2

anyone?


#3

as a sidenote, I’m not managing to kill the dispatch processes with either of these:

kill -9 ruby
kill -9 dispatch.fcgi
killall -USR1 ruby
killall -USR1 dispatch.fcgi

which makes it harder to debug :stuck_out_tongue:


#4

I’ve that i have to use

killall -9 ruby1.8to stop some of the processes. Try

ps axto see whether your dispatch.fcgi processes are running under ruby or ruby1.8.

(I have no idea why they run under what look like different copies of Ruby. They seem to start with ruby and move to /usr/bin/ruby1.8 after a few hours.


#5

thanks mjpowers, going to give it try… strange indeed!