Think In Geek

In geek we trust

Subversioning a Rails App

The time when application versions where stored in different folders or in zip files has ended. Today we have great tools like Subversion or CVS. This tools must be known by everybody, but for those who aren’t known, they are applications that control versions of files.

While developing a Ruby on Rails application it’s good to use a system like Subversion. In this howto I’ll explain my experience subversioning my Rails app.

The first step is to create a subversion repository. Mine is created with a web interface in my hosting account, if you can control your subversion repositories and you don’t know how to create it the chapter Creating and Configuring your Repository from SVN book may be useful. My repository url is (for example) http://someaccount.somehosting/myapp.

For subversioning a rails app we need, of course, a rails app. We’ll create a dummy app for testing. After that we have to import this directory structure to our repository

jsegura@ibook:~/dev/rails $ rails demo
      create  app/controllers
      create  app/helpers
      create  app/models
      create  app/views/layouts
      create  config/environments
jsegura@ibook:~/dev/rails$ svn import demo http://someaccount.somehosting/demo -m "Rails import"

The next actions have to be done in a working copy, the directory demo is no longer necessary.

jsegura@ibook:~/dev/rails $ rm -rf demo
jsegura@ibook:~/dev/rails $

After obtaining the working copy we have to prepare our repository for developers usage. The steps are:

  1. Removing temp files
  2. Removing log files

To remove these files doesn’t mean “they are unnecessary”, only means “there is unnecessary for these files to stay in the repo” :-).

jsegura@ibook:~/dev/rails/demo$ svn remove log/<strong>
D         log/development.log
D         log/production.log
D         log/server.log
D         log/test.log
jsegura@ibook:~/dev/rails/demo$ svn propset svn:ignore "*.log" log/
property 'svn:ignore' set on 'log'
jsegura@ibook:~/dev/rails/demo svn
svn            svndumpfilter  svnserve       svnversion     
svnadmin       svnlook        svnsync       
jsegura@ibook:~/dev/rails/demo$ svn ci -m "Remove and ignore log files"
Sending        demo/log
Deleting       demo/log/development.log
Deleting       demo/log/production.log
Deleting       demo/log/server.log
Deleting       demo/log/test.log
Committed revision 3.
jsegura@ibook:~/dev/rails/demo$ svn remove tmp/</strong>
D         tmp/cache
D         tmp/pids
D         tmp/sessions
D         tmp/sockets
jsegura@ibook:~/dev/rails/demo svn propset svn:ignore "*" tmp/
property 'svn:ignore' set on 'tmp'
jsegura@ibook:~/dev/rails/demo$ svn ci -m "Remove and ignore temp files"
Sending        demo/tmp
Deleting       demo/tmp/cache
Deleting       demo/tmp/pids
Deleting       demo/tmp/sessions
Deleting       demo/tmp/sockets
Committed revision 4.

To end up, the only final step is not subversion the config for accessing the database.

jsegura@ibook:~/dev/rails/demo$ svn propset svn:ignore "database.yml" config/
property 'svn:ignore' set on 'config'
jsegura@ibook:~/dev/rails/cdemo$ svn ci -m "Ignoring database.yml"
Sending        demo/config
Committed revision 5.
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn


Leave a Reply

Your email address will not be published. Required fields are marked *