Posted on November 13, 2006 at 9:37 pm

A reminder to myself and others:

You should understand, that in truth, no genuine satisfaction in life can ever be attained by you or anyone else, who simply refuses to take risks. For the life of anyone who chooses to live with extreme caution will never amount to anything more than a succession of dull, soporific days, continuing on, without interruption.”

I wrote this quote down some time ago, but failed to write down where I got it. If you know where this quote originated, please let know.

Posted on November 3, 2006 at 12:30 pm

Three weeks ago I left the security of my job of the last 8 years to pursue a new career as a freelance consultant/programmer.

I’ve been freelancing part-time for several years and it was always a nice supplement to my income, but I was afraid of going it alone. What if I couldn’t make enough to support my family? What if I’m not good enough? What if I fail and have to go find a job? What will people think of me then?

Earlier this year I came to the realization that there is no reason to fear failing. Would it be the end of the world if I did fail? Hardly. Would I be embarrassed? Probably. But, embarrassed or not, I can always change gears or find another job. I could even give up and just lay around watching TV all day while my wife supports me.

So, now I’m doing what I really love: Developing the best software that I’m able, using Ruby and Ruby on Rails. I also plan to spend more time working on my own software and writing about Ruby and Ruby on Rails. I’m even considering doing some speaking on the subject.

Are you looking for an experienced Ruby or Ruby on Rails developer? Maybe you’re just looking for some mentoring or guidance on a project? Send me an email at keithm at infused.org. I’m always looking for exciting new projects.

Posted on October 7, 2006 at 12:29 pm

New in dbf-0.4.0:

  • Support for dBase III style memo files
  • Documentation in doc/readme.txt
  • Fixed that field lengths were being read as signed integers, when they be should be unsigned
  • Fixed skipping over deleted records

Thank you to everybody that submitted patches and test files. Keep ‘em coming.

Posted on September 28, 2006 at 10:25 am

Update_attributes is not very smart; it will update a record whether or not the hash you pass it contains any changed values. If you aren’t careful, you could end up with a ton of database writes for no reason. Try my update_attributes_if_changed method instead:

module ActiveRecord
  class Base

    def update_attributes_if_changed(hash)
      update_attributes(hash) if needs_update?(hash)
    end

    def needs_update?(hash)
      hash.stringify_keys!
      !attributes.dup.delete_if{|k,v| !hash.key?(k) || hash[k] == v}.empty?
    end

    def write_attributes(hash)
      attributes.merge(hash.stringify_keys)
    end

  end
end

I’ve thrown in a method called write_attributes too. It works just like update_attributes, but it doesn’t automatically save the record.

Posted on September 26, 2006 at 4:43 pm

Yesterday, somebody asked me if it’s possible to format the contents of an input field using the text_field form helper.

I don’t think its documented in the API docs, but you can specify the value to use by passing in a value parameter:

text_field :book, :title, :value => @book.title.upcase