Welcome to your Dehydrate gem!.This gem provide a method named resourceful which you can use in your controller to make it resourceful and remove duplicacy.
Add this line to your application's Gemfile:
gem "dehydrate", path: "url of this repo"
And then execute:
$ bundle install
Make your controller resourceful by adding "dehydrate" in your controller
Bug reports and pull requests are welcome on GitHub at https://github.com/gemventory/dehydrate.