A blog to explore new rails features along with unit, functional, and integration testing Link to Live Site
- Front-End
- Styling
- SCSS / sass css
- Bootstrap 4
- Styling
- Back-End
- Framework
- Rails
- Package Management
- NPM
- YARN
- Babel
- Webpack
- faster compilation with Foreman gem
- to Start Foreman running process
foreman start -f Procfile.dev
- to Start Foreman running process
- faster compilation with Foreman gem
- Database
- Postgress
- Deployed On
- Heroku
- Framework
- Testing
- tbd
- Issue #1
- Missing app/assets/javascript/application.js folder/file in Rails 6
- Slow render on compilation of SCSS
- Solution #1
- Medium Blog Post
- use & configure Webpack
yarn add bootstrap@4.3.1 jquery popper.js
- import only styles that are needed, not entire Node folder
- Created
- javascript/stylesheets fodler
- application.scss
@import './bootstrap_custom.scss';
- bootstrap_custom.scss
@import specific components
- javascript/packs
- application.js
import '../stylesheets/application'
import './bootstrap_custom.js'
- bootstrap_custom.js
@import specific components
- application.js
- application.scss
- javascript/stylesheets fodler
- Layouts
- application.html.erb file
<%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
- application.html.erb file
- webpack/environment.js
const webpack = require('webpack') environment.plugins.append( 'Provide', new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', Popper: ['popper.js', 'default'] }) )
- Issue #2
- Deploying PostgreSQL DB to Heroku
- Soution #2
- Research
- Implementation
- in terminal, from app
heroku run rake db:migrate --app APPNAME
- Issue #3
- Connecting PostgreSQL DB with Rails application
- Solution #3
- Research
- Implementation
- in terminal, from app
rails db:setup
- Explanation of Command
- will create development and test databases
- set owner to the user specified
- create “schema_migrations” tables in each
- table is used to record migrations to schemas and data
- Issue #4
- centering horizontal bootstrap4 columns
- Solution #4
- Research
- Implementation
- in partial form
<%= form_for @user, :html => {:class => "form-horizontal center"} do |f| %>...
- in html of form
class="col-auto offset-sm-2"
- Explanation
- uses a flexbox utility to vertically center the contents and changes .col to .col-auto so that your columns only take up as much space as needed.
- html structure
- Explanation
<!-- FIRST --> <div class="container" > <!-- SECOND --> <%= form_for(@article, :html => {class: "form-horizontal center", role: "form" }) do |f| %> <!-- THIRD --> <div class="control-label form-group row" >
Bootstrap 4 Rows (from FreeCodeCamp article)
- They have to be placed in containers.
- They are only used for containing columns.
- The columns have to be children of the row.
- Solution #4
- centering horizontal bootstrap4 columns
- Issue #4
- adding secure passwords for Users
- Solution #4
- ADD METHOD: has_secure_password method in model (user.rb)
- ADD GEM: gem 'bcrypt' in Gemfile
- ADD COLUMN: password_digest attribute in Users table
- How does above mechanism work?
- takes password string that's entered
- creates
one way hash digest
of string, saves to database SALTS
password, adding random data to password- to authenticate users with salted password
- USE METHOD:
resouce.authenticate('password')
to compare passwords in DB
- USE METHOD:
- How does above mechanism work?
- Rubular
- for REGEX, regular expressions
- RubyOnRails, "ActiveModel::SecurePassword::ClassMethods"
- method:
has_secure_password
- method: