Search code examples
ruby-on-rails-3versioninggemfile

Should I pin gem "rails" to a version?


Most rails projects have a very specific version included in their gemfile, right after a rails new foo.

For example gem 'rails', '3.1.3'

Would it not be better to change this to allow dot-version and e.g. define rails as gem 'rails', '~>3.2'?

How is rails version-numbering done? I see major changes between dot-releases, e.g. upgrading from 3.0 to 3.1 requires quite severe changes (mostly to the asset pipeline). How is that for subreleases? Is 3.2.1 a bugfixonly release of 3.2.0?


Solution

  • There's not really any reason not to use the ~> constraint, but you should put:

    gem 'rails', '~>3.1.3'
    

    since that will mean any 3.1.x that is at least 3.1.3. Putting ~>3.1 implies compatibility with any Rails version 3.x.

    Rails versioning follows semantic versioning, as far as I know.

    However, I think the idea of specifying the exact version is that you read the release notes with every release and make a specific effort to validate that it's okay. Ultimately it's all up to you, though. You should be sure you're somehow following a feed for Rails versions so you always know about security releases either way.