#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
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) |
has_many :ratings, foreign_key: :dog_id | |
belongs_to :owner, class_name: "Person" |
#Object Oriented Javascript
#Overview
new Object();
this
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!!!'); | |
}; |
#Building APIs
#Overview
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' |
<!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> |