Monthly Archives: March 2011

Recursive custom to_json in Ruby for arrays of objects or nested objects

Let’s say we want to customize the json template for an object: class User def to_json super(:except => [:password, :password_salt, :encrypted_password, :last_sign_in_ip, :updated_at, :current_sign_in_ip, :remember_token, :reset_password_token, :remember_created_at]) end end Apparently this is fixed in Ruby 1.9 but for now only converting an object [...]
Posted in Software | Tagged , , , , , | Comments closed

Deduping join data in ruby based on multiple attributes

In the past I created an app using Rails built in HABTM and no unique index on the join tables. I’m more into the has_many :through choice today. In order to migrate my data with a unqiue index, I had a bunch of de-duping to do. It was a bit trickier than [...]
Posted in Software | Tagged , , , , , | Comments closed