30
Ruby on Rails: An introduction - Who am I? Maciej Mensfeld Presented by: Maciej Mensfeld RoR: An introduction [email protected] dev.mensfeld.pl github.com/mensfeld senior ruby [email protected] lead ruby [email protected]

Ruby on Rails : An introduction - Who am I?

  • Upload
    dolph

  • View
    38

  • Download
    0

Embed Size (px)

DESCRIPTION

Ruby on Rails : An introduction - Who am I?. RoR : An introduction . Presented b y :. Maciej Mensfeld. senior ruby [email protected] lead ruby [email protected]. [email protected] dev.mensfeld.pl github.com / mensfeld. Maciej Mensfeld. - PowerPoint PPT Presentation

Citation preview

Page 1: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction - Who am I?

Maciej Mensfeld

Presented by:

Maciej Mensfeld

RoR: An introduction

[email protected]

github.com/mensfeld

senior ruby [email protected] ruby [email protected]

Page 2: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction - Rules

Maciej Mensfeld 2/30

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

RoR: An introduction

Page 3: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – Rails what?

Maciej Mensfeld 3/30

RoR: An introduction

Page 4: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – What is Ruby on Rails?

Maciej Mensfeld 4/30

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!

Page 5: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – What is Ruby on Rails?

Maciej Mensfeld 5/30

RoR: Why Ruby on Rails? Lot of frameworks exists on the market and a lot of

programming languages for the web but…

Rails leads

Page 6: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – What is Ruby on Rails?

Maciej Mensfeld 6/30

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!

Really faster?

3-4 times faster than

dev with zend

Page 7: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – What is Ruby on Rails?

Maciej Mensfeld 7/30

RoR: Why Ruby on Rails?

Designed to make it easier to develop, deploy, and maintain web applications

Design with Model-View-ControllerAlso based on DRY concept

Don’t Repeat Yourself (DRY)Every piece of knowledge should be expressed in just one place

Page 8: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – Who uses RoR?

Maciej Mensfeld 8/30

I do! ;) (but not only…)

and thousands of other…

Page 9: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 9/30

Lil bit bout Rails structure

The Framework

Page 10: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 10/30

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?!

Page 11: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 0

Lil bit bout Rails structure

Fortunately you don’t need to care about this :)

Page 12: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 12/30

MVC

Page 13: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 13/30

Rails MVC

Page 14: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 14/30

Models ;)

Page 15: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 15/30

ActiveRecord models

Page 16: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 16/30

Models should be…

Fat! Fat! Fat!!!!

Fat! Fat! Fat!!!!

Fat! Fat! Fat!!!!

Fat! Fat! Fat!!!!

Fat! Fat! Fat!!!!Fat m

odel

s, th

in c

ontr

olle

rs

Page 17: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 17/30

But… don’t piss off Vegeta ;)

Make fat models and thin controllers or Vegeta will

visit U…

Page 18: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 18/30

ActionController

Page 19: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 19/30

ActionController – be Restful

Page 20: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 20/30

ActionController – be Restful

Page 21: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 21/30

ActionView

Page 22: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – The framework

Maciej Mensfeld 22/30

ActionView templates

ERB – templates with HTM and Ruby code – used to

display dinamic stuff from prepared by controllers

Page 23: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – Example app

Maciej Mensfeld 23/30

Enough theory, let’s start the magic!

Page 24: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – Example app

Maciej Mensfeld 24/30

Generate Rails scaffold…

Try it out!

Page 25: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – Example app

Maciej Mensfeld 25/30

Start rails server to check if it works

Try it out!

Go to http://localhost:3000/

Page 26: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – Example app

Maciej Mensfeld 26/30

Yay! It works!

Page 27: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – Example app

Maciej Mensfeld 27/30

Creating Posts

Try it out!

Page 28: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – Example app

Maciej Mensfeld 28/30

Creating Posts

Try it out!

Yeah it works but… we can create empty posts :( not good :(

Page 29: Ruby on  Rails : An introduction -  Who am  I?

Ruby on Rails: An introduction – Example app

Maciej Mensfeld 29/30

Protect create/update/destroy

Try it out!

Our blog works but anyone can add, edit and remove posts… shitty :/

Page 30: Ruby on  Rails : An introduction -  Who am  I?

Ruby: writing some cool stuff

Maciej Mensfeld 30/30

Live long and prosper!

Presented by:

Maciej Mensfeld

[email protected]

github.com/mensfeld