Skip to content

treinalinux/blog

Repository files navigation

Project blog

This README is not finished yet, it will soon be finished.

Create Project

rails new blog -d postgresql --skip-turbolinks

Config bootstrap on Rails 6

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


Config database postgresql remoto

vim config/database.yml
  default: &default
  adapter: postgresql
  encoding: unicode
  username: postgres
  host: 192.168.0.189

Create database

- 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published