Rails 6: Questions and Answers

(in no particular order)

What are the Rails libraries?

Library

Description

Action Controller

actions

Action Dispatch

routing, params, session, cookies

Active Job

queuing, background jobs

Action Mailer

emails

Active Model

model interfaces

Action Pack

meta-package

includes Controller and Dispatch

Active Record

ORM

Active Support

utilities, core extensions

Action View

templating, rendering

New in Rails 5 and 6

Library

Description

Action Cable

websockets

since Rails 5

Action Mailbox

internal emails

since Rails 6.0

Active Storage

cloud storage

since Rails 5.2

Action Text

rich text editing

since Rails 6.0

When creating a new Rails application, you have the option to skip:

  • Cable

  • Mailbox

  • Mailer

  • Record

  • Storage

  • Text

  • Job?

Cable

Controller

Dispatch

Job

Mailbox

Mailer

Model

Pack

Record

Storage

Support

Text

View

Is it actually possible to use these libraries outside of Rails?

...

What are all those gems in the Gemfile?

Gem

Description

bcrypt

bootsnap

byebug

capybara

image_processing

jbuilder

listen

mysql2

pg

puma

rails

redis

sass-rails

selenium-webdriver

spring

spring-watcher-listen

sqlite3

turbolinks

tzinfo-data

web-console

webdrivers

webpacker

What is Bootsnap, and how does it work?

...

What is Listen, and how does it work?

...

What is Puma, and how does it work?

...

What is Spring, and how does it work?

...

What is Sprockets, and how does it work?

...

What is Turbolinks, and how does it work?

...

Why is there a bin folder, and what is it for?

...

Why is there a vendor folder, and what is it for?

...

What's the difference between all the assets folders?

app/assets

app/javascript

lib/assets

public/assets

How does the asset tree work?

app/assets/config/manifest.js

Why is the config/manifest.js file in app/assets and not config?

Sprockets 4 moves the configuration from config/application.rb to app/assets/config/manifest.js.

Previously, config/application.rb contained:

config.assets.precompile += []

Now app/assets/config/manifest.js contains:

//= link_tree ../images
//= link_directory ../stylesheets .css

What are concerns?

...

If global variables are "bad", what about global helpers?

app/helpers/application_helper.rb

How do credentials/secrets work?

config/credentials.yml.enc

config/master.key

tmp/development_secret.txt

.env

EDITOR="vim --wait" rails credentials:edit

credentials since Rails 5.2

What is @rails/ujs, and how do you use it?

...

How do the meta tags work?

csrf_meta_tags

csp_meta_tags

How does the stylesheet media option work?

media: 'all'

Is there a difference between dependencies and devDependencies?

...