Reputation: 7725
I'm trying to render a json from an ActiveRecord::Base
object, including paperclip
's methods.
> i = Model.last
> i.to_json methods: :picture
=> # Successful output
Problem is, I need .picture.url(:tiny)
and to_json methods: 'picture.url(:tiny)'
doesn't work. Is there a way to make to_json
work or I'll have to work this around other way?
Upvotes: 0
Views: 1134
Reputation: 29599
in your picture model, create a method called picture_avatar
def tiny_avatar
picture.url(:tiny)
end
then use that method to pass to to_json
i.to_json methods: :tiny_avatar
Upvotes: 2