My Profile Photo

rubycoloredglasses


I'm Jason, a web applications developer in the San Francisco Bay area.


  1. Using Serialize Option with ActiveRecord Objects

    Documentation seems to be more available on how to build forms with check boxes or a multiple select field for ActiveRecord objects that have a has_many or has_many_and_belongs_to association with other ActiveRecord objects. This article shows you how provide a multiple select form based on a custom defined array, with the selected options stored in a single attribute of your ActiveRecord object. …


  2. Save the Tests, Don't Throw Them Away

    So it’s been several weeks since I started using test driven development. I’m using FactoryGirl instead of fixtures, because I’ve heard that fixtures are limiting. I’d rather just write Factories from the beginning. I’m also using standard Test::Unit based unit and functional tests. Haven’t touched on integration testing yet. …


  3. Factory Girl Associations and Records Persisting Across Tests

    I just recently started to adopt test driven development practices. The project I’m working on needs to get done soon, and I didn’t want to get held up learning Rspec. After much consulting with other developers at the company I work for, I had decided to use basic Test::Unit tests with FactoryGirl factories instead of fixtures, and adopt Shoulda if a scenario arises where the options it provides (contexts) are needed. …


  4. Generating Test File Stubs for Existing Models, Views, and Controllers

    I’ve noticed that if you install certain testing gems, like Factory Girl, or Rspec, that your Rails application will create test files for these libraries instead of using the defaults. Even further you can configure the generators used by your Rails app in /config/application.rb …


  5. Rails 3 and Subclasses Method

    I was just trying to create coding that reflectively loads the subclasses of a class I’ve defined. The idea is that as new subclasses are added, the script I’m writing can detect which ones are present and inform a remote API that support for a specific API feature is available. …


  6. Locate and Updatedb with Homebrew

    UPDATE: I ran into errors and decided to not use the findutils provided by Homebrew. I simply setup the following alias in .bash_profile and this did the trick. This is using the built in locate database provided with Mac OS X Snow Leopard. …


  7. Foreign Key References when Generating Model

    I forget the proper syntax for a model generation command that includes a reference to another models id (foreign key). …


  8. Edit Devise User without Password

    I recently setup a custom controller to edit/update my Admin accounts, which are authenticated using Plataformatec’s Devise gem. …


  9. Factory Girl Not Generating Factories with Scaffold

    I just started a new Rails 3.2 project, and to ensure that the proper test files are generated using Shoulda or Factory_Girl, I’ve installed those gems and configured the application to generate the test files using these gems. …


  10. Ruby Comparison Operator =~

    I saw this in some code recently, wasn’t sure what it did. …