Slide 1

Slide 1 text

Ruby Rails ON Monday, February 20, 12

Slide 2

Slide 2 text

About Me Mike Skalnik github.com/skalnik @skalnik Monday, February 20, 12

Slide 3

Slide 3 text

So what is Ruby Rails ON ? Monday, February 20, 12

Slide 4

Slide 4 text

Rails is a web framework Monday, February 20, 12 A full stack framework for creating database backed web apps

Slide 5

Slide 5 text

Rails is a kitchen sink Monday, February 20, 12 Tries to include all the things you need

Slide 6

Slide 6 text

Rails is MVC* *kinda Monday, February 20, 12 Rails is actually Model2

Slide 7

Slide 7 text

Rails is not a silver bullet Monday, February 20, 12 Rails makes it easy to make a web application quickly. A fantastic starting place. *Agile*

Slide 8

Slide 8 text

Rails is opinionated Monday, February 20, 12

Slide 9

Slide 9 text

Rails is opinionated Monday, February 20, 12 * Reaching for copy & paste? DON’T! * Defaults should be good enough. Ready to go out of the `rails new` * If at all possible, simplify the problem and scope * Don’t code more than you need *right now*, you aren’t gonna need it

Slide 10

Slide 10 text

•Don’t Repeat Yourself (DRY) Rails is opinionated Monday, February 20, 12 * Reaching for copy & paste? DON’T! * Defaults should be good enough. Ready to go out of the `rails new` * If at all possible, simplify the problem and scope * Don’t code more than you need *right now*, you aren’t gonna need it

Slide 11

Slide 11 text

•Don’t Repeat Yourself (DRY) •Convention over Configuration Rails is opinionated Monday, February 20, 12 * Reaching for copy & paste? DON’T! * Defaults should be good enough. Ready to go out of the `rails new` * If at all possible, simplify the problem and scope * Don’t code more than you need *right now*, you aren’t gonna need it

Slide 12

Slide 12 text

•Don’t Repeat Yourself (DRY) •Convention over Configuration •Keep It Simple Stupid Rails is opinionated Monday, February 20, 12 * Reaching for copy & paste? DON’T! * Defaults should be good enough. Ready to go out of the `rails new` * If at all possible, simplify the problem and scope * Don’t code more than you need *right now*, you aren’t gonna need it

Slide 13

Slide 13 text

•Don’t Repeat Yourself (DRY) •Convention over Configuration •Keep It Simple Stupid •You Aren’t Gonna Need It Rails is opinionated Monday, February 20, 12 * Reaching for copy & paste? DON’T! * Defaults should be good enough. Ready to go out of the `rails new` * If at all possible, simplify the problem and scope * Don’t code more than you need *right now*, you aren’t gonna need it

Slide 14

Slide 14 text

Rails has Monday, February 20, 12 * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD

Slide 15

Slide 15 text

Rails has •An Object Relational Mapper Monday, February 20, 12 * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD

Slide 16

Slide 16 text

Rails has •An Object Relational Mapper •A Templating Engine Monday, February 20, 12 * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD

Slide 17

Slide 17 text

Rails has •An Object Relational Mapper •A Templating Engine •Web Application Conventions Monday, February 20, 12 * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD

Slide 18

Slide 18 text

Rails has •An Object Relational Mapper •A Templating Engine •Web Application Conventions •An internal Ruby DSL Monday, February 20, 12 * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD

Slide 19

Slide 19 text

Rails has •An Object Relational Mapper •A Templating Engine •Web Application Conventions •An internal Ruby DSL •Testing built in Monday, February 20, 12 * ActiveRecord * ActionView (Part of ActionPack) * ActionController (Also ActionPack) * Beautify of Ruby allows for very expressive specific code * Encourages TDD

Slide 20

Slide 20 text

Lets chat about MVC Monday, February 20, 12 What do you guys know about MVC? Technically Model2

Slide 21

Slide 21 text

Model “Models” the nouns in your application Responsible for behavior & data The posts, comments, and authors Monday, February 20, 12

Slide 22

Slide 22 text

View Displays information passed to it HTML, XML, or even complex JSON Templated with erb, builder, slim Monday, February 20, 12

Slide 23

Slide 23 text

Controller Controls relationship between Model & View Monday, February 20, 12

Slide 24

Slide 24 text

Controller Browser View Model Monday, February 20, 12 Browser sends request which controller sees Controller coordinates with Model Passes values to view View renders values and sends to browser Terminal time!

Slide 25

Slide 25 text

$ terminal_time Monday, February 20, 12

Slide 26

Slide 26 text

ActiveRecord “An object that wraps a row in a database table” Monday, February 20, 12 Based on Martin Fowler’s Active Record

Slide 27

Slide 27 text

Responsible 1.persistence 2.database access 3.behavior for Monday, February 20, 12

Slide 28

Slide 28 text

Usage Create create, new Read find, find_by_ Update save, update_attributes Delete destroy Monday, February 20, 12 Create instantiates and saves, new only instantiates find_by_attr

Slide 29

Slide 29 text

$ terminal_time Monday, February 20, 12

Slide 30

Slide 30 text

Action Controller get and show vs. do and redirect Monday, February 20, 12

Slide 31

Slide 31 text

Usage Pass to view as @var redirect_to render Monday, February 20, 12 redirect_to sends a 301 and redirects to different action render just renders that actions view

Slide 32

Slide 32 text

$ terminal_time Monday, February 20, 12

Slide 33

Slide 33 text

View Has access to @variables We’ll just stick to ERB Monday, February 20, 12

Slide 34

Slide 34 text

ERB <% %> Evaluate <%= %> Evaluate & Print <%- %> Evaluate & Eat Whitespace Monday, February 20, 12

Slide 35

Slide 35 text

$ terminal_time Monday, February 20, 12

Slide 36

Slide 36 text

So what do you think? Monday, February 20, 12

Slide 37

Slide 37 text

@ Web Tech Innovators Monday, February 20, 12

Slide 38

Slide 38 text

ATLRUG Monday, February 20, 12