In Rails Gemfile, what are the differences between these :
gem "gemname", "~> 4.0.1"
and
gem "gemname", "4.0.1"
and
gem "gemname"
Also what should be used where and benefit of following that way?
The first will tell bundler to load any gem that varies with the last (patch) number. So 4.0.x where x is 1 or greater.
The second will only load 4.0.1.
The third will get the highest value that works (depending on what the needs of the rest of your gems in your Gemfile) or will get whatever is specified in your Gemfile.lock, if you have one.
I missed your second question. Frankly, it depends. For the most part, I go with the first option, because it lets me pick up bug fixes without worrying about how it impacts my other gems.