Tag Archives: as_json

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 | Also tagged , , , , | Comments closed