浏览代码

Merge branch 'master' of github.com:excid3/spark-clone

Chris Oliver 6 年之前
父节点
当前提交
8ddc352422
共有 2 个文件被更改,包括 8 次插入0 次删除
  1. 3 0
      app/models/notification.rb
  2. 5 0
      template.rb

+ 3 - 0
app/models/notification.rb

@@ -2,6 +2,9 @@ class Notification < ApplicationRecord
   belongs_to :recipient, class_name: "User"
   belongs_to :actor, class_name: "User"
   belongs_to :notifiable, polymorphic: true
+  
+  scope :unread, -> { where(read_at: nil) }
+  scope :recent, -> { order(created_at: :desc).limit(5) }
 
   def self.post(to:, from:, action:, notifiable:)
     recipients = Array.wrap(to)

+ 5 - 0
template.rb

@@ -182,6 +182,10 @@ def add_whenever
   run "wheneverize ."
 end
 
+def stop_spring
+  run "spring stop"
+end
+
 # Main setup
 add_template_repository_to_source_path
 
@@ -189,6 +193,7 @@ add_gems
 
 after_bundle do
   set_application_name
+  stop_spring
   add_users
   add_bootstrap
   add_sidekiq