Reputation: 21564
Our team uses different databases for each other, and we are using bundler so our Gemfile contains the repo creator's db connector(mysql)
I am using pg and due to a bit laziness and fear of breaking something, I don't want to use mysql, so I just add a gem "pg" in our Gemfile.
Of course, since we're using git, it will always show as a modified file, and we all use the Gemfile so we can't gitignore it or commit it with our changes.
Question is, how do we go about this? Is there a conditional in bundler or do I just have to declare that I'm using a certain gem someplace else?
Upvotes: 10
Views: 6337
Reputation: 211560
Since Gemfile
, like Rakefile
, is just a chunk of Ruby, you can throw in conditionals if you think it will simplify your life. For instance:
if (Gem.available?('pg'))
gem 'pg'
else
gem 'mysql2'
end
Sometimes you have to do this for different Ruby versions as 1.8 and 1.9 sometimes need different gems.
Upvotes: 18
Reputation: 3500
You can use a group. Yehuda Katz explain it how here (taking in example the pg gem) http://yehudakatz.com/2010/05/09/the-how-and-why-of-bundler-groups/
Upvotes: 1