Showing posts from November, 2007

links for 2007-11-30

Scientific American: The Secret to Raising Smart Kids
(tags: kidseducation)

Reinspire :: CSS Vertical Stretch
span or stretch a div all the way to the bottom of the page
(tags: css)

links for 2007-11-29

links for 2007-11-28

links for 2007-11-27

links for 2007-11-23

links for 2007-11-21

links for 2007-11-17

links for 2007-11-16

subtlety : a remote subversion excursion
This is just too useful. I'm using it to monitor Rails.
(tags: subversionrss)

Functional Programming Meets Web Application Development

If you're checking out functional programming, but are firming stuck in object oriented programming, then give Scala a try. Scala merges aspects of OOP and FP together into a cohesive and flexible language.

If you're a web application developer interested in functional programming, then you'll want to check out David Pollak's presentation on lift to the Bay Area Functional Programmers.

lift is a web framework written in Scala, using both functional programming and Scala's Actors, which enable heavily concurrent applications via lightweight (threadless) processes.

links for 2007-11-09

Rails Bug With Has Many Collections Empty? and Build

After my long rant about problems in Ruby on Rails has_many collections and empty? calls, we spent some more time and really condensed the problem. I can explain this problem much more clearly now.

Let's take the following code:

f =
pp f.bars

What do you think will be printed out when we pp f.bars?

Well, if you're like me, you'd think it would return an array with one Bar in it. And, if you were like me, you'd be wrong.

Turns out that the call to f.bars.empty? doesn't realize you've ever added a new Bar to the collection of bars. Therefore, it will go into the database and do a select count(*) to determine the size of the collection. It will return zero, because at this point you haven't saved anything into the database. Not only is going to the database to determine the size of the collection wrong (in the line above, I've added a Bar though build so empty? should know there's at least one), but empty? in the process…

links for 2007-11-07

When Empty Isn’t Empty With Rails Active Record Collections

So I'm writing some Rails code, just playing around, and I run into a very strange situation. I've found a situation where Rails' Active Record code is calculating the results to empty? incorrectly, even if I add elements to the collection. So I had a has_many collection with elements inside of it, but calls to length or empty were returning 0 and true.

Here's my simple models:

class Query < ActiveRecord::Base
has_many :measures
validates_presence_of :cube_name

def measure_attributes=(attrs)
attrs.each {|a|}


class Measure :query
has_one :condition, :as => :conditionable

Notice that in Query, I've added a measure_attributes method which automatically handles the construction of new Measure instances from the form parameters.

Here's the simple nested form. From the models, a Query has many Measures:

<% form_for :query, :url => {:action => :new} do |f| %>
Cube Name: <%= f.text_field :cube_name %>

<% @…

links for 2007-11-03