114
Rails is Easy

Rails is Easy*

Embed Size (px)

DESCRIPTION

Rails is Easy*

Citation preview

Page 1: Rails is Easy*

Rails is Easy

Page 2: Rails is Easy*

Rails is Easy*

Page 3: Rails is Easy*

Rails is Easy*

*for experienced web developers

Page 4: Rails is Easy*

The Rails Code Camp is not for complete beginners, each participant must have at least some programming background and

familiarity with model-view-controller architecture.

Page 5: Rails is Easy*

The Rails Code Camp is not for complete beginners, each participant must have at least some programming background and

familiarity with model-view-controller architecture.

We aren't joking.

Page 6: Rails is Easy*

And yeah, you'll probably be screwed if you also lied

about installing Rails 4.0.

Page 7: Rails is Easy*

We need you to focus in the next 2 hours.

Page 8: Rails is Easy*

Rails is Easy*

Page 9: Rails is Easy*

History Lesson

Page 10: Rails is Easy*

2006 – 2009

Rise of Rails

Page 11: Rails is Easy*

2006 – 2009

Consumer Enterprise

Page 12: Rails is Easy*

2006 – 2009

Page 13: Rails is Easy*

Exodus

Page 14: Rails is Easy*

Graduation

Page 15: Rails is Easy*

2006 – 2009

Consumer Enterprise

Page 16: Rails is Easy*

2006

● Easy to Write● Easy to Deploy

Page 17: Rails is Easy*

2006

● Easy to Write WRONG● Easy to Deploy WRONG

Page 18: Rails is Easy*
Page 19: Rails is Easy*

● Templating Language?

Page 20: Rails is Easy*

● Templating Language?● Programming Language?

Page 21: Rails is Easy*

● Templating Language?● Programming Language?

● Web Interface?

Page 22: Rails is Easy*

2006

Easy to Write WRONGand programmers were writing

wrong:

● No structure● Single pages doing many things

● etc.

Page 23: Rails is Easy*

Common Layers in anInformation System Logical Architecturehttp://en.wikipedia.org/wiki/Common_layers_in_an_information_system_logical_architecture

Presentation LayerApplication Layer

Business LayerInfrastructure Layer

Page 24: Rails is Easy*

Presentation Layer?Application Layer?

Business Layer?Infrastructure Layer?

2006

Page 25: Rails is Easy*

2006

Page 26: Rails is Easy*

All the patterns in the world...

Page 27: Rails is Easy*

2006

Easy to Write WRONGand programmers were writing

wrong:

● No structure● Single pages doing many things

● etc.

Page 28: Rails is Easy*

2006

● With structure● Modular

● etc.

Page 29: Rails is Easy*

2006

● With structure● Modular

● etc.● Too Complicated

Page 30: Rails is Easy*

XML Everywhere!

Page 31: Rails is Easy*

2006

● With structure● Modular

● etc.

Page 32: Rails is Easy*

2006

● With structure● Modular

● etc.● Reasonably Complicated

Page 33: Rails is Easy*

Best Practicesand

Conventions

Page 34: Rails is Easy*
Page 35: Rails is Easy*

Best Practicesand

Conventions

Page 36: Rails is Easy*

Web Application Structure

web server app server

Page 37: Rails is Easy*

Web Application Structure

Page 38: Rails is Easy*

Web Application Structure

Page 39: Rails is Easy*

MVC Web App Structure

Page 40: Rails is Easy*

MVC Model 2 Structure

Page 41: Rails is Easy*

MVC Web App Structure

webserver app server

Page 42: Rails is Easy*

MVC Web App Structure

app server

Page 43: Rails is Easy*

MVC Web App Structure

Controller

Page 44: Rails is Easy*

MVC Web App Structure

Controller

Model

Page 45: Rails is Easy*

MVC Web App Structure

Controller

Model

Page 46: Rails is Easy*

MVC Web App Structure

Controller

ModelView

Page 47: Rails is Easy*

MVC Web App Structure

Controller

ModelView

Page 48: Rails is Easy*

MVC Web App Structure

Controller

ModelView

Page 49: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

Page 50: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

Page 51: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

Page 52: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

Page 53: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/public/

Page 54: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/public//db//config/ database.yml

Page 55: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/public//db//config/ database.yml

/config/routes.rb

Page 56: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/public//db//config/ database.yml

/app/controllers/

/config/routes.rb

Page 57: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/public//db//config/ database.yml

/app/controllers/

/config/routes.rb

/app/models/

Page 58: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/public//db//config/ database.yml

/app/controllers/

/config/routes.rb

/app/models//app/views/

Page 59: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 60: Rails is Easy*

2013

Page 61: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 62: Rails is Easy*

2013

Page 63: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 64: Rails is Easy*

Rote Memorization Time!

Page 65: Rails is Easy*

Getting Started with Rails 4

http://edgeguides.rubyonrails.org/getting_started.html

Page 66: Rails is Easy*

Hello Rails!

Page 67: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 68: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 69: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 70: Rails is Easy*

controller#action

class#method

Page 71: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 72: Rails is Easy*

Getting Up and Running

Page 73: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 74: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 75: Rails is Easy*

Representational State Transfer (REST)

Prefix Verb URI Pattern Controller#Action posts GET /posts(.:format) posts#index POST /posts(.:format) posts#create new_post GET /posts/new(.:format) posts#newedit_post GET /posts/:id/edit(.:format) posts#edit post GET /posts/:id(.:format) posts#show PATCH /posts/:id(.:format) posts#update PUT /posts/:id(.:format) posts#update DELETE /posts/:id(.:format) posts#destroy

Page 76: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 77: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 78: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db/migrate//public/

Page 79: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db/migrate//public/

Page 80: Rails is Easy*

ActiveRecord models have, by default, a integer primary key "id" and two timestamps "created_at"

and "updated_at".

All three are automatically managed by ActiveRecord.

Page 81: Rails is Easy*

Show

Page 82: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 83: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 84: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 85: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 86: Rails is Easy*

When a controller renders a view, all instance variables (e.g. @foo) are

cloned inside the view

Page 87: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 88: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 89: Rails is Easy*

Validation

Page 90: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 91: Rails is Easy*

Updating

Page 92: Rails is Easy*

Partials

Page 93: Rails is Easy*

MVC Web App Structure

ModelView

Router Controller

/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/

Page 94: Rails is Easy*

Deleting

Page 95: Rails is Easy*

Congratulations!

Page 96: Rails is Easy*

Congratulations!

We've barely scratched the surface of Rails.

Page 97: Rails is Easy*

Congratulations!

Normally this takes 2 days to understand

Page 98: Rails is Easy*

Congratulations!

Normally this takes 2 days to understand,even more if self-study

Page 99: Rails is Easy*

What we haven't covered:

Page 100: Rails is Easy*

What we haven't covered:

● Associations - table joins made simple

Page 101: Rails is Easy*

What we haven't covered:

● Associations - table joins made simple(?)

Page 102: Rails is Easy*

What we haven't covered:

● Associations - table joins made simple(?)● Gems - plugins, libraries, and Bundler

Page 103: Rails is Easy*

What we haven't covered:

● Associations - table joins made simple(?)● Gems - plugins, libraries, and Bundler

● Testing - code that tells you what's broken

Page 104: Rails is Easy*

What we haven't covered:

● Associations - table joins made simple(?)● Gems - plugins, libraries, and Bundler

● Testing - code that tells you what's broken● Asset Pipeline - serve compressed and up-to-

date assets in production

Page 105: Rails is Easy*

What we haven't covered:

● Associations - table joins made simple(?)● Gems - plugins, libraries, and Bundler

● Testing - code that tells you what's broken● Asset Pipeline - serve compressed and up-to-

date assets in production● Deployment - deploy with only one command

Page 106: Rails is Easy*

What we haven't covered:

● Associations - table joins made simple(?)● Gems - plugins, libraries, and Bundler

● Testing - code that tells you what's broken● Asset Pipeline - serve compressed and up-to-

date assets in production● Deployment - deploy with only one command

● Ruby itself!!!

Page 107: Rails is Easy*

What we haven't covered:

● Associations - table joins made simple(?)● Gems - plugins, libraries, and Bundler

● Testing - code that tells you what's broken● Asset Pipeline - serve compressed and up-to-

date assets in production● Deployment - deploy with only one command

● Ruby itself!!!● and so on...

Page 108: Rails is Easy*

What we haven't covered:

Rails Culture

Page 109: Rails is Easy*

Rails Culture

Page 110: Rails is Easy*

Rails Culture

● The personalities

Page 111: Rails is Easy*

Rails Culture

● The personalities● Our attitude towards code

Page 112: Rails is Easy*

Rails Culture

● The personalities● Our attitude towards code● Our attitude towards work

Page 113: Rails is Easy*

Rails Culture

● The personalities● Our attitude towards code● Our attitude towards work

● How the hell does a "slow" framework that doesn't work well on Windows get such a high

market demand for developers?!?!

Page 114: Rails is Easy*

Cheat Sheets:

http://pragtob.github.io/rails-beginner-cheatsheet/

http://apidock.com