ruby on railsは、うまく動作させるまでが結構大変
mysql2はバージョン0.3.21を使うべし 0.4.5は動かない。
rspecのバージョンは3.4を使うべし、これで動いた。
centos7への
mysql5.6のインストール・設定を書いておく
sudo yum -y localinstall http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm sudo yum remove mariadb-libs sudo rm -rf /var/lib/mysql/ yum repolist all | grep mysql sudo yum -y install yum-utils sudo yum-config-manager --disable mysql57-community sudo yum-config-manager --enable mysql56-community sudo yum -y install mysql-community-server sudo systemctl start mysqld sudo systemctl enable mysqld /usr/bin/mysqladmin -u root password 'root' sudo yum install mysql-devel
ローカル開発環境なのでmysqlのパスワードはrootにしているが、実際は難しいのにしましょう。環境変数で設定する。
Gemfile
source 'https://rubygems.org' ruby '2.1.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.0' # Use mysql as the database for Active Record gem 'mysql2', '~> 0.3.21' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~> 4.0.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring', group: :development # Use ActiveModel has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use unicorn as the app server # gem 'unicorn' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development # Use debugger # gem 'debugger', group: [:development, :test] gem 'therubyracer', platforms: :ruby gem 'bcrypt', '~> 3.1.7' gem 'nokogiri', '~> 1.6.1' gem 'rails-i18n', '~> 4.0.1' group :test do gem 'rspec-rails', '~> 3.4' gem 'spring-commands-rspec', '~> 1.0.1' gem 'capybara', '~> 2.2.1' gem 'factory_girl_rails', '~> 4.4.1' gem 'database_cleaner', '~> 1.2.0' end