Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

We use the wonderful semantic versioning paradigm when versioning our rails app. One question I had was where is it best to store this number? I've seen it stored in /lib, environment.rb, etc.

Just wondering what people thought as to best practices?

like image 782
Greg Olsen Avatar asked Jan 31 '12 01:01

Greg Olsen


People also ask

How do I find my Rails version?

Use the command: rake about . This command will output the following info plus more (hence the ellipsis: About your application's environment Rails version 4.2. 0 Ruby version 2.2.

Where is Rails config?

You probably know that you can configure Rails in config/application. rb and config/environments/development. rb etc. But you can also leverage that for configuring your own custom settings for your application.

What is Rails application config?

In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The configuration file config/application. rb and environment-specific configuration files (such as config/environments/production.


1 Answers

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

like image 168
dooleyo Avatar answered Oct 13 '22 01:10

dooleyo