Versions
gem installed with "gem install mysql2 -v '< 0.3' ". All dependencies were met.
rails & 'rails c' are working fine.
I need to run a script outside of rails environment using activerecord 3.0.9. When I run the script this is the output:
======================
/home/ross/work/x/library/models.rb:27:in `eval': !!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2' (RuntimeError)
from /home/ross/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/mysql_adapter.rb:19:in `mysql_connection'
from /home/ross/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:229:in `new_connection' ....
=======================
Clearly the gem is there, because rails works.
Don't know why the gem isn't found when running a script?
Can anyone pls shed some light on the issue?
Regards Ross
In case it helps anyone, in my case I had forgotten to change the adapter in database.yml
to mysql2
for the production database, the Gemfile
was OK (upgrading from rails
2.3.4 to 3.0.9).
Check your database.yml
first
You have something like this:
development:
adapter: mysql
encoding: utf8
...
To solve your problem you need replace mysql
to mysql2
.
Correct version of database.yml
development:
adapter: mysql2
encoding: utf8
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With