Skip to content

saviokmua/adminlte-with-ruby-on-rails

Repository files navigation

AdminLTE 3.2.0 responsive administration template based on

create new Ruby on Rails project

rails new adminlte-rails -j esbuild -c bootstrap

add foreman gem

gem 'foreman', github: 'ddollar/foreman'

after that we can start our project like

./bin/dev

add home controller

rails generate controller home index

and add changes to config/routes.rb

root 'home#index'

add admin-lte, jquery and bootstrap packages

yarn add admin-lte@^3.2.0 jquery
yarn remove bootstrap
yarn add bootstrap@4.6.2

create base admin-lte template

copy body tag from node_modules/admin-lte/starter.html to app/view/layouts/application.html.erb

add css

add below line to app/assets/stylesheets/application.bootstrap.scss

@import 'dist/css/adminlte.css';

add admin-lte images to project

add below line to app/assets/config/manifest.js:

//= link_tree ../../../node_modules/admin-lte/dist/img

and change tags

<img src="dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3" style="opacity: .8">

to

<%= image_tag "dist/img/AdminLTELogo.png",  alt: "AdminLTE Logo", class: "brand-image img-circle elevation-3", style: "opacity: .8" %>

added fontawesome(cdn)

go to https://cdnjs.com/libraries/font-awesome

copy and insert to layout like next:

<head>
    ...
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" integrity="sha512-iecdLmaskl7CVkqkXNQ/ZH/XLlvWZOJyj7Yy7tcenmpD1ypASozpmT/E0iPtmFIB46ZmdtAc9eNBvH0H/ZpiBw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
    ...
</head>

add jQuery and other js

create file app/javascript/add_jquery.js with next content:

import jquery from 'jquery'
window.jQuery = jquery
window.$ = jquery

and add below lines to app/javascript/application.js

import './add_jquery'
import 'admin-lte'

and add below lines to config/initializers/assets.rb

Rails.application.config.assets.paths << Rails.root.join("node_modules/admin-lte/")
Rails.application.config.assets.precompile += %w[dist/css/* dist/js/*.js]

admin lte

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published