Skip to content

Instantly share code, notes, and snippets.

@mointrantor
mointrantor / LAI
Last active August 29, 2025 09:32
Backfill
['LAI-00025716']

#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

@mointrantor
mointrantor / ar_migrate.rb
Created February 3, 2017 09:54 — forked from icyleaf/ar_migrate.rb
ActiveRecord type of integer (tinyint, smallint, mediumint, int, bigint)
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb
# Maps logical Rails types to MySQL-specific data types.
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
return super unless type.to_s == 'integer'
case limit
when 1; 'tinyint'
when 2; 'smallint'
when 3; 'mediumint'
when nil, 4, 11; 'int(11)' # compatibility with MySQL default
@mointrantor
mointrantor / gist:df01510acfb5962c31e1d2fc5fadbdc8
Last active April 18, 2016 11:28 — forked from sbob909/gist:1886593
Sample Data for Apex Workbook Spring 2012
Merchandise__c[] ml = new List<Merchandise__c>();
Merchandise__c m = new Merchandise__c(Name='Pencils', Description__c='Cool pencils', Price__c=1.5,Total_Inventory__c=1000);
ml.add(m);
Merchandise__c m2 = new Merchandise__c(Name='Notebooks',Description__c='Blue notebooks',Price__c=4.5, Total_Inventory__c=2000);
ml.add(m2);
insert ml;
Invoice_Statement__c inv = new Invoice_Statement__c(Description__c = 'Invoice 1');
insert inv;