Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use with bcrypt #190

Closed
alec-c4 opened this issue Feb 27, 2024 · 1 comment
Closed

Use with bcrypt #190

alec-c4 opened this issue Feb 27, 2024 · 1 comment

Comments

@alec-c4
Copy link

alec-c4 commented Feb 27, 2024

Hey!
Thanks a lot for your work. I'd like to use lockbox with bcrypt gem, I've replaced in my migration email field to

      t.text :email_ciphertext, null: false, default: ""
      t.string :email_bidx, null: false, default: ""

and added

  has_encrypted :email
  blind_index :email

and everytime I try to create an user I see following

irb(main):001> User.new
/Users/alec/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/activemodel-7.1.3.2/lib/active_model/attribute_methods.rb:486:in `method_missing': super: no superclass method `email' for an instance of User (NoMethodError)
Did you mean?  email?

How to fix it?

@ankane
Copy link
Owner

ankane commented Feb 27, 2024

Hi @alec-c4, I'm not sure how to reproduce the error.

require "bundler/inline"

gemfile do
  source "https://rubygems.org"

  gem "activerecord", require: "active_record"
  gem "sqlite3"
  gem "lockbox"
  gem "blind_index"
  gem "bcrypt"
end

ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"

ActiveRecord::Schema.define do
  create_table :users do |t|
    t.text :email_ciphertext
    t.string :email_bidx
    t.string :password_digest
  end
end

class User < ActiveRecord::Base
  has_encrypted :email
  blind_index :email
  has_secure_password
end

p User.new

@ankane ankane closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants