I have a model User
and another Images
and relationship in between both of these as:
User has_many :images
Image belongs_to :user
Now I'm writing a json api to get user with his images using eagerloading like,
User.all.as_json({:include=> {:images => {only: [:image_url] } })
Now I want to get images and want to override JSON at the time of generating like we can override as_json
method in my user model same as I want to override at time time of include, but that is not generating using as_json
in Image Model.
Aucun commentaire:
Enregistrer un commentaire