My Profile Photo

rubycoloredglasses


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


  1. Rspec Executable Not Found

    I’m working on an older Rails 2.3.8 application that is way too complicated and without tests to make it worth upgrading to Rails 3 or higher. Because of this we must use RSpec-Rails 1.3.4, with RSpec 1.3.2. …


  2. Changing the Default Text Editor

    Certain command line utilities drop into an external text editor program to accept certain types of input. For instance, when using the command ‘crontab -e’ to edit your cron table, your default text editor program will be opened up with the current cron table configuration. The same also applies to the Git versioning system when using the interactive rebase mode. This helps the program avoid supporting it’s own text editor, and allows the user to specify their preferred text editor. …


  3. Metaclass

    I ran into an instance of meta programming in Ruby today, in the Exceptional Ruby book I’m reading for work. It seems that the theme this week is “you don’t know Ruby as well as you could”. …


  4. Using Super with Ruby class methods

    One of the awesome things about Ruby is that you can over-ride methods you define, or even over-write methods that are built into Ruby. …


  5. Ruby Coloured Glasses

    I’m sorry Taryn. My friend just pointed your site out to me. I swear it was a coincidence. I like your background by the way. …


  6. Duplicate associated records when using FactoryGirl

    When I decided to start using tests as part of my development practice, I had the choice of using the default fixture system, or using one of the recommended fixture alternatives, also known as factories. I decided upon using FactoryGirl given it’s popular mention on the web, and one of the projects at work was using it. …


  7. Finding Records without Specific Child in Many-to-Many Relationship

    Okay. Here is a tricky challenge. Let’s say you are coding a blog system where Posts may have many Tags, and a tag can have many posts. Your database would have a ‘posts’ table, a ‘tags’ table, and a ‘post_tags’. With Ruby on Rails this would be configured for an ActiveRecord model using the has_many through method. …


  8. Listing Gems from Rails Console

    Got this from Stack Overflow, figured it could come in handy at some point in the future. …


  9. Add a Serialized Hash Attribute to a Factory_Girl Definition

    I recently declared an ActiveRecord model which stores a serialized Hash inside of a text field. When I tried to setup a factory for this model using FactoryGirl, I received many syntax errors. This is because FactoryGirl attributes expect a single value or a certain form of code block. …


  10. List Sorted Methods in Ruby

    I often use ‘methods’ to get a list of methods available for an object in Ruby, but it can be a pain trying to look through the list for what I want. I wish it outputed in a sorted list straight down the page. This template will help you achieve that. Maybe I should override the ‘methods’ method. Hm… …