1

I am getting "undefined method `accept' for nil:NilClass" error while running db:migrate. My configuration is:

Rails 3.2.8
MySql 5.1.54
OS : win7
ruby : 1.9.2

my gems list command output:

F:\RailsApp\MyApp>gem list

*** LOCAL GEMS ***

actionmailer (3.2.8)
actionpack (3.2.8)
activemodel (3.2.8, 3.1.0)
activerecord (3.2.8)
activeresource (3.2.8)
activesupport (3.2.8, 3.1.0)
arel (3.0.2)
bcrypt-ruby (3.0.1 x86-mingw32)
builder (3.0.0)
bundler (1.1.5)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.3.3)
erubis (2.7.0)
execjs (1.4.0)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
json (1.7.4)
mail (2.4.4)
mime-types (1.19)
minitest (1.6.0)
multi_json (1.3.6)
mysql (2.8.1 x86-mingw32)
mysql2 (0.3.11 x86-mingw32, 0.2.6 x86-mingw32)
polyglot (0.3.3)
rack (1.4.1, 1.3.6)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.8)
railties (3.2.8)
rake (0.9.2.2, 0.8.7)
rdoc (3.12, 2.5.8)
sass (3.2.0)
sass-rails (3.2.5)
sprockets (2.1.3)
thor (0.15.4)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
uglifier (1.2.7)

I have also copy the %MYSQLPATH%/bin/libmySQL.dll file to %RUBYHOME%/bin folder.

Can anybody pleas help me to solve this problem?

Kulbir Saini
  • 3,926
  • 1
  • 26
  • 34
Anand Soni
  • 5,070
  • 11
  • 50
  • 101

3 Answers3

1

This may be a AR-JDBC issue. Try running

bundle update activerecord-jdbc-adapter

This may help you..

If it didn't work for you, try with

bundle update mysql2

For more info look into the GitHub Issue

PradeepKumar
  • 1,259
  • 9
  • 5
1

Finally I have resolve the problem with reference to this post mysql2 gem compiled for wrong mysql client library.

What I have done is as follows:

  1. download and extract the package from http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick

  2. remove all mysql/mysql2 gem and re-install mysql gem with this command: gem install mysql --platform=ruby -- --with-mysql-dir=E:/mysql-connector-c-noinstall-6.0.2-win32

  3. add gem 'mysql' in GemFile

  4. modify database.yml with adapter:mysql

  5. copy MYSQLHOME/bin/libmsql.dll to RUBYHOME/bin

  6. if find dsl error then add require 'rake/dsl_definition' at top of RakeFile

and it works.. :-)

My final GemFile is:

source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'mysql'
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
Community
  • 1
  • 1
Anand Soni
  • 5,070
  • 11
  • 50
  • 101
1

I had the same issue fixed by correcting database.yml file. It was having adopter as mysql2 now I have correct it to mysql

Mayank Jain
  • 405
  • 9
  • 19