mostrar notificaciones a los usuarios cuando alguien comenta en su
debate o responde a su comentario
This commit is contained in:
12
app/models/notification.rb
Normal file
12
app/models/notification.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Notification < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :activity
|
||||
|
||||
scope :unread, -> { where(read: false) }
|
||||
scope :recent, -> { order(id: :desc) }
|
||||
scope :for_render, -> { includes(activity: [:user, :trackable]) }
|
||||
|
||||
def timestamp
|
||||
activity.trackable.created_at
|
||||
end
|
||||
end
|
||||
@@ -22,6 +22,7 @@ class User < ActiveRecord::Base
|
||||
has_many :proposals, -> { with_hidden }, foreign_key: :author_id
|
||||
has_many :comments, -> { with_hidden }
|
||||
has_many :failed_census_calls
|
||||
has_many :notifications
|
||||
|
||||
validates :username, presence: true, if: :username_required?
|
||||
validates :username, uniqueness: true, if: :username_required?
|
||||
|
||||
Reference in New Issue
Block a user