Where do you store your Rails Application’s version number?

My strategy is to let your VCS tags do it for you (git shown here).

Add this to your application.rb:

# Only attempt update on local machine
if Rails.env.development?
  # Update version file from latest git tag
  File.open('config/version', 'w') do |file|
    file.write `git describe --tags --always` # or equivalent
  end
end

config.version = File.read('config/version')

You can then access the version anywhere in your app with Rails.configuration.version

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)