week 1 of hackyale ruby on rails course
TRANSCRIPT
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
1/37
www.hackyale.com
# Ruby on rails
Tuesday, January 17, 12
http://www.hackyale.com/http://www.hackyale.com/http://www.hackyale.com/http://www.hackyale.com/ -
8/3/2019 Week 1 of HackYale Ruby on Rails course
2/37
History, IntroductionRAILS AND YOU
Tuesday, January 17, 12
http://www.hackyale.com/http://www.hackyale.com/ -
8/3/2019 Week 1 of HackYale Ruby on Rails course
3/37
WHo are these guys?
BUT FIRST
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
4/37
COURSE INSTRUCTORS
Bay Gross
Junior in Davenport
co-founder @ Amicus
HardlyWork.in, chickentenders, whatsherface...
Charlie Croom
Senior in Sillimanco-founder @ Amicus
Yale Bluebook, whatsherface...
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
5/37
what?
NOW FORRAILS
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
6/37
WHAT IS RAILS?
A web developmentframework for ruby
like jQuery is aframework for Javascript
like Django is framework for Python
remember, ruby isjust a programming language
Created by David Heinemeier Hansson
at 37Signals
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
7/37
WHAT IS A FRAMEWORK?
A framework is a library of common functions
it saves you work, but creates overhead
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
8/37
SO IF RAILS IS A FRAMEWORK...
it lets you buildfast...
but with a cost
bigger codebase
slower execution
specific: bad threading, etc.
Rails is a bunch of pre-defined functions, methods, andstructures, written in ruby, that collectively allows us to developweb applications in ruby faster.
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
9/37
WHAT SPECIFICALLY DOES IT GIVE ME?
common security holes
sessions, cookies
convenient (RESTful) routing
ORM functionality
MVC functionality
streamlined Asset caching
and more...
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
10/37
WHAT MAKES IT SPECIAL?
Convention over Configuration
Dont Repeat Yourself (DRY)
Fast, flexible, dare-I-say agile development
open-source
fantastic community
rubyonrails.org
RailsConf
Meetups, etc.
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
11/37
Stacks on stacks on stacks
OUR WORKINGSTACK
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
12/37
What even is a STACK?
HOLD UP
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
13/37
A set of software subsystems orcomponents needed to deliver a fully
functional solution, e.g. a product orservice.
STACK
LAMP: Linux, apache, mysql, php
LEAP: Linux, Eucalyptus, Appscale, python
to name a few...
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
14/37
OUR STACK
We teach on the edge:
most of this software is < 1 month old
Rails (pre-release)
RVM (fixed yesterday)
Ruby 1.9.3 ( 1.9.2 is OK too)
RubyGems 1.8.14+
GIT
Heroku
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
15/37
from the bottom up
WALK THE STACK
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
16/37
OPERATING SYSTEMS
OSX
Lion, or Snow Leapord
yes, this is important.
remember. Were working on the edge
Windows
lol
Linux
oh cool so your a haxor?
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
17/37
RVM
Ruby Version Manager [ OSX only ]
manage multiple versions of Ruby
manage multiple gem sets and versions of gems
encapsulate your projects
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
18/37
RUBY
Similar to perl
many implementations
we will use the standard
higher level than C
comes pre-installed on OSX, but we will use RVM
plugins come packaged as gems
we use RubyGems to manage these!
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
19/37
RUBYGEMS
install gems
update gems
delete gems
...
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
20/37
RAILS
we know what this is now.
its just another gem!
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
21/37
WEBRICK / APACHE
Servers
use WEBrick locally
use APACHE for production
other common alternatives include nginx
hosts yourserver-side (ie: ruby) code
handles requests
returns generated client-side (ie: html/css/javascript) code
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
22/37
GIT
version control
developed by Linus Torvalds and crew
for version control of Linux!
track changes
collaborate
deploy (this is new + exciting)
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
23/37
HEROKU
Fast deployment
essentially a front-end for Amazon EC2
create & deploy live web applications
using GIT!
Great for testing, small applications, static sites
For real applications, we use EC2 itself
Essentially a cloud server with its own stack
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
24/37
The language, the legend
RUBY
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
25/37
CRASH COURSE
Everything is an object
Everything has methods
literally everything, even numbers
0.zero? #=> true
Emphasis on readability
block statements defined w/o brackets
simba.is_a_lion? #=> conditional methods named witha question mark, trailing parenthesis optional
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
26/37
CONVENTIONS
ClassNames
method_names + variable_names
methods_asking_questions?
slightly_dangerous_methods!
@instance_variables
@@class_variables
$global_variables
VARIOUS_CONSTANTS
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
27/37
FEATURES
Free format scripting language
you can start typing anywhere
no headers, no int main
comments with a #
one statement per line
or use semi colons
everything is true
exceptfalse and nil
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
28/37
0 is true. ZERO, the number, is true.
This will haunt your code.
HOLD UP
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
29/37
OUTPUT
puts()
parenthesis are always optional in ruby functions
puts Hello world
puts Hello + my_planet.to_s
puts Hello #{my_planet}
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
30/37
TYPES
Strings, Modulos (Classes), Arrays, Numerics, Hashes...
Strongly cast
type coercion is easy
10.to_s #=> 10
5.to_i #=> 5
hello.to_sym #=> :hello
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
31/37
SPECIAL TYPES
Symbols
theyre everywhere!
What are they?
have string and integer component...
easy to read, but fast during runtime
:my_symbol
Hashes
built in. So hey, thats cool
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
32/37
HASHES
Keys and Value pairs can be any type!
my_hash = { 5 => 10, hello => 2, world => :stop_it,{:nested_hash => make it stop!} => :inception}
but generally keys should be symbols
{ :name => Raptor, :claws => true }
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
33/37
ITERATION
For loops... dont really exist as expected.
Usually one iterates over an enumerable set
array.each { |element| puts element }
array.map { |el| el.capitalize }
closest thing to a for loop?
(0..10).each { |i| puts i }
note: last statement in iteration is implicit return
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
34/37
ITERATION
#Canalsobedonewithblocks:
array.mapdo|item|
putsitem
end
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
35/37
BANG BANG BABY
The Bang (!) character
Denotes a clobbering method
days.select{ |d| d[0] == T }
days.select!{ |d| d[0] == T }
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
36/37
Practice Ruby by running irb in yourterminal
IRB = Interactive Ruby Shell
TO THE TERMINAL!
Tuesday, January 17, 12
-
8/3/2019 Week 1 of HackYale Ruby on Rails course
37/37
Questions?
[email protected] [ OSX ]
[email protected] [windows]
THATS IT
mailto:[email protected]:[email protected]:[email protected]:[email protected]