From 7ff7f2fe6e0f0d2a5ba8f062302c865e7dfd2145 Mon Sep 17 00:00:00 2001 From: Derek Date: Fri, 8 Jun 2018 14:50:24 -0700 Subject: [PATCH] Check the rails version and install the appropriate mysql2 gem. --- recipes/gems.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/recipes/gems.rb b/recipes/gems.rb index 295eb11d..8be57e4a 100644 --- a/recipes/gems.rb +++ b/recipes/gems.rb @@ -46,7 +46,17 @@ end end gsub_file 'Gemfile', /gem 'mysql2'.*/, '' -add_gem 'mysql2', '~> 0.3.18' if prefer :database, 'mysql' +if prefer :database, 'mysql' + if Rails::VERSION::MAJOR < 5 + add_gem 'mysql2', '~> 0.3.18' if prefer :database, 'mysql' + else + if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR <= 1 + add_gem 'mysql2', '~> 0.3.18' if prefer :database, 'mysql' + else + add_gem 'mysql2', '< 0.6.0', '>= 0.4.4' + end + end +end ## Gem to set up controllers, views, and routing in the 'apps4' recipe add_gem 'rails_apps_pages', :group => :development if prefs[:apps4]