Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undefined method `accept' for nil:NilClass on rake db:migrate

Using ruby-1.9.2 and rails 3.2.1. The version of mysql2 is 0.2.7.

Upon running rake db:migrate I get the error: "undefined method `accept' for nil:NilClass:"

Trace includes:

gems/activerecord-3.2.1/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `to_sql'

like image 313
vectran Avatar asked Feb 11 '12 23:02

vectran


5 Answers

Change your Gemfile from:

gem 'activerecord-mysql2-adapter'

to:

gem 'mysql2'
like image 88
Shaheen Ghiassy Avatar answered Nov 20 '22 06:11

Shaheen Ghiassy


Ok, I fixed on my machine. This is because of older MySQL2. Do this to resolve the problem.

bundle update mysql2

        Or

bundle update

For more details visit Github

like image 26
chhantyal Avatar answered Nov 20 '22 07:11

chhantyal


For me by removing gem 'activerecord-mysql2-adapter' from Gem File worked out

like image 25
Anikethana Avatar answered Nov 20 '22 07:11

Anikethana


Install the lastest mysql2 ruby gem. my environtment:

Rails3.2.9 + mysql2 0.2.9,  : "undefined method `accept' for nil:NilClass:"
Rails3.2.9 + mysql2 0.3.11, works fine
like image 1
Siwei Avatar answered Nov 20 '22 05:11

Siwei


It can happen because of incompatibility of your mysql and ruby version.

To resolve this either update your mysql gem by gem install mysql which will install latest mysql gem.

And then add this in your Gemfile.

If still the problem exists then you should see the compatibility between your ruby and mysql

like image 1
Akshay Mohite Avatar answered Nov 20 '22 06:11

Akshay Mohite