Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2'

Discussion in 'Ruby' started by Jakub Flaška, Mar 2, 2011.

  1. Hello I have this small script:

    ----------------------
    require 'active_record'

    ActiveRecord::Base.establish_connection(
    :adapter => 'mysql',
    :database => 'cards',
    :username => 'user',
    :password => 'myPassword',
    :host => 'localhost',
    :charset => 'utf8',
    :encoding => 'utf8',
    :port => '3306')

    class Start < ActiveRecord::Base
    set_table_name "grb_tGStart"
    set_primary_key "start_id"
    has_many :posts
    end

    starts = Start.find:)all, :conditions => [ "agency_id = (?) AND
    is_active = (?)", 17, 1 ])

    ----------------------

    And I got this error:
    ----------------------
    /activerecord-3.0.5/lib/active_record/connection_adapters/mysql_adapter.rb:22:in
    `rescue in mysql_connection': !!!
    Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2'
    (RuntimeError)

    ----------------------
    Every hint to this issue points on a file: database.yml and there to
    change adapter: mysql, to adapter: mysql2.
    But I don't know what's the file databases.yml :) I don't have it in my
    project. Can you please advice me, what's the file databases.yml?

    --
    Posted via http://www.ruby-forum.com/.
    Jakub Flaška, Mar 2, 2011
    #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.
Similar Threads
  1. Gary Herron
    Replies:
    2
    Views:
    662
    Bruno Desthuilliers
    Jul 4, 2006
  2. Austin 7873
    Replies:
    5
    Views:
    182
    Eric Hodel
    Jan 27, 2007
  3. Pablo Q.
    Replies:
    4
    Views:
    133
    Prashant Srinivasan
    Oct 9, 2008
  4. vivec manavortex
    Replies:
    3
    Views:
    139
    vivec manavortex
    Jan 26, 2011
  5. Rajesh B.
    Replies:
    2
    Views:
    316
    Phillip Gawlowski
    Mar 25, 2011
Loading...

Share This Page