Pivotal Labs

Kelly Felkins's blog



Standup 5/9/2008

edit Posted by Kelly Felkins on Friday May 09, 2008 at 05:43PM

Interesting

  • attr_readonly marks an attribute as, ah, read only -- use it to tell ActiveRecord that an attribute should not be a part of update operations. Rails uses attr_readonly internally with counter caches (search for "counter_cache" under ActiveRecord::Associations::ClassMethods) since counter caches are incremented/decremented directly in the database with sql. Without attr_readonly, subsequent updates of the counter_cache'd model would revert the counter to the value of the counter at the time the model was loaded.

Note: attr_readonly was either buggy or not exposed prior to 1.2.3. If you are using a version of rails prior to 1.2.3 you can do this instead:

def attributes_with_quotes(include_primary_key = true)
  attributes.inject({}) do |quoted, (name, value)|
    if column = column_for_attribute(name)
      # original:
      # quoted[name] = quote_value(value, column) unless !include_primary_key && column.primary
      quoted[name] = quote_value(value, column) unless !include_primary_key &&
          (column.primary || ["your_attributes", "listed_here"].include?(column.name))
    end
    quoted
  end
end

Ask for Help

  • help: Looking for recommendations on converting an existing schema to a new schema. We are considering dumping the existing schema to yaml (using ar_fixtures) and making the transformations there.
    • answer #1: One recent project had a "liberate" script that extracted information from the legacy database via sql statements and constructed AR model objects as necessary. The liberate script grew to some 1500 lines of code and was refactored many times.
    • answer #2: Another project did the data migration by first importing the legacy database and then using rails migrations as needed to transform the data to the new schema. Most of the migrations used sql for the transformations. These migrations did not have associated unit tests.
    • Please offer your suggestions in the comments.

Standup 5/8/2008

edit Posted by Kelly Felkins on Thursday May 08, 2008 at 04:25PM

Interesting

Ask for Help

Standup 5/7/2008

edit Posted by Kelly Felkins on Wednesday May 07, 2008 at 04:24PM

Interesting

  • "JsUnit has been updated" A new feature available on trunk is a "modern" ui. The modern ui has 2 panes, with errors and failures listed on the left. Clicking on an error displays details on the right. Get this by 1) installing trunk, and 2) specifying "ui=modern" as a parameter.

Screen grab of old and new ui for jsunit

Ask for Help

  • help: "Selecting an iframe with Selenium RC fu" It appears that selenium has the ability to select an iframe, but it doesn't work in selenium rc fu.
    • answer: Apparently the selenium provided in selenium rc fu is an older version

Standup 5/6/2008

edit Posted by Kelly Felkins on Tuesday May 06, 2008 at 04:21PM

Ask for Help

  • "RSpec only Hoe?" How do you convince Hoe to only run specs and not tests?
    • In the distance a dog barks...
  • "Is there a fun way to learn Ruby?" I have a 500 page book, but is there a fun way to learn Ruby?
    • (various pivots look at each other) "Pairing...of course"
  • "Use RSpec to verify deployment?" Previously I used Rspec with JRuby to create stories for a java project. It would be nice to have a deployment story. The plan would say "apache goes here", "mongrel goes there", "mysql goes over there". You could show the plan to your customer printed on a piece of paper and you could run it to do the deployment.

Standup 05/05/2008

edit Posted by Kelly Felkins on Monday May 05, 2008 at 04:36PM

Interesting Things

  • Interesting things were all about internal Pivotal Labs activities this week.

Ask for Help

  • Window.frames['name'] If we add a frame, then remove it, then add it again, it's still there.

    • [silence]
  • "What's that gem that draws a graph of your models?"

Sample RailRoad Output, model names changed to protect the innocent