Ruby on rails 轨道&x2B;Strongbox:TypeError:can';t强制转换Strongbox::锁定到二进制
当我尝试在console中创建新录制时,出现以下错误:Ruby on rails 轨道&x2B;Strongbox:TypeError:can';t强制转换Strongbox::锁定到二进制,ruby-on-rails,console,Ruby On Rails,Console,当我尝试在console中创建新录制时,出现以下错误: 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.in
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
我的模型是这样的:
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
class注释Rails.root.join('config','keypair.pem'))
结束
类录制Rails.root.join('config','keypair.pem'))
结束
我以前从未使用过保险箱,但它在其他任何地方都能正常工作,所以我不太明白这一点。想法?唯一性验证与strongbox不兼容。您的录音模型是唯一检查声音文件和图像文件唯一性的模型。对您来说,最好的方法是在此处添加自定义验证以检查唯一性。令人惊讶的是,我用完全相同的模型得出了这个结论:) 另外,为了唯一性,我正在自己实施自定义验证