Tag Archives: rails

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 [...]
Posted in rails | Also tagged , , , , | 9 Comments

Chaining :include’s in Rails to reduce the number of SQL queries

Say you have the following data model and you want to execute a single query that returns all the data at once within the ActiveRecord tables, with the proper rails associations between them. Wouldn’t it be nice if you could do something like A.find(:all, :include => :b => :c => :d => :e) #v1 ? [...]
Posted in programming, rails, scalability | Also tagged , , , , , , | 1 Comment