In my gemfile I have:
gem \'mysql2\'
My database.yml is as follows:
default: &default
adapter: mysql2
database: <
Had same issue but adding source 'https://rubygems.org'
to the top of gem file solved issue.
Steps:
add source 'https://rubygems.org'
to your gem file.
Comment out mysql2 gem
and add gem 'mysql2', '~> 0.3.18'
Run bundle install
Just a further update - the solution in the question is correct.
The 4th comment is worth taking note of:
This isn't a bug with mysql2, it's a problem with the requirement in the ActiveRecord adapter: http://github.com/rails/rails/issues/21544. This is fixed in rails master: https://github.com/rails/rails/commit/5da5e3772c32593ecf2f27b8865e81dcbe3af692
I was able to tie Rails 4.2.4
to the 4-2-stable
branch and get it working with the latest mysql2
:
gem 'rails', '~> 4.2.4', git: "git://github.com/rails/rails.git", branch: '4-2-stable'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] #-> Rails 4.1+
#DB
gem 'mysql2'
As a complete beginner i got confused on how to do this so I just did a trial check and finally got my server working , here is how i got it working .
get into the file of working directory("work") and from there get into the file of the app you created("sample_app")which has mysql 2 installed go to gem file ("Gemfile")edit gem 'mysql2' to gem 'mysql2', '~> 0.3.18'
now go back to cmd and run command "bundle install".
so the directory to edit file taking consideration of above files in brackets should be . "c\work\sample_app\Gemfile"
hope i was of some help .