mirror of
https://github.com/wahyd4/libr-2.git
synced 2026-08-10 22:06:01 +10:00
30 lines
566 B
Ruby
30 lines
566 B
Ruby
class Post < ActiveRecord::Base
|
|
|
|
has_many :comments, as: :commentable
|
|
has_many :likes, as: :likable
|
|
has_many :favorites, as: :favoritable
|
|
has_many :share_instances, as: :sharable, dependent: :destroy
|
|
has_many :timeline_sources
|
|
|
|
has_many :images
|
|
|
|
has_one :thumbnail
|
|
|
|
validates_presence_of :url, :type
|
|
|
|
acts_as_paranoid
|
|
|
|
# default_scope {where(:blocked => false)}
|
|
|
|
# default_scope {where(:processed => true)}
|
|
|
|
def first_sharer
|
|
share_instances.first.user_name
|
|
end
|
|
|
|
def self.json_attrs
|
|
[:id, :url, :title, :type, :summary]
|
|
end
|
|
|
|
end
|