Upload
bryanbibat
View
495
Download
0
Embed Size (px)
DESCRIPTION
Rails is Easy*
Citation preview
Rails is Easy
Rails is Easy*
Rails is Easy*
*for experienced web developers
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.
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.
And yeah, you'll probably be screwed if you also lied
about installing Rails 4.0.
We need you to focus in the next 2 hours.
Rails is Easy*
History Lesson
2006 – 2009
Rise of Rails
2006 – 2009
Consumer Enterprise
2006 – 2009
Exodus
Graduation
2006 – 2009
Consumer Enterprise
2006
● Easy to Write● Easy to Deploy
2006
● Easy to Write WRONG● Easy to Deploy WRONG
● Templating Language?
● Templating Language?● Programming Language?
● Templating Language?● Programming Language?
● Web Interface?
2006
Easy to Write WRONGand programmers were writing
wrong:
● No structure● Single pages doing many things
● etc.
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
Presentation Layer?Application Layer?
Business Layer?Infrastructure Layer?
2006
2006
All the patterns in the world...
2006
Easy to Write WRONGand programmers were writing
wrong:
● No structure● Single pages doing many things
● etc.
2006
● With structure● Modular
● etc.
2006
● With structure● Modular
● etc.● Too Complicated
XML Everywhere!
2006
● With structure● Modular
● etc.
2006
● With structure● Modular
● etc.● Reasonably Complicated
Best Practicesand
Conventions
Best Practicesand
Conventions
Web Application Structure
web server app server
Web Application Structure
Web Application Structure
MVC Web App Structure
MVC Model 2 Structure
MVC Web App Structure
webserver app server
MVC Web App Structure
app server
MVC Web App Structure
Controller
MVC Web App Structure
Controller
Model
MVC Web App Structure
Controller
Model
MVC Web App Structure
Controller
ModelView
MVC Web App Structure
Controller
ModelView
MVC Web App Structure
Controller
ModelView
MVC Web App Structure
ModelView
Router Controller
MVC Web App Structure
ModelView
Router Controller
MVC Web App Structure
ModelView
Router Controller
MVC Web App Structure
ModelView
Router Controller
MVC Web App Structure
ModelView
Router Controller
/public/
MVC Web App Structure
ModelView
Router Controller
/public//db//config/ database.yml
MVC Web App Structure
ModelView
Router Controller
/public//db//config/ database.yml
/config/routes.rb
MVC Web App Structure
ModelView
Router Controller
/public//db//config/ database.yml
/app/controllers/
/config/routes.rb
MVC Web App Structure
ModelView
Router Controller
/public//db//config/ database.yml
/app/controllers/
/config/routes.rb
/app/models/
MVC Web App Structure
ModelView
Router Controller
/public//db//config/ database.yml
/app/controllers/
/config/routes.rb
/app/models//app/views/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
2013
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
2013
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
Rote Memorization Time!
Getting Started with Rails 4
http://edgeguides.rubyonrails.org/getting_started.html
Hello Rails!
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
controller#action
class#method
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
Getting Up and Running
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
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
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db/migrate//public/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db/migrate//public/
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.
Show
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
When a controller renders a view, all instance variables (e.g. @foo) are
cloned inside the view
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
Validation
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
Updating
Partials
MVC Web App Structure
ModelView
Router Controller
/app/controllers//app/models//app/views//config/routes.rb/config/database.yml/db//public/
Deleting
Congratulations!
Congratulations!
We've barely scratched the surface of Rails.
Congratulations!
Normally this takes 2 days to understand
Congratulations!
Normally this takes 2 days to understand,even more if self-study
What we haven't covered:
What we haven't covered:
● Associations - table joins made simple
What we haven't covered:
● Associations - table joins made simple(?)
What we haven't covered:
● Associations - table joins made simple(?)● Gems - plugins, libraries, and Bundler
What we haven't covered:
● Associations - table joins made simple(?)● Gems - plugins, libraries, and Bundler
● Testing - code that tells you what's broken
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
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
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!!!
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...
What we haven't covered:
Rails Culture
Rails Culture
Rails Culture
● The personalities
Rails Culture
● The personalities● Our attitude towards code
Rails Culture
● The personalities● Our attitude towards code● Our attitude towards work
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?!?!
Cheat Sheets:
http://pragtob.github.io/rails-beginner-cheatsheet/
http://apidock.com