- Page 1 and 2:
Ruby on Rails 101
- Page 3 and 4:
Agenda Monday Tuesday Wednesday Thu
- Page 5 and 6:
Kung-Fu? “Ruby o
- Page 7 and 8:
Rails background • Jason Fried +
- Page 9 and 10:
Rails Philosophy and Strengths •
- Page 11 and 12:
MVC Request Cycle 1. A request is m
- Page 13 and 14:
Directory Structure app controllers
- Page 15 and 16:
Useful Rake Tasks • db:migrate
- Page 17 and 18:
Environments • Every environment
- Page 19 and 20:
• raise @object.inspect Debugging
- Page 21 and 22:
“I always thought Smalltalk would
- Page 23 and 24:
Everything in Ruby
- Page 25 and 26:
Defining a class and Instantiating
- Page 27 and 28:
Getter- and Settter Methods class P
- Page 29 and 30:
Variable/Method Ambiguity Gotcha cl
- Page 31 and 32:
Defining Class Methods class Person
- Page 33 and 34:
Naming Conventions • MyClass •
- Page 35 and 36:
assignment • a, b = b, a # swappi
- Page 37 and 38:
modules # Mixins - instead of multi
- Page 39 and 40:
Everything is an object • 2 + 2 i
- Page 41 and 42:
Introspection andreas = Person.new(
- Page 43 and 44:
String class “ruby”.upcase +
- Page 45 and 46:
hash class h = {:lang => ‘<strong
- Page 47 and 48:
More About methods • Arbitrary nu
- Page 49 and 50:
Structs Rating = Struct.new(:name,
- Page 51 and 52:
Iterators: while, until, and for. K
- Page 53 and 54:
locks, closures, and proc objects d
- Page 55 and 56:
common string operations “ “.bl
- Page 57 and 58:
egular expressions puts “matches
- Page 59 and 60:
invoking external programs system(
- Page 61 and 62:
Ruby on the Comman
- Page 63 and 64:
Core Classes are Also Open class In
- Page 65 and 66:
Using the VCR vcr = VCR.new vcr.gsu
- Page 67 and 68:
eval, binding def evaluate_code(cod
- Page 69 and 70:
class Person def add_method(method)
- Page 71 and 72:
Object Space ObjectSpace.each_objec
- Page 73 and 74:
System Hooks: Class#inherited class
- Page 75 and 76:
Migrations 75
- Page 77 and 78:
Migrations: Managing Tables and Col
- Page 79 and 80:
Two Special Columns created_at and
- Page 81 and 82:
Let’s Bring Sexy Back # Note: thi
- Page 83 and 84:
Fundamentals • One database table
- Page 85 and 86:
CRUD • Create: create, new • Re
- Page 87 and 88:
if user.save # All is ok else # Cou
- Page 89 and 90:
Column/Attribute Data Types MySQL <
- Page 91 and 92:
Default Attribute Values class User
- Page 93 and 94:
find • User.find(:first) # => Use
- Page 95 and 96:
Power Find with Additional Attribut
- Page 97 and 98:
Like Clauses # Like this User.find(
- Page 99 and 100:
RecordNotFound Exception User.exist
- Page 101 and 102:
order = Order.find(12) order.name =
- Page 103 and 104:
Locking # SELECT * FROM accounts WH
- Page 105 and 106:
Destroy Class Methods def destroy(i
- Page 107 and 108:
Calculations Person.minimum(‘age
- Page 109 and 110:
Virtual Attributes # Virtual attrib
- Page 111 and 112:
Composite Attributes class Name att
- Page 113 and 114:
Chad Fowler Says ActiveRecord is an
- Page 115 and 116:
Controllers • Controllers are <st
- Page 117 and 118:
equest.env SERVER_NAME = localhost
- Page 119 and 120:
Render examples • render :text =>
- Page 121 and 122:
Cookies • A hash stored by the br
- Page 123 and 124:
Configuring Sessions • session :o
- Page 125 and 126:
Best Practice • Don’t put SQL a
- Page 127 and 128:
What is ActionView? • ActionView
- Page 129 and 130:
Template Environment • Templates
- Page 131 and 132:
Builder Template Example: RSS xml.i
- Page 133 and 134:
Partials • Partials are templates
- Page 135 and 136:
Passing Variables to Partials • C
- Page 137 and 138:
Layouts • Layouts are templates u
- Page 139 and 140:
Dynamic Layout Selection class Blog
- Page 141 and 142:
Helpers • Helpers are Rub
- Page 143 and 144:
url_helper.rb url_for({:controller
- Page 145 and 146:
Testing 145
- Page 147 and 148:
Test::Unit:TestCase • Test::Unit
- Page 149 and 150:
Unit Test Example require File.dirn
- Page 151 and 152:
Test Data with Fixtures • Fixture
- Page 153 and 154:
Assertions • assert(actual, comme
- Page 155 and 156:
Functional Test Example require Fil
- Page 157 and 158:
assert_select assert_select “p.wa
- Page 159 and 160:
Integration Test Example class Trac
- Page 161 and 162:
Running Tests • rake - runs all t
- Page 163 and 164:
Mocha and Stubba Examples client =
- Page 165 and 166:
cov • rcov is a Ruby</str
- Page 167 and 168:
AJAX and RJS Testing • When you d
- Page 169 and 170:
HTML Validation and Link Checking
- Page 171 and 172:
Test Case Specific Fixtures • Sha
- Page 173 and 174:
RSpec Examples require File.join(Fi
- Page 175 and 176:
class User has_one :weblog end clas
- Page 177 and 178:
elongs_to class LineItem < ActiveRe
- Page 179 and 180:
Methods added by has_many Firm#clie
- Page 181 and 182:
has_and_belongs_to_many # Requires
- Page 183 and 184:
Join Model with Conditions class Ar
- Page 185 and 186:
Polymorphic Associations create_tab
- Page 187 and 188:
Single Table Inheritance: Class Hie
- Page 189 and 190:
Acts As List class Parent < ActiveR
- Page 191 and 192:
Acts As Tree create_table :categori
- Page 193 and 194:
Eager Loading: From N+1 to 1 Query
- Page 195 and 196:
Association Callbacks class Project
- Page 197 and 198:
Validation • Validations are rule
- Page 199 and 200:
Validation Errors class Person < Ac
- Page 201 and 202:
Validation Macros: Usage class User
- Page 203 and 204:
Callback Sequence create update des
- Page 205 and 206:
efore_save Example class User < Act
- Page 207 and 208:
Observers class AuditObserver < Act
- Page 209 and 210:
ActionView Forms 209
- Page 211 and 212:
form_for - Wrapping Model Objects
- Page 213 and 214:
Processing Multiple Object Form Sub
- Page 215 and 216:
Select Boxes "name") form.collec
- Page 217 and 218:
date_helper.rb distance_of_time_in_
- Page 219 and 220:
form_tag_helper.rb - Working with N
- Page 221 and 222:
There is a Better Way: attachment_f
- Page 223 and 224:
Styling Error Messages Customize th
- Page 225 and 226:
Filters • Typically used to imple
- Page 227 and 228:
Filter Blocks and Classes around_fi
- Page 229 and 230:
Verification verify :only => :post_
- Page 231 and 232:
Caching • Rails provides three ty
- Page 233 and 234:
Cache Storage • Can store fragmen
- Page 235 and 236:
Cache Sweeper Declaration class Con
- Page 237 and 238:
Fragment Cache Storage • Fragment
- Page 239 and 240:
AJAX - Introduction • AJAX stands
- Page 241 and 242:
ActionView::Helpers:: PrototypeHelp
- Page 243 and 244:
ActionView::Helpers:: JavaScriptMac
- Page 245 and 246:
RJS • RJS is a Rails Ruby
- Page 247 and 248:
Example: Posting a Comment: The Con
- Page 249 and 250:
Options for Remote Links and Forms
- Page 251 and 252:
Options for Updating the Page • I
- Page 253 and 254:
Example: An AJAX Shopping Cart # In
- Page 255 and 256:
Observing Forms "search"}, {:id =>
- Page 257 and 258:
Options for Observers :url - url_fo
- Page 259 and 260:
The Spinner Icon module Application
- Page 261 and 262:
Drag and Drop Example: The Response
- Page 263 and 264:
Autocompletion: Example # In text f
- Page 265 and 266:
Global AJAX Hooks # In public/javas
- Page 267 and 268:
RJS Reuse module ApplicationHelper
- Page 269 and 270:
Routing Going Beyond :controller/:a
- Page 271 and 272:
Anatomy of a Route • map.route_na
- Page 273 and 274: splat params map.connect ‘*anythi
- Page 275 and 276: Routes in the console rs = ActionCo
- Page 277 and 278: REST 277
- Page 279 and 280: Rails Implementation of REST: CRUD
- Page 281 and 282: map.resources :articles Method URL
- Page 283 and 284: The Accept Header and Extensions #
- Page 285 and 286: Nested Resources # Nested resources
- Page 287 and 288: Consuming REST # You can any HTTP c
- Page 289 and 290: ActionMailer 289
- Page 291 and 292: Creating a Mailer # Creates app/mod
- Page 293 and 294: Sending Email StatisticsMailer.deli
- Page 295 and 296: Attachments class ApplicationMailer
- Page 297 and 298: Unit Testing Mailers def setup Acti
- Page 299 and 300: Plugins Introduction • Plugins is
- Page 301 and 302: Creating Plugins • Generate your
- Page 303 and 304: The Rails Module Inclusion Pattern
- Page 305 and 306: ActiveSupport Introduction ActiveSu
- Page 307 and 308: Enumerations groups = posts.group_b
- Page 309 and 310: 20.bytes 20.megabytes 20.seconds 20
- Page 311 and 312: "åäö".size => 6 "åäö".chars.s
- Page 313 and 314: Rails 2.0 • No radical changes, m
- Page 315 and 316: Deployment 315
- Page 317 and 318: FastCGI • FastCGI is a long runni
- Page 319 and 320: Typical Mongrel Architecture • Th
- Page 321 and 322: Mongrel Alternative: LiteSpeed •
- Page 323: How to Use Capistrano gem install -
- Page 327 and 328: Capistrano 2.0 • New homepage at
- Page 329 and 330: Gem Dependencies • It’s a good
- Page 331 and 332: Security • SQL Injection - always
- Page 333 and 334: Performance II • Use Memcached an
- Page 335 and 336: Resources 335
- Page 337 and 338: Videos and Audio • PeepCode.com -
- Page 339 and 340: Applications and Frameworks • Ric
- Page 341: Advice • Go with the flow. Stay o