0

Hey guys noob question here. I'm having a problem launching rails s. I think its a mysql problem but when I checked the gemfile file for gem 'mysql' its there.

I'm pasting the console log below:

$ rails s
=> Booting WEBrick
=> Rails 3.2.2 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
/Users/username/Sites/projectname/config/initializers/omniauth.rb:2: warning: already initialized constant VERIFY_PEER
[2012-05-19 18:33:15] INFO  WEBrick 1.3.1
[2012-05-19 18:33:15] INFO  ruby 1.9.3 (2012-04-20) [x86_64-darwin11.3.0]
[2012-05-19 18:33:15] INFO  WEBrick::HTTPServer#start: pid=74815 port=3000


Started GET "/" for 127.0.0.1 at 2012-05-19 18:33:30 -0400

NoMethodError (undefined method `init' for Mysql:Class):
activerecord (3.2.2) lib/active_record/connection_adapters/mysql_adapter.rb:32:in `mysql_connection'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:277:in `new_connection'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:287:in `checkout_new_connection'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:235:in `block (2 levels) in checkout'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `loop'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:230:in `block in checkout'
/Users/gorteks/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `checkout'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:374:in `retrieve_connection'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection'
activerecord (3.2.2) lib/active_record/query_cache.rb:67:in `rescue in call'
activerecord (3.2.2) lib/active_record/query_cache.rb:61:in `call'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `_run__2560155742155290980__call__1944809023615832682__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/static.rb:61:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/application.rb:220:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.2) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/Users/gorteks/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/gorteks/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/gorteks/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'


Rendered /Users/gorteks/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.6ms)
Rendered /Users/gorteks/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.7ms)
Rendered /Users/gorteks/.rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.2/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (8.7ms)

When visiting localhost I see this:

NoMethodError

undefined method `init' for Mysql:Class

Rails.root: /Users/username/Sites/projectname
Application Trace | Framework Trace | Full Trace

Request

Parameters:

None

Show session dump

Show env dump
Response

Headers:

None

Thank your for any help! I'm stuck!

1 Answer 1

2

You should be using the mysql2 gem for the version of Rails that you're on instead of the mysql gem. Just making that switch should resolve your issue.

Sign up to request clarification or add additional context in comments.

2 Comments

after runing bundle install and adding gem 'mysql2' to the Gemfile, console spits out: /Users/gorteks/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2.rb:9:in require': dlopen(/Users/username/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib (LoadError)
See this for assistance on that issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.