Skip to content

Instantly share code, notes, and snippets.

@iscott
iscott / simple_authentication_rails_5_bcrypt_and_has_secure_password.md
Last active May 22, 2024 08:00
Cheat Sheet: Simple Authentication in Rails 5 with has_secure_password

Cheat Sheet: Simple Authentication in Rails 6 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.

Specs
AUTHOR Ira Herman
LANGUAGE/STACK Ruby on Rails Version 4, 5, or 6
@fabianvf
fabianvf / test.erb
Created April 25, 2016 17:33
How to test erb templates with ruby
<%= conditon ? 'True case' : 'False case' %>)
@robotmay
robotmay / gist:2479149
Created April 24, 2012 12:09
Find the closest date in an array of dates
# I have an array of dates (both past and present) and a single date ('needle' below),
# for which I want to find the closest date in either direction. Here's my solution;
# can you think of a better one?
dates.sort_by { |date| (date.to_time - needle.to_time).abs }.first