Przeglądaj źródła

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

Chris Oliver 6 lat temu
rodzic
commit
8ddc352422
2 zmienionych plików z 8 dodań i 0 usunięć
  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