AR#to_json に こなたw
9 # konata = User.find(1) 10 # konata.to_json 11 # 12 # {"id": 1, "name": "Konata Izumi", "age": 16, 13 # "created_at": "2006/08/01", "awesome": true}
こなたwwww
15 # The :only and :except options can be used to limit the attributes 16 # included, and work similar to the #attributes method. For example: 17 # 18 # konata.to_json(:only => [ :id, :name ]) 19 # 20 # {"id": 1, "name": "Konata Izumi"} 21 # 22 # konata.to_json(:except => [ :id, :created_at, :age ]) 23 # 24 # {"name": "Konata Izumi", "awesome": true}
ほうほう、AR#to_json に :only と :except がつけられるのかー。良いことを知った。
あと :include もあるのね。で、:include でも :only とかが使えると。