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 RoR 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
Database
Open the database configuration file LesliApp/config/database.yml
Add PostgreSQL as the main database (Currently Lesli is compatible only with Postgres)
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"
Create the database for Lesli
rails db:create
Lesli include a Rake task to start the database, this task is going to create, migrate, seed and initialize our database.
rake lesli:db:setup
Router
Open the Rails routes file at: LesliApp/config/routes.rb
and include the Lesli modules
Rails.application.routes.draw do
mount Lesli::Engine => "/lesli"
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$
INFO
It is possible to add development users, roles, privileges and more; we will explore this options later in the documentation.