Best way to version a rails app?

What would be the best way to version a rails application? We want to start to get into more structured testing cycles and having a set version per build is a part of that. We use subversion but I would like to avoid using revision numbers for versions. Is there an easy way to do this automatically? Or should I just define a app_version method in the application helper?

(We are using subversion for source control)

  • Possibilities of implementing a git server
  • Global Xcode run scripts
  • Versioning on development and release branches (git-flow)
  • Real diff between two GIT histories (or SHA hashes/commits)
  • Automatic versioning of sources for local backup
  • What is best practice for keeping secrets out of a git repository?
  • How do I count the number of git commits affecting a given subtree?
  • Why do I get “fatal: git status --porcelain failed”?
  • 5 Solutions collect form web for “Best way to version a rails app?”

    You can use subversion keywords:

    Essentially, you could have a helper method…

    def app_version

    $Id$ is a keyword which svn will expand (the link above has others you could use). Now, we set the keywords property on that file to let svn know that it should be replacing keywords (let’s assume application_helper.rb):

    svn propset svn:keywords "Id" application_helper.rb
    svn ci application_helper.rb

    Now if you look at application_helper.rb it’ll read (something like this, with the version, date, user name changed)

    def app_version
        "$Id: application_helper.rb 282 2009-06-26 10:34:17Z root $"

    Obviously, you could assign this to a variable and parse it to the required format, included it in your view templates etc. Or do the same thing but instead of application_helper.rb, just use a file called VERSION in your root dir.

    If you use git, you can create a static variable in your environment.rb file that pulls the current tag name from git. If you’re using something like git flow, this works great.

    Add to environment.rb:

    APP_VERSION = `git describe --always` unless defined? APP_VERSION

    Now you can <%= APP_VERSION %> in your views. N.B. that this doesn’t work on Heroku.


    The app-version plugin ( allows you to specify various components of an application version. You could then include the subversion revision as a component of the build without it being the dominant part.

    You could also, as part of your build/test workflow, increment another component of the version.

    You could either version by labelling your git / svn branch … or, best way, a constant in the environment file, just like Rails does:

    MY_APP_VER = 0.1

    Why would you use the application helper? You can always get at that variable from your application helper should you need to display it onscreen. But, that seems silly to have logic belonging to the configuration of your entire application inside a helper method.

    Ithink this should be the responsibility of your source control system. I’d use a tag for each version, then you can create a helper method that just writes the tag out in your app (say, in the footer):

    def put_version
      "<p id='version'>#{$$TAG_NAME}</p>"

    Can’t remember the syntax for inserting the tag name.

    Git Baby is a git and github fan, let's start git clone.