The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Ruby on Rails mongrel issues

Discussion in 'General Discussion' started by jeffleeismyhero, Apr 27, 2008.

  1. jeffleeismyhero

    Joined:
    Jan 18, 2006
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    I've installed Rails using the howtos on the forum and everything seems to work (i.e., I can build a rails app and run it).

    The problem I am having is that when I try to use mongrel (as opposed to script/server -e production) I am given the following error message:

    The page you were looking for doesn't exist.

    You may have mistyped the address or the page may have moved.

    URL: http://domain.com/ampersand/

    I have used the cPanel rewrite form to create my rewrite from domain.com:12001 to domain.com/ampersand

    If I create a controller and view named greeting the error (404) is the same when I try http://domain.com/ampersand/greeting/

    My production.log file contains the following:

    Code:
    Processing ApplicationController#index (for 192.168.1.1 at 2008-04-26 23:59:00) [GET]
      Session ID: BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%0ASGFzaHsABjoKQHVzZWR7AA%3D%3D--ea3a6fe119e702ccc57b0f31e5a94cc27abc9d4b
      Parameters: {}
    
    
    ActionController::RoutingError (No route matches "/ampersand/" with {:method=>:get}):
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1441:in `recognize_path'
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1424:in `recognize'
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:76:in `process'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:74:in `synchronize'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:74:in `process'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:159:in `process_client'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:158:in `each'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:158:in `process_client'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `initialize'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `new'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:268:in `initialize'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:268:in `new'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:268:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:282:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:281:in `each'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:281:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:128:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/command.rb:212:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:281
        /usr/bin/mongrel_rails:16:in `load'
        /usr/bin/mongrel_rails:16
    
    Rendering /home/domain/public_html/ampersand/public/404.html (404 Not Found)
    
    
    Processing ApplicationController#index (for 192.168.1.1 at 2008-04-26 23:59:07) [GET]
      Session ID: BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%0ASGFzaHsABjoKQHVzZWR7AA%3D%3D--ea3a6fe119e702ccc57b0f31e5a94cc27abc9d4b
      Parameters: {}
    
    
    ActionController::RoutingError (No route matches "/ampersand/greeting" with {:method=>:get}):
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1441:in `recognize_path'
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/routing.rb:1424:in `recognize'
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:170:in `handle_request'
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:115:in `dispatch'
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:126:in `dispatch_cgi'
        /usr/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/dispatcher.rb:9:in `dispatch'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:76:in `process'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:74:in `synchronize'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/rails.rb:74:in `process'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:159:in `process_client'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:158:in `each'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:158:in `process_client'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `initialize'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `new'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:268:in `initialize'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:268:in `new'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:268:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:282:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:281:in `each'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:281:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:128:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/command.rb:212:in `run'
        /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:281
        /usr/bin/mongrel_rails:16:in `load'
        /usr/bin/mongrel_rails:16
    
    Rendering /home/domain/public_html/ampersand/public/404.html (404 Not Found)
    
    My Routes file is the default:

    Code:
    ActionController::Routing::Routes.draw do |map|
      # The priority is based upon order of creation: first created -> highest priority.
    
      # Sample of regular route:
      #   map.connect 'products/:id', :controller => 'catalog', :action => 'view'
      # Keep in mind you can assign values other than :controller and :action
    
      # Sample of named route:
      #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
      # This route can be invoked with purchase_url(:id => product.id)
    
      # Sample resource route (maps HTTP verbs to controller actions automatically):
      #   map.resources :products
    
      # Sample resource route with options:
      #   map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
    
      # Sample resource route with sub-resources:
      #   map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
    
      # Sample resource route within a namespace:
      #   map.namespace :admin do |admin|
      #     # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
      #     admin.resources :products
      #   end
    
      # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
      # map.root :controller => "welcome"
    
      # See how all your routes lay out with "rake routes"
    
      # Install the default routes as the lowest priority.
      map.connect ':controller/:action/:id'
      map.connect ':controller/:action/:id.:format'
    end
    
    The mongrel.log file contains:

    Code:
    ** Starting Mongrel listening at 0.0.0.0:12001
    ** Starting Rails with production environment...
    ** Rails loaded.
    ** Loading any Rails specific GemPlugins
    ** Signals ready.  TERM => stop.  USR2 => restart.  INT => stop (no restart).
    ** Rails signals registered.  HUP => reload (without restart).  It might not work well.
    ** Mongrel 1.1.4 available at 0.0.0.0:12001
    ** Writing PID file to log/mongrel.pid
    I'm not sure what I am doing wrong but if I use script/server everything works fine. I assume my problem has something to do with routes but since I am just learning RoR I am unable to make sense of it...
     
  2. jeffleeismyhero

    Joined:
    Jan 18, 2006
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    1
    Well, it appears that the routes need to be setup as follows:

    Code:
      # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
      # This make http://domain.com/ampersand work
      map.connect 'ampersand/:controller/:action/:id', :controller => 'greeting'
    
      # See how all your routes lay out with "rake routes"
    
      # Install the default routes as the lowest priority.
      map.connect '/ampersand/:controller/:action/:id'
      map.connect '/ampersand/:controller/:action/:id.:format'
    
    All is working here, but I assume my routes above are primitive and could benefit from review by a seasoned Railer.
     
  3. succhi

    succhi Registered

    Joined:
    Sep 22, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    I know this post is old but someone might find it anyway.

    You would probably find that putting the following at the bottom of your environment.rb will work for you so you don't need to muck with your routes.

    Code:
    ActionController::AbstractRequest.relative_url_root = "/ampersand"
     
Loading...

Share This Page