ea8e9901f4
Your branch is behind 'origin/strong-params' by 1 commit, and can be fast-forwarded. I'll pull to catch up after this commit Change code to whitelist params Remove attr_accessible lines Add strong_params to Gemfile, since this branch is still on Rails 3 Mixin to ActiveRecord::Base ActiveModel::ForbiddenAttributesProtection Use an initializer for the mixin
21 lines
510 B
Ruby
21 lines
510 B
Ruby
class Pay < ActiveRecord::Base
|
|
# Associations
|
|
belongs_to :user
|
|
|
|
# Validations
|
|
validates :bank_account_num, presence: true
|
|
validates :bank_routing_num, presence: true
|
|
validates :percent_of_deposit, presence: true
|
|
|
|
# callbacks
|
|
before_save :encrypt_bank_account_num
|
|
|
|
def as_json
|
|
super(only: [:bank_account_num, :bank_routing_num, :percent_of_deposit, :id])
|
|
end
|
|
|
|
def encrypt_bank_account_num
|
|
self.bank_account_num = Encryption.encrypt_sensitive_value(self.bank_account_num)
|
|
end
|
|
end
|