2016-04-20 22:29:29 +08:00
|
|
|
class Subscribe < ApplicationRecord
|
2014-04-02 23:40:05 +08:00
|
|
|
validates :email, presence: true, uniqueness: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, message: '地址无效' }
|
2014-04-01 17:09:10 +08:00
|
|
|
|
|
|
|
def self.subscribe_list
|
2014-04-07 22:56:21 +08:00
|
|
|
Subscribe.all.where(enable: true).map(&:email)
|
|
|
|
end
|
|
|
|
|
2015-04-16 16:20:45 +08:00
|
|
|
def self.unsubscribe_list
|
|
|
|
Subscribe.all.where(enable: false).map(&:email)
|
|
|
|
end
|
|
|
|
|
2014-04-07 22:56:21 +08:00
|
|
|
def self.unsubscribe?(email)
|
|
|
|
Subscribe.where(email: email, enable: false).first.present?
|
2014-04-01 17:09:10 +08:00
|
|
|
end
|
|
|
|
end
|