Posted by: Bob Ngu on: March 1, 2007
My RoR efforts have culminated in JiggyMe, check it out!
First thing I tried with my own Web 2.0 app is to create a new model. In doing so, I decided that it is a good idea to add created_at, updated_at, and lock_version to every table. This is so I can leverage one of Rails Active Record cool feature. In Rails, some database attribute columns are magic columns because they get filled automatically by Rails, e.g., id, created_at, created_on, updated_at, updated_on, lock_version, etc. To avoid adding those 3 columns manually to each table, I decided to use RedHill Consulting’s Row Version Migrations plugin to handle this automatically for all table creation.
A general note about Rails plugins, unlike gems, plugins are installed directly into a specific Rails app. This makes it easier to deploy them remotely along with an entire application. Because Row Version Migrations plugin install require SVN, I also had to install SVN (apart from TortoiseSVN) in order to be able to install the plugin.
Before running any of the plugin commands below, remember to first change directory to your application root directory. If you get an HTTP error while running the command “ruby script/plugin discover”, the real culprit is likely that the plugin site is down. However, it came out as an ugly stack of errors in Ruby, there should be a better way for Ruby to handle this error because it looks like a Ruby/Rails problem initially.
Next, install Row Version Migration Plugin run
“Ruby script/plugin install
svn://rubyforge.org/var/svn/redhillonrails/trunk/vendor/plugins/row_version_migrations”
And viola, when I rake db:migrate to create the table, the new table showed up with those 3 columns added automatically, cool stuff.
December 20, 2007 at 1:38 am
I would like to see a continuation of the topic