rails on apache 2.0

Discussion in 'Ruby' started by non, Jul 17, 2005.

  1. non

    non Guest

    Working on the O'Reilly tutorial. Got everything working fine with WebBrick
    and am not trying to get it to work with Apache.

    I looks like I am close, ruby seems to be running, but I get the following
    error when I open the /recipe/list page (or any other page accessing Mysql).

    NameError in Recipe#list
    uninitialized constant Mysql
    /app/controllers/recipe_controller.rb:12:in `list'
    Show framework trace
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/dependencies.rb:186:in
    `const_missing'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb:37:in
    `mysql_connection'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/query_cache.rb:52:in
    `send'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/query_cache.rb:52:in
    `connection='
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:108:in
    `retrieve_connection'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:239:in
    `connection'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:751:in
    `add_limit!'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:746:in
    `construct_finder_sql'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:343:in
    `find'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/deprecated_finders.rb:37:in
    `find_all'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in
    `send'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in
    `perform_action_without_filters'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/filters.rb:295:in
    `perform_action_without_benchmark'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in
    `perform_action_without_rescue'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in
    `measure'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in
    `perform_action_without_rescue'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/rescue.rb:80:in
    `perform_action'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in
    `send'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in
    `process'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispatcher.rb:32:in
    `dispatch'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:144:in
    `process_request'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:64:in
    `process!'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:55:in
    `each_cgi'
    C:/opensource/ruby/lib/ruby/site_ruby/1.8/fcgi.rb:595:in `each'
    C:/opensource/ruby/lib/ruby/site_ruby/1.8/fcgi.rb:595:in `each_cgi'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:55:in
    `process!'
    C:/opensource/ruby/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:21:in
    `process!'
    D:/Projects/rails/cookbook/public/dispatch.fcgi:24
    This error occured while loading the following files:
    mysql.rb

    Here is what I added to http.conf:

    LoadModule fastcgi_module modules/mod_fastcgi.so

    <IfModule mod_fastcgi.c>
    AddHandler fastcgi-script .fcgi
    </IfModule>

    <VirtualHost *:80>
    ServerName rails.todo.com
    DocumentRoot d:/projects/rails/ToDo/public
    <Directory d:/projects/rails/ToDo/public/>
    Options ExecCGI FollowSymLinks
    AllowOverride all
    Allow from all
    Order allow,deny
    </Directory>
    </VirtualHost>

    Here is what is in the .htaccess file:

    # General Apache options
    AddHandler fastcgi-script .fcgi
    AddHandler cgi-script .cgi
    Options +FollowSymLinks +ExecCGI

    # If you don't want Rails to look in certain directories,
    # use the following rewrite rules so that Apache won't rewrite certain
    requests
    #
    # Example:
    # RewriteCond %{REQUEST_URI} ^/notrails.*
    # RewriteRule .* - [L]

    # Redirect all requests not available on the filesystem to Rails
    # By default the cgi dispatcher is used which is very slow
    #
    # For better performance replace the dispatcher with the fastcgi one
    #
    # Example:
    # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
    RewriteEngine On
    RewriteRule ^$ index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

    # In case Rails experiences terminal errors
    # Instead of displaying this message you can supply a file here which will
    be rendered instead
    #
    # Example:
    # ErrorDocument 500 /500.html

    ErrorDocument 500 "<h2>Application error</h2>Rails application failed to
    start properly"

    Any help would be appreciated.
     
    non, Jul 17, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page