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?
A: Yes, you should commit it. The presence of a `Gemfile. lock` in a gem's repository ensures that a fresh checkout of the repository uses the exact same set of dependencies every time.
The Gemfile is where you specify which gems you want to use, and lets you specify which versions. The Gemfile. lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.
Your gemfile is a list of all gems that you want to include in the project. It is used with bundler (also a gem) to install, update, remove and otherwise manage your used gems. These gems belong to development environment and the test environment since they are for testing the application.
Gemfiles. Gemfiles require at least one gem source, in the form of the URL for a RubyGems server. Generate a Gemfile with the default rubygems.org source by running bundle init . If you can, use https so your connection to the rubygems.org server will be verified with SSL.
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With