Clear ORM
  • Welcome to Clear
  • Introduction
    • Setup
  • Model
    • Defining your model
      • Describing your columns
      • Primary Keys
      • Converters
    • Associations
      • belongs_to
      • has_many
      • has_many through
      • has_one
    • Lifecycle
      • Persistence
      • Validations
      • Triggers
    • Batchs operations
      • Bulk update
      • Bulk insert & delete
    • Transactions & Save Points
      • Transaction & Savepoints
      • Connection pool
    • Locks
  • Querying
    • The collection object
      • Filter the query
        • Filter the query – The Expression Engine
        • Find, First, Last, Offset, Limit
        • Aggregation
        • Ordering & Group by
      • Fetching the query
        • Each and Fetch
        • Cursored fetching
        • Model extra attributes
      • Joins
      • Eager Loading
      • Window and CTE
      • Scopes
    • Writing low-level SQL
      • Select Clause
      • Insert Clause
      • Delete Clause
  • Migrations
    • Manage migrations
    • Call migration script
    • Migration CLI
  • Additional and advanced features
    • JSONB
    • Symbol vs String
    • Enums
    • BCrypt
    • Full Text Search
    • Handling multi-connection
  • Other resources
    • API Documentation
    • Inline documentation
    • Github repository
    • Credits
    • Benchmark
Powered by GitBook
On this page
  1. Additional and advanced features

BCrypt

We provide helper for storing encrypted password. See example below:

class User
  include Clear::Model
  primary_key :id, type: :uuid
  
  column encrypted_password : Crypto::Bcrypt::Password
  
  def password=(x)
    self.encrypted_password = Crypto::Bcrypt::Password.create(x)
  end  
end


# Create a new user with the password
User.create!({password: "helloworld"})

#...

# Get the created user
user = User.query.first

if user.encrypted_password.verify("thisisfalse") # < false
  #...
end
PreviousEnumsNextFull Text Search

Last updated 5 years ago