This blog is a quick walkthrough of creating a Ruby On Rails application without a model.
Find Rails new options from here:
Find Gemfile options from here:
Install Ruby/Rails using rbenv
$ touch .rbenv-gemsets $ echo project-name > .rbenv-gemsets $ rbenv gemset active $ rbenv install 2.5.3 $ gem install bundler $ rbenv rehash $ gem install rails -v 5.2.9 $ rbenv rehash $ rails new my-new-porject --skip-active-record --skip-bundle -v 5.2.9
Add in Gemfile:
comment jbuilder, we don’t need it.
# gem 'jbuilder', '~> 2.8’
Move rbenv gems file to new rails app folder
$ mv .rbenv-gemsets my-new-porject $ touch .ruby-version $ echo 2.5.3 > .ruby-version $ gem install bundler $ bundle $ ruby -v ruby 2.5.3p105 (2018-10-18 revision 65156) [x86_64-darwin18]
Start Rails server:
$ rails s
# Bootstrap Theme
gem 'bootstrap', '~> 4.3.0’
# Slim template Engine
gem 'slim', '>=4.0.1’
Do Bundle Install
Rename css to scss because we use bootsrap mixins and variables that work with scss files
$ mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss
Import Bootstrap styles in app/assets/stylesheets/application.scss:
// Custom bootstrap variables must be set or imported *before* bootstrap. @import "bootstrap";
Then, remove all the *= require and *= require_tree statements from the Sass file. Instead, use @import to import Sass files.
Add jquery-rails to Gemfile:
gem 'jquery-rails', '~> 4.3.4’
Bootstrap tooltips and popovers depend on popper.js for positioning.
Add Bootstrap dependencies and Bootstrap to your application.js:
//= require jquery3 //= require popper //= require bootstrap-sprockets
While bootstrap-sprockets provides individual Bootstrap components for ease of debugging, you may alternatively require the concatenated bootstrap for faster compilation:
//= require jquery3 //= require popper //= require bootstrap
Sass: Individual components
All Bootstrap opponents will be imported by default.
You can also import components explicitly. To start with a full list of modules copy _bootstrap.scss file into your assets as _bootstrap-custom.scss. Then comment out components you do not want from _bootstrap-custom. In the application Sass file, replace @import ‘bootstrap’ with:
/* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's * vendor/assets/stylesheets directory can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the bottom of the * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. * */ /*Custom bootstrap variables must be set or imported *before* bootstrap. The available variables can be found: https://github.com/twbs/bootstrap-rubygem/blob/master/assets/stylesheets/bootstrap/_variables.scss */ @import "bootstrap";
Your application.js File:
You can check sample bootstrap forms here: