Skip to content

Instantly share code, notes, and snippets.

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@kianinyvr
kianinyvr / person.rb
Created July 4, 2017 01:04
Using attr_accessor in Ruby Class
class Person
attr_accessor :name
def initialize(name)
@name = name
end
end
p = Person.new('L. Ron')
puts p.name
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
var words = process.argv.slice(2);
// console.log(words);
var wordsInLatin = new Array;
for( var i = 0;i < words.length; i++){
wordsInLatin.push(Latinize(words[i]));
}
function printInFrame(list) {
var list = list.split(' ');
// console.log("List split" , list );
var longest = longestStr(list).length;
var border = repeat('*', longest + 3);
console.log(border);
for (word of list) {
console.log('* ' + word + repeat(' ', longest - word.length) + '*');
}
function isPalindrome(str) {
var noSpaces = str.split(" ").join("");
noSpaces = noSpaces.toLowerCase();
var mid = Math.floor(noSpaces.length/2);
var last = noSpaces.length - 1;
function average(list) {
var sum = 0;
for (var num of list) {
sum += num;
}
return sum / list.length;
};
function average(list) {
var sum = 0;
for (var num of list) {
sum += num;
}
return sum / list.length;
};
var a = process.argv.slice(2);
var rolls = Number(a[0]);
var string = new Array;
function rollDice(rolls){
for(var i = 0; i < rolls; i++){