Saturday, 27 July 2013

Overwrite models attributes at Serializer with rails 4

class AppSerializer < ActiveModel::Serializer
attributes :hashid, :updated_at
def updated_at
object.updated_at.to_time.to_i
end
def attributes
data = super
data[:attribute] = edit_app_url(object)
data
end
end
view raw gistfile1.rb hosted with ❤ by GitHub

No comments:

Post a Comment