metamaps--metamaps/app/models/message.rb
2016-09-24 11:00:46 +08:00

16 lines
313 B
Ruby

# frozen_string_literal: true
class Message < ApplicationRecord
belongs_to :user
belongs_to :resource, polymorphic: true
delegate :name, to: :user, prefix: true
def user_image
user.image.url
end
def as_json(_options = {})
json = super(methods: [:user_name, :user_image])
json
end
end