how adding a "version" when generating a new rails project

every lib/gem will have a version, but seems everyone forgot the project itself.
I preferred a config.version option in the applicaiton.rb after running rails new <project>

module Todo
  class Application < Rails::Application
    ...
    config.version = '1.0.0'
  end
end

then in rails console, we can get the project’s version using:
Todo.version
=> “1.0.0”

there are “versions” for db migrations, but why not the project? I think this can be a standard for a rails project

any thought for this idea?

Hi Rain,

I don’t think that web applications are like software libraries in this respect. Engineering teams that are pushing software out the door are already tracking their versions with commits to their source control. SemVer is great because it helps convey things like breaking changes, but web apps don’t really have the same kind of backwards-compatibility problems that libraries might (APIs served by the app might, but that’s a different issue). If your team is always shipping, and therefore making lots of small deploys to production, separately tracking a version number is a step that will result in merge conflicts and possibly misleading data in the event that multiple pushes are made on a single “version” of the app.

  • Geoff

Indeed I don’t think there’s need to track “versions” on a web application, since it’s way more common for people to use tags or similar with git or some other scm, when they do.

In any case, it’s fairly easy to add that to your application if you want or need it:

module Todo

class Application < Rails::Application

config.version = ‘1.0’

end

def self.version

Application.config.version

end

end

That should do the trick.

We do this - we run two week iterations, and group fixes and features under a version number that tracks the iteration. Every commit is linked to an issue, and every issue is linked to a release version. The last thing we do in an iteration is a commit to bump the version number to match the iteration, tag and push to prod.

I work for an insurance company, and we have a very strict change management process, in part because we are huge (IT budget in the $4-500M), and in part because we have very serious regulatory requirements. It would be nice to push to prod every day, but compared to some we don’t have it too bad.

L

This email crafted from materials gathered from across the cosmos.