# Ruby on Rails - "uninitialized constant Mysql" error

## cleber

Hi everyone!

I'm trying to use Ruby on Rails (RoR), but I'm having some issues.

I get the RoR welcome screen working, but when I created a controller and try to access it, I get the following error:

```

 NameError in Clothe#index

uninitialized constant Mysql

Show framework trace

/usr/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/dependencies.rb:186:in `const_missing'

/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/mysql_adapter.rb:37:in `mysql_connection'

/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/query_cache.rb:52:in `connection='

/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:108:in `retrieve_connection'

/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:239:in `connection'

/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:461:in `count_by_sql'

/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/base.rb:454:in `count'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagination.rb:154:in `count_collection_for_pagination'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagination.rb:171:in `paginator_and_collection_for'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/pagination.rb:111:in `paginate'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/scaffolding.rb:101:in `list'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/scaffolding.rb:94:in `index'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in `perform_action_without_filters'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/filters.rb:295:in `perform_action_without_benchmark'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `perform_action_without_rescue'

/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `perform_action_without_rescue'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/rescue.rb:80:in `perform_action'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in `process'

/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispatcher.rb:32:in `dispatch'

/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:144:in `process_request'

/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:64:in `process!'

/usr/lib/ruby/site_ruby/1.8/fcgi.rb:600:in `each_cgi'

/usr/lib/ruby/site_ruby/1.8/fcgi.rb:597:in `each_cgi'

/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:55:in `process!'

/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:21:in `process!'

/var/www/rails/rails_link/wardrobe/public/dispatch.fcgi:24

This error occured while loading the following files:

   mysql.rb

Request

Parameters: None

Show session dump

flash: !map:ActionController::Flash::FlashHash {}

Response

Headers: {"cookie"=>[], "Cache-Control"=>"no-cache"}

```

(My table and controller is called "clothe")

Also if I create a dummy method with some render_text "Hello World", it also works...

I was trying just with a plain instalation of RoR (from portage), but I read some pages talking about fast CGI problem, so I installed fastCGI and the results are the same, having the problem happening both on FastCGI and on plain CGI.

Did some one ever had this problem before?

Using last stable ruby and rails (0.13) installation from portage.

Thanks in advance!

----------

## cleber

Well, after playing arround, I found what was the problem.

Actually, I had to re-emerge ruby mysql module, and then the ruby server (not Apache2) started to work.

Then I had to remove "-D RUBY" from apache options from /etc/conf.d/apache2 document.

Then it started to work for apache too.

Hope that this helps some one!

Bye

----------

## aarnott

Sweet.  Thank you for sharing your fix.  It took me just a bit to learn the package name you had to re-emerge, and since it worked for me as well, I include it here:

sudo emerge -a mysql-ruby

----------

