我attr_encrypted
在 rails 3.2.13 中使用来加密一列。为此,在我的模型中,我有以下内容:
attr_encrypted :social_security_no, :key => 'a secret key'
该应用程序既不保存social_security_no
也不保存encrypted_social_security_no
在数据库中。
我也试过spectator-attr_encrypted
宝石。但是,现在它给出了以下错误:
/home/ashish/.rvm/gems/ruby-2.0.0-p0@lendty/gems/activerecord-3.2.13/lib/active_record/dynamic_matchers.rb:55:in 'method_missing': undefined method 'attr_encrypted' for #<Class:0x0000000824f768> (NoMethodError)
那么,有什么办法可以摆脱这个问题呢?或者,是否有适用于 Rails 3.2.13 和 Ruby 2.0.0 的 gem 的分叉版本?
而且,这是我的模型:
class Lender < ActiveRecord::Base
extend SignUpCounter
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :first_name, :last_name, :evening_phone, :daytime_phone, :social_security_no
attr_encrypted :social_security_no, :key => '3243serw54325325435sdrtf34453454325sdt346546'
# Validations
validates_uniqueness_of :social_security_no, :email
# Geocoding
geocoded_by :current_sign_in_ip
after_validation :geocode
# Associations
has_many :loans
has_many :borrowers, :through => :loans
# Scopes
scope :verified, where(verified: true)
def full_name
first_name.to_s + " " + last_name
end
end