0
當我嘗試創建控制檯一個新的記錄,我得到這個錯誤:的Rails +保險櫃:類型錯誤:無法施展保險櫃::鎖定爲二進制
TypeError: can't cast Strongbox::Lock to binary
不過,其他表在那裏我使用Strongbox工作正常。 我的模式是這樣的:
create_table "recordings", force: true do |t|
t.datetime "date"
t.string "position"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "patient_id"
t.binary "sound_file"
t.binary "sound_file_key"
t.binary "sound_file_iv"
t.binary "image_file"
t.binary "image_file_key"
t.binary "image_file_iv"
t.binary "audio_data_points"
t.binary "audio_data_points_key"
t.binary "audio_data_points_iv"
end
create_table "notes", force: true do |t|
t.integer "user_id"
t.integer "recording_id"
t.integer "patient_id"
t.binary "content"
t.binary "content_key"
t.binary "content_iv"
end
我的模式是這樣的:
class Note < ActiveRecord::Base
validates :content, presence: true
belongs_to :user
belongs_to :recording
belongs_to :patient
encrypt_with_public_key :content,
:key_pair => Rails.root.join('config','keypair.pem')
end
class Recording < ActiveRecord::Base
validates :date , presence: true
validates :position , presence: true
validates :sound_file , presence: true , uniqueness: true
validates :image_file , presence: true , uniqueness: true
has_many :notes, dependent: :destroy
has_many :srecordings
has_many :users, through: :srecordings
belongs_to :patient
encrypt_with_public_key :sound_file, :image_file, :audio_data_points,
:key_pair => Rails.root.join('config','keypair.pem')
end
我從來沒有使用保險櫃之前,但它的正常工作在其他地方,所以我不完全得到這一個。思考?