code for startup mvp (ruby on rails) session 1

16
Learning to Code for Startup MVP Presented by Henry Shi

Upload: henry-s

Post on 20-Aug-2015

424 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Code for Startup MVP (Ruby on Rails) Session 1

Learning to Code for Startup MVP

Presented by Henry Shi

Page 2: Code for Startup MVP (Ruby on Rails) Session 1

Agenda – Wednesday November 7

1. Review of Last Session

2. Ruby Basicso Syntax and semanticso Syntax and semantics

o Practice makes perfect

1. Rails Models (but no Bottles)o ORM and SQL introduction

o Migrations

o Making the User model

o Signup/Signin/Signout

Page 3: Code for Startup MVP (Ruby on Rails) Session 1

Prework – Setup

• Windows (not recommended if possible):o http://railsinstaller.org/

o Use Sublime Text for your text editor

• OSX:• OSX:o http://railsinstaller.org/

o This includes osx-gcc-installer (200mb)

• Linux:o http://blog.sudobits.com/2012/05/02/how-to-install-

ruby-on-rails-in-ubuntu-12-04-lts/

Page 4: Code for Startup MVP (Ruby on Rails) Session 1

Prework - Git

Install git if not already included:

http://www.git-scm.com/book/en/Getting-

Started-Installing-Git

Configure Git:

git config --global user.name "Your Name“

git config --global user.email

[email protected]

Page 5: Code for Startup MVP (Ruby on Rails) Session 1

Review of Last Session

1. The Web and How it Works

2. Git/Github

3. Rails and Ruby

4. Heroku

Page 6: Code for Startup MVP (Ruby on Rails) Session 1

The Web - Overview

Page 7: Code for Startup MVP (Ruby on Rails) Session 1

GIT/GITHUB

• What is GIT?

• Distributed Version Control System (DVCS)

• Why should I care?• Why should I care?o Never lose data or accidentally overwrite, delete files

o Collaborate with peers anywhere and stay in sync

automatically (no more _v1, _v2, _final, _final_final…)

o Compare and track changes over time, and easily

revert changes

o Deploy code to real web

Page 8: Code for Startup MVP (Ruby on Rails) Session 1

Rails

• Ruby on Rails is an open-source web

framework that’s optimized for programmerhappiness and sustainable productivity.

• It lets you write beautiful code by favoring

convention over configuration.

• 80/20 Rule =>great for Startup MVP

Page 9: Code for Startup MVP (Ruby on Rails) Session 1

Heroku

What is Heroku?

• a hosted platform built specifically for

deploying Rails and other web applications in

1 command1 command

• Best thing since sliced bread

Page 10: Code for Startup MVP (Ruby on Rails) Session 1

Ruby – Programmer’s Best Friend

• Ruby is a dynamic, open source

programming language with a focus on

simplicity and productivity. It has an

elegant syntax that is natural to read and elegant syntax that is natural to read and

easy to write.

• We will only cover the necessary syntax

needed to create a rails app

• Thankfully, its not a lot ☺

Page 11: Code for Startup MVP (Ruby on Rails) Session 1

Interactive Ruby Shell

• For the following slides, you should follow

along with the Interactive Ruby Shell (irb)

• Open a terminal, type irb and press enter• Open a terminal, type irb and press enter

Page 12: Code for Startup MVP (Ruby on Rails) Session 1

Ruby - Strings

• Characters (letters, digits, punctuation)

surrounded by quotes

food = "chunky bacon"

puts "I'm hungry for, #{food}!">> "I'm hungry for, chunky bacon!"

• Can perform operations on strings,

concatenation, length, empty, etc

>> "I'm hungry for, chunky bacon!"

“Hello” + “World”>> “Hello World"

“Henry”.empty?>> false

Page 13: Code for Startup MVP (Ruby on Rails) Session 1

Ruby - Numbers

• Self Explanatory

123.class>> Fixnum

(123.0).class>> Float

• Can add different types of numbers directly

Page 14: Code for Startup MVP (Ruby on Rails) Session 1

Ruby - Symbols

• Characters (letters, digits, punctuation)

preceded by colon (:)

food = :hello

:asf3fasdf.class>> Symbol

• Lightweight strings

• immutable

>> Symbol

Page 15: Code for Startup MVP (Ruby on Rails) Session 1

Ruby - Array

• List surrounded by square brace and

separated by commas, zero indexed

a = [1, 2, 3]

b = ('a'..'e').to_a # ["a", "b", "c", "d", "e"]

c = %w[foo bar baz quux] # ["foo", "bar", "baz", "quux"]

• Can perform operations on arrays, add,

remove, reverse etc

Page 16: Code for Startup MVP (Ruby on Rails) Session 1

ERROR: undefined

OFFENDING COMMAND: f‘~

STACK: