Slajd 1 - Mensfeld

Download Report

Transcript Slajd 1 - Mensfeld

Chapter 3.1 – RoR: An introduction
RoR: An introduction
Presented by:
Maciej Mensfeld
senior ruby [email protected]
senior ruby [email protected]
[email protected]
dev.mensfeld.pl
github.com/mensfeld
Maciej Mensfeld
Ruby on Rails: An introduction - Rules
RoR: An introduction
Please…
• …ask me to slow down, if I speak to quickly;
• …ask me again, if I forget;
• …ask questions, if anything i say is not clear;
• …feel free to share your own observations
Maciej Mensfeld
Ruby on Rails: An introduction – Rails what?
RoR: An introduction
Maciej Mensfeld
Ruby on Rails: An introduction – What is Ruby on Rails?
RoR: What is Ruby on Rails?
•Full stack web application
framework
•Written in the Ruby programming
language
•Growing community since 2004
•Open Source and Free
•Focused on developer productivity
and getting the job done – fast!
Maciej Mensfeld
Ruby on Rails: An introduction – What is Ruby on Rails?
RoR: Why Ruby on Rails?
Lot of frameworks exists on the market and a lot of
programming languages for the web but…
Rails
leads
Maciej Mensfeld
Ruby on Rails: An introduction – What is Ruby on Rails?
RoR: Why Ruby on Rails?
•Rails give the developers a real productivity boost for
developing web applications
•Because of Ruby and domain specific languages
•Convention over Configuration
•Productivity boost!
3-4 times
faster than
dev with zend
Really faster?
Maciej Mensfeld
Ruby on Rails: An introduction – What is Ruby on Rails?
RoR: Why Ruby on Rails?
Designed to make it easier to develop, deploy, and maintain
web applications
Design with Model-View-Controller
Also based on DRY concept
Don’t Repeat Yourself (DRY)
Every piece of knowledge should be expressed in just one place
Maciej Mensfeld
Ruby on Rails: An introduction – Who uses RoR?
I do! ;) (but not only…)
and thousands of other…
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
Lil bit bout Rails structure
The Framework
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
Lil bit bout Rails structure
Try it out!
cd ~
rails new my_blog
…
(output):
create
create README
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
…
To much stuff! WTF?!
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
Lil bit bout Rails structure
Fortunately you don’t need
to care about this :)
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
MVC
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
Rails MVC
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
Models ;)
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
ActiveRecord models
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
Fat models, thin controllers
Models should be…
Maciej Mensfeld
Fat! Fat! Fat!!!!
Fat! Fat! Fat!!!!
Fat! Fat! Fat!!!!
Fat! Fat! Fat!!!!
Fat! Fat! Fat!!!!
Ruby on Rails: An introduction – The framework
But… don’t piss off Vegeta ;)
Make fat models and thin
controllers or Vegeta will
visit U…
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
ActionController
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
ActionController – be Restful
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
ActionController – be Restful
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
ActionView
Maciej Mensfeld
Ruby on Rails: An introduction – The framework
ActionView templates
ERB – templates with HTM
and Ruby code – used to
display dinamic stuff from
prepared by controllers
Maciej Mensfeld
Ruby on Rails: An introduction – Example app
Enough theory, let’s start the magic!
Maciej Mensfeld
Ruby on Rails: An introduction – Example app
Generate Rails scaffold…
Try it
out!
Maciej Mensfeld
Ruby on Rails: An introduction – Example app
Start rails server to check if it works
Try it
out!
Go to http://localhost:3000/
Maciej Mensfeld
Ruby on Rails: An introduction – Example app
Yay! It works!
Maciej Mensfeld
Ruby on Rails: An introduction – Example app
Creating Posts
Try it
out!
Maciej Mensfeld
Ruby on Rails: An introduction – Example app
Creating Posts
Try it
out!
Yeah it works but… we can create empty posts :( not good :(
Maciej Mensfeld
Ruby on Rails: An introduction – Example app
Protect create/update/destroy
Try it
out!
Maciej Mensfeld
Our blog works but anyone can add, edit and remove posts…
shitty :/
Ruby: writing some cool stuff
Live long and prosper!
Presented by:
Maciej Mensfeld
[email protected]
dev.mensfeld.pl
github.com/mensfeld
Maciej Mensfeld