Serialize object for export json api
Add this line to your application's Gemfile:
gem 'mini_serializer'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mini_serializer
serializer=MiniSerializer::Serializer.new(House.all)
serializer=MiniSerializer::Serializer.new(House.all,{except:[:id,:title]})
serializer.add_has_many('house_images',['id','house_id','created_at','updated_at'])
serializer.add_has_one('house_type',['id'])
render json:serializer.json_serializer
Bug reports and pull requests are welcome on GitHub at https://github.com/mhi20/mini_serializer.
The gem is available as open source under the terms of the MIT License.