Git Product home page Git Product logo

Comments (4)

spikex avatar spikex commented on June 11, 2024

Strongbox has tests for more than one field which pass under 3.1, so my guess is that's not the root of the problem. "Cannot visit" appears to be raised when a string is expected and instead an object is found. Strongbox turns the encrypted fields into objects, so this seems likely. Do you have any validations on those fields?

from strongbox.

oleander avatar oleander commented on June 11, 2024

I've solved the problem.

I had this line in my user model.

 validates_uniqueness_of :phone_number, scope: [:username]

I used the validation above before I changed the type of the username column from string to binary.

In other words; this should work.

 validates_uniqueness_of :phone_number

@spikex Any idea why this is happening?

from strongbox.

spikex avatar spikex commented on June 11, 2024

It happens because when the scope feature of validates_uniqueness_of ends up with the Lock object when it was expecting the string value of the column. You could argue that this is a bug in validates_uniqueness_of, that it should call to_s to make sure it has a string.

But, it's never going to work in Stongbox; even if you had the username for the scope, given that a string is never encrypted the same way twice, that username can't be matched against the already encrypted ones in the database.

from strongbox.

oleander avatar oleander commented on June 11, 2024

That explains a lot, thanks!

from strongbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.