Install Lesli core

Lesli is a Ruby on Rails gem designed to seamlessly integrate with your application. It ensures complete isolation of code, database, and assets, preventing any interference with your main Ruby on Rails application.

Rails application

Create a new Rails application

rails new LesliApp

Navigate to the LesliApp folder

cd LesliApp

Add Lesli gem to your Rails app

bundle add lesli

Additional for this example we are going to install some other engines, so you can see the Lesli Platform working

bundle add lesli_shield
bundle add lesli_dashboard


Database

Open the database configuration file

LesliApp/config/database.yml

Add PostgreSQL as the main database (Currently Lesli is compatible only with PostgreSQL and SQLite)

default: &default
  adapter: postgresql
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  database: "db_dev"
  username: "db_user"
  password: "db_pass"

test:
  <<: *default
  database: "lesli-test"
  username: "db_user"
  password: "db_pass"

My recommendation is to use Rails Credentials or AWS Secret Manager

development:
  <<: *default
  database: <%= Rails.application.credentials.dig(:db, :database) %>
  username: <%= Rails.application.credentials.dig(:db, :username) %>
  password: <%= Rails.application.credentials.dig(:db, :password) %>

test:
  <<: *default
  database: <%= Rails.application.credentials.dig(:db, :database) %>
  username: <%= Rails.application.credentials.dig(:db, :username) %>
  password: <%= Rails.application.credentials.dig(:db, :password) %>

production:
  <<: *default
  port: <%= Rails.application.credentials.dig(:db, :port) %>
  host: <%= Rails.application.credentials.dig(:db, :host) %>
  database: <%= Rails.application.credentials.dig(:db, :database) %>
  username: <%= Rails.application.credentials.dig(:db, :username) %>
  password: <%= Rails.application.credentials.dig(:db, :password) %>

Create the database for Lesli

rails db:create

Lesli include a Rake task to initialize the database for demo and development purposes, this task is going migrate, build privileges (if LesliSecurity is installed), translations (if LesliBabel is installed), seed the database with demo users and demo data for every installed engine and at the end print a pretty message with the status of the application.

rake lesli:db:dev


Router

Open the Rails routes file at: LesliApp/config/routes.rb and include the Lesli modules

Rails.application.routes.draw do
    # mount lesli platform
    Lesli::Routing.mount
end


Run Lesli

Execute the Rails server

rails server

Using your favorite web browser navigate to http://127.0.0.1:3000/login, Lesli mounted devise at root level, so you already have an authentication engine working.

The seeders comes with default users with different roles and privileges, to see Lesli in action use the owner user:

username: [email protected]
password: Tardis2023$

It is possible to add development users, roles, privileges and more; we will explore this options later in the documentation.

 Edit this page

Last Update: 2024/12/26