metamaps--metamaps/app/models/message.rb

17 lines
313 B
Ruby
Raw Normal View History

2016-09-24 03:00:46 +00:00
# frozen_string_literal: true
class Message < ApplicationRecord
2015-12-11 19:23:41 +00:00
belongs_to :user
belongs_to :resource, polymorphic: true
delegate :name, to: :user, prefix: true
2015-12-11 19:23:41 +00:00
def user_image
user.image.url
2015-12-11 19:23:41 +00:00
end
def as_json(_options = {})
json = super(methods: [:user_name, :user_image])
2015-12-11 19:23:41 +00:00
json
end
end