Getting lost with all available attributes names on an Active Record object is normal, especially on large projects.
A lot of programmers have developed the bad habit of consulting the migrations to identify which attributes are available on an Active Record model. This certainly is not the smartest way to do this.
I had been using a gem called annotate to automatically add comments in my models with the database schema. But that wasn’t automatic enough.
So I decided to create something more practical and I ended up implementing a pseudo-intelissense for Textmate which can display a list with all available attributes for each Active Record model in my project. See how it works:
The idea is pretty simple. The variable name is important here. Since you can’t get the project scope through TextMate (if anyone has an idea how to do it please let me know), then the variable name is what indicates which Active Record model should be used.
For example, if you have a model named
User you should use variable names as
@@user, etc.. Variables such as
@products will show the
Product model attributes. The concept is simple. If you use a different variable name, you must indicate which model should be used.
This is still an experimental feature and a work in progress. See some of the latest features that I’ve been working in recent days:
You can install running the following commands in the terminal window:
mkdir -p ~/Library/Application\ Support/TextMate/Bundles cd ~/Library/Application\ Support/TextMate/Bundles git clone git://github.com/carlosbrando/ruby-on-rails-tmbundle.git "Ruby on Rails.tmbundle" osascript -e 'tell app "TextMate" to reload bundles'
This bundle is a fork of Dr. Nic’s ruby-on-rails-tmbundle. So if you already have installed this bundle, it’s advisable to remove it before to avoid conflicts.
The project is on GitHub: http://github.com/carlosbrando/ruby-on-rails-tmbundle