to_jsonの履歴

railsの配列を簡単にjsonにしてくれる便利メソッド

{ word:<%= @word.to_json(:only => [:id, :title]) %>
  parents:<%= @word.parents.map{|w|w.from}.to_json(:only => [:id, :title]) %>
  children:<%= @word.children.map{|w|w.to}.to_json(:only => [:id, :title]) %>
}


http://apidock.com/rails/ActiveRecord/Serialization/to_json