Sha256: 15564313fb3d3c4a74f42101d9788dc969efc0e3a2680e77c7c955ee74e977c7

Contents?: true

Size: 557 Bytes

Versions: 3

Compression:

Stored size: 557 Bytes

Contents

module ClarkKent
	class UserReportEmail < ActiveRecord::Base
    include ClarkKent::Cloneable

		belongs_to :user, class_name: ClarkKent.user_class_name
		belongs_to :report_email

	  validates_with UserEmailValidator

		def email=(address)
			self.user = ClarkKent.user_class.where("lower(#{ClarkKent.user_class_name.underscore.pluralize.gsub(/\//,'')}.email) = lower(:email)",email: address).first
			self.errors.add(:email, "Couldn't find a user with that email addres") unless self.user.present?
		end

		def email
			self.user.try :email
		end
	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
clark_kent-0.11.3 app/models/clark_kent/user_report_email.rb
clark_kent-0.11.2 app/models/clark_kent/user_report_email.rb
clark_kent-0.11.1 app/models/clark_kent/user_report_email.rb