2012-10-26 10:04:52 +00:00
|
|
|
class Mapping < ActiveRecord::Base
|
|
|
|
|
2015-10-02 08:04:30 +00:00
|
|
|
scope :topicmapping, -> { where(mappable_type: :Topic) }
|
|
|
|
scope :synapsemapping, -> { where(mappable_type: :Synapse) }
|
|
|
|
|
|
|
|
belongs_to :mappable, polymorphic: true
|
2015-09-10 14:48:35 +00:00
|
|
|
|
2014-08-12 22:14:04 +00:00
|
|
|
belongs_to :map, :class_name => "Map", :foreign_key => "map_id"
|
2012-10-26 10:04:52 +00:00
|
|
|
|
2014-08-12 22:14:04 +00:00
|
|
|
belongs_to :user
|
2014-08-12 16:01:01 +00:00
|
|
|
|
|
|
|
def user_name
|
|
|
|
self.user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
def user_image
|
|
|
|
self.user.image.url
|
|
|
|
end
|
|
|
|
|
|
|
|
def as_json(options={})
|
|
|
|
super(:methods =>[:user_name, :user_image])
|
|
|
|
end
|
2013-04-26 04:07:29 +00:00
|
|
|
|
2012-10-26 10:04:52 +00:00
|
|
|
end
|