Skip to content

Instantly share code, notes, and snippets.


Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

The goal of this cheatsheet is to make it easy to add hand-rolled authentication to any rails app in a series of layers.

First the simplest/core layers, then optional layers depending on which features/functionality you want.

AUTHOR Ira Herman
LANGUAGE/STACK Ruby on Rails Version 4 or 5
View error
vue.runtime.esm.js?2b0e:587 [Vue warn]: Property or method "policy_holder" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See:
found in
---> <PolicyHolder> at src/components/PolicyHolder.vue
<App> at src/App.vue
warn @ vue.runtime.esm.js?2b0e:587
warnNonPresent @ vue.runtime.esm.js?2b0e:1872
get @ vue.runtime.esm.js?2b0e:1914
View vscode_settings.json
"editor.fontSize": 16,
"editor.fontLigatures": true,
"editor.fontFamily": "Fira Code",
"editor.tabSize": 2,
"editor.minimap.enabled": false,
"terminal.integrated.fontSize": 14,
"terminal.integrated.scrollback": 10000,
"git.path": "/usr/bin/git",
"workbench.colorTheme": "Dracula Soft",
esparkman / form_object.rb
Created May 4, 2018
Form Object Example
View form_object.rb
# used to share results from one user to another
# ensures that valid data is supplied and errors out if the parameters are invalid
class BookingFormModel
include ActiveModel::Model
attribute :first_name, :string
attribute :last_name, :string
attribute :stay_duration_days, :integer
def persisted?
View error.txt
NameError: uninitialized constant Datadog
/var/www/apps/legacy_dashboards_staging/releases/20180302190521/config/initializers/datadog_tracer.rb:3:in `<top (required)>'
/var/www/apps/legacy_dashboards_staging/shared/bundle/ruby/2.3.0/gems/railties- `block (2 levels) in <class:Engine>'
/var/www/apps/legacy_dashboards_staging/shared/bundle/ruby/2.3.0/gems/railties- `each'
/var/www/apps/legacy_dashboards_staging/shared/bundle/ruby/2.3.0/gems/railties- `block in <class:Engine>'
/var/www/apps/legacy_dashboards_staging/shared/bundle/ruby/2.3.0/gems/railties- `instance_exec'
/var/www/apps/legacy_dashboards_staging/shared/bundle/ruby/2.3.0/gems/railties- `run'
/var/www/apps/legacy_dashboards_staging/shared/bundle/ruby/2.3.0/gems/railties- `block in run_initializers'
# Your init script
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
# An example hack to log to the console when each text editor is saved.
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
View modal.html.erb
<div class="header">
<div class="header-img" style="background-image: url('/assets/inside.jpg')">
<button data-toggle="modal" data-target=".photos-modal" class="view-photos">View Photos</button>
<div class="modal fade photos-modal" tabindex="-1" role="dialog" data-focus="true" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= @rental.title %></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
View gist:84ec87152f1e578a694edbee23fc20a7
actioncable (5.1.4) lib/action_cable/server/configuration.rb:25:in `pubsub_adapter'
actioncable (5.1.4) lib/action_cable/server/base.rb:76:in `block in pubsub'
/Users/evansparkman/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
actioncable (5.1.4) lib/action_cable/server/base.rb:76:in `pubsub'
actioncable (5.1.4) lib/action_cable/server/broadcasting.rb:46:in `block in broadcast'
activesupport (5.1.4) lib/active_support/notifications.rb:168:in `instrument'
actioncable (5.1.4) lib/action_cable/server/broadcasting.rb:44:in `broadcast'
actioncable (5.1.4) lib/action_cable/server/broadcasting.rb:23:in `broadcast'
View products.js
App.products = App.cable.subscriptions.create("ProductsChannel", {
connected: function() {
// Called when the subscription is ready for use on the server
disconnected: function() {
// Called when the subscription has been terminated by the server
received: function(data) {
You can’t perform that action at this time.