This README is not finished yet, it will soon be finished.
rails new blog -d postgresql --skip-turbolinks
yarn add bootstrap jquery popper.js
remove folder stylesheets
rm -rf app/assets/stylesheets
vim app/assets/config/manifest.js
remove line:
//= link_directory ../stylesheets .css
vim config/webpack/environment.js
const { environment } = require('@rails/webpacker')
const webpack = require('webpack')
// Add an additional plugin of your choosing : ProvidePlugin
environment.plugins.prepend(
'Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
jquery: 'jquery',
'window.Tether': 'tether',
Popper: ['popper.js', 'default']
})
)
module.exports = environment
vim app/javascript/packs/application.js
import "bootstrap"
import "../src/application.css"
mkdir app/javascript/src
vim app/javascript/src/application.css
@import 'bootstrap';
Change stylesheet_link_tag for stylesheet_pack_tag
vim app/views/layouts/application.html.erb
# Change:
<%= stylesheet_link_tag 'application', media: 'all' %>
# For:
<%= stylesheet_pack_tag 'application', media: 'all' %>
# Create div container and insert yield
<div class='container'>
<%= yield %>
</div>
vim config/webpacker.yml
# extract_css: false
extract_css: true
Done, end config bootstrap on Rails 6
vim config/database.yml
default: &default
adapter: postgresql
encoding: unicode
username: postgres
host: 192.168.0.189
- rails db:create
- rails generate scaffold post title:string author:string body:text
- rails generate model comment post:references author body:text
- rails db:migrate