2015-12-11 19:23:41 +00:00
|
|
|
class Message < ActiveRecord::Base
|
|
|
|
belongs_to :user
|
|
|
|
belongs_to :resource, polymorphic: true
|
|
|
|
|
2016-07-26 00:14:23 +00:00
|
|
|
delegate :name, to: :user, prefix: true
|
2015-12-11 19:23:41 +00:00
|
|
|
|
|
|
|
def user_image
|
2016-07-26 00:14:23 +00:00
|
|
|
user.image.url
|
2015-12-11 19:23:41 +00:00
|
|
|
end
|
|
|
|
|
2016-07-26 00:14:23 +00:00
|
|
|
def as_json(_options = {})
|
|
|
|
json = super(methods: [:user_name, :user_image])
|
2015-12-11 19:23:41 +00:00
|
|
|
json
|
|
|
|
end
|
|
|
|
end
|