我是新来的rails,我有这个大问题。我正在运行 rails 3.2.9 和 Ruby 1.9.3,我将一个 rails 应用程序从 linux 移植到 windows,但是在 windows 中我遇到了 mysql2 gem 的很多问题。我昨天安装了 mysql2 gem,然后我尝试运行 rake db:migrate 但我有这个输出:
耙中止!
请安装 mysql2 适配器:(gem install activerecord-mysql2-adapter
无法加载此类文件 -- mysql2)
C:/Users/RoccaA/Desktop/project/config/environment.rb:5:in `'
Tasks: TOP => db:migrate => environment
(见通过使用 --trace 运行任务进行完整跟踪)
然后这是我的 Gemfile
gem 'rails', '3.2.9'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
# gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
# gem 'uglifier', '>= 1.0.3'
end
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
# this gems needs for auth
gem 'cancan'
gem 'devise'
gem 'rolify'
gem 'execjs'
gem 'therubyracer', :platform => :ruby
gem 'populator'
gem 'faker'
gem 'paperclip'
gem 'simple_xlsx_writer'
gem 'roo'
gem 'mysql2', '0.3.11'
gem 'simple_xlsx_writer'
gem 'rake', '~> 10.0.4'
gem 'icalendar'
这是我的 database.yml
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: emc
pool: 5
username: root
password: root
socket: /var/run/mysqld/mysqld.sock
testing:
adapter: mysql2
encoding: utf8
reconnect: false
database: emc
pool: 5
username: root
password: root
socket: /var/run/mysqld/mysqld.sock
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: emc
pool: 5
username: root
password: root
socket: /var/run/mysqld/mysqld.sock
我试图以很多方式解决这个问题,我读到我必须使用 mysql2 版本 < 0.3 但是使用这个版本我有这个输出
警告:这个版本的 mysql2 (0.2.18) 与 Rails 3.1 不兼容,因为 ActiveRecord 适配器被拉入 Rails 本身。
警告:如果您打算在 Rails >= 3.1.x 中使用
rake aborted,请使用 0.3.x(或更高)版本!
nil:NilClass 任务的未定义方法“接受”
:TOP => db:migrate
(通过使用--trace 运行任务查看完整跟踪)**
希望有人可以帮助我,谢谢。