Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to version a rails app? [closed]

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)

like image 959
AdamB Avatar asked Jun 26 '09 08:06

AdamB


People also ask

How do I use a different version of Rails?

There's nothing you need to do to manage two different Rails versions. The only thing you'll want to do is gem install rails to get the latest version and create your new project with rails new myapp . That will make sure the new project starts with Rails 5.1 (or whatever is the latest at the time).

How do you find out what version of Rails is installed?

(To see which version of Rails is installed, enter rails -v at the command line.) You may also need to install the sqlite3 gem, which isn't automatically installed by the Rails gem but is needed for development. That's gem install sqlite3 .


2 Answers

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.

Source: http://blog.danielpietzsch.com/post/1209091430/show-the-version-number-of-your-rails-app-using-git

like image 181
Max Masnick Avatar answered Sep 19 '22 22:09

Max Masnick


You can use subversion keywords:

Essentially, you could have a helper method...

def app_version
    "$Id$"
end

$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 $"
end

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.

like image 38
ideasasylum Avatar answered Sep 19 '22 22:09

ideasasylum