code from here -> http://railscasts.com/episodes/348-the-rails-api-gem?language=ja&view=asciicast