Skip to content

Instantly share code, notes, and snippets.

@lisaSwanson
lisaSwanson / application.html.erb
Created October 1, 2015 17:27 — forked from stujo/application.html.erb
Page Specific Document Ready JavaScript in Rails with jQuery
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>PizzaShack</title>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tags %>
</head>
<body>
@lisaSwanson
lisaSwanson / 01. Gemfile
Created October 1, 2015 02:24 — forked from schleg/01. Gemfile
Setup for Devise + Omniauth
gem 'pg'
group :development do
gem 'ruby-debug'
end
gem 'rake', '~> 0.8.7'
gem 'devise'
gem 'oa-oauth', :require => 'omniauth/oauth'
gem 'omniauth'
gem 'haml'
gem 'dynamic_form'

#Building APIs

#Overview

  • What is an API?
  • Why build an API?
    • Who is going to use it?
    • What are they going to do?
  • REST Architecture
    • Stateless
  • Resource Representations
function Dinosaur(color){
this.id = Dinosaur.prototype.counter++;
this.dob = Date.now();
this.color = color;
};
Dinosaur.prototype.roar = function(){
console.log('RARWARARRR said the ' + this.color + ' Dinosaur!!!');
};
@lisaSwanson
lisaSwanson / oojs.md
Last active August 29, 2015 14:28 — forked from stujo/oojs.md
Object Oriented Primer for JavaScript

#Object Oriented Javascript

#Overview

  • Creating Objects in JavaScript
    • new Object();
    • Object Literal Notation (Important)
    • Factory Function
  • Review JavaScript's this
  • More Creating Objects in JavaScript
    • Constructor Function
@lisaSwanson
lisaSwanson / gist:9643c14b3c08fd8df649
Created August 13, 2015 23:18
has_many, belongs_to syntax
has_many :ratings, foreign_key: :dog_id
belongs_to :owner, class_name: "Person"
@lisaSwanson
lisaSwanson / gist:b1a0ee1deecae0e17f0d
Last active August 29, 2015 14:27
ActiveRecord Cheat Sheet
From within the console run ...
Dog.all
::all is a class method that returns all of the records in the dogs table as instances of the Dog class. The individual instances are returned within a collection, an ActiveRecord::Relation object that acts much like an array.
Calling Dog::all tells Active Record to generate and execute a SQL query. We can see the SQL that was executed in the console output: SELECT "dogs".* FROM "dogs".
Dog.where(age: 1)