Author Archives: Matt Pulver

Why Do Cells Have DNA?

In order for a system to reproduce itself, it seems necessary for it to hold an encoded form of itself somehow. This idea, and the inevitability of the existence of DNA-like structures within living cells, is well-illustrated using computer code.
Posted in programming, ruby | Tagged , , , , , , | Leave a comment

ActiveRecord from_xml (and from_json) part 2

This post is an upgrade to the previous post about the unmarshalling of XML and JSON strings into rails objects, with arbitrarily deep object associations. As you may know if you are reading this, there doesn’t seem to be a way in rails to reverse to_xml and to_json when associations are included. Example usage: xml = firm.to_xml [...]
Posted in programming, rails | Tagged , , , , , | 3 Comments

ActiveRecord from_json and from_xml

Unless I’m missing something, the default rails from_json and from_xml methods don’t work with data that have associated objects. Here are routines that work for some simple examples I’ve tested. I placed this code in vendor/rails/activerecord/lib/active_record/base.rb within the ActiveRecord::Base class, but there might be a better place to put it. def self.from_hash( hash ) h [...]
Posted in programming, rails | Tagged , , , , , | 4 Comments