Class: NotificationSetting

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/notification_setting.rb

Overview

Schema Information

Table name: notification_settings

id          :integer          not null, primary key
user_id     :integer          not null
source_id   :integer          not null
source_type :string           not null
level       :integer          default(0), not null
created_at  :datetime         not null
updated_at  :datetime         not null

Class Method Summary collapse

Class Method Details

.find_or_create_for(source) ⇒ Object


32
33
34
35
36
37
38
39
40
# File 'app/models/notification_setting.rb', line 32

def self.find_or_create_for(source)
  setting = find_or_initialize_by(source: source)

  unless setting.persisted?
    setting.save
  end

  setting
end