Named instances for ActiveRecord

For a project that I'm working on at my day job, we have a governmental client for which we are building a pretty large and complicated online/offline Ruby on Rails application. As part of this app there are tons of data-specific rules. For example, if a client with HIV is being assessed then certain fields may have to be displayed/hidden and there are rules that get applied differently. So lets say you have the following setup:

Now, somewhere in your code you want to be able to do take a specific action only if that client has a particular diagnosis. Without named_instances you might do something like:

With named_instances you can do the following faster and more concise code:

We've been using this functionality for about 6 months now and its been great. The gem is out on GemCutter (which rocks) and the repo is at GitHub. Hopefully it will be useful in your projects. Comments, criticisms, and patches welcome.

learnSTAT is now open source

I've been teaching a Statistics course at USC for a few years now and so, being the geek that I am, I decided a couple of semesters ago to write some course management software in Rails. I've worked on it on and off since then and I would consider it to be in a semi-usable state at this point. I've used it in my last two semesters without major problems.

The features at this point are

  • course announcements
  • course documents
  • ability to assign multiple choice quizzes
  • quiz statistics, including per question
  • ability to add exam grades

The source is available at http://github.com/jasondew/learnstat. Please send any bug reports or feature requests to jason.dew at gmail.