bbindex.indd 449 i n e x . i n d d

4 4 9 authentication attachment_fu plugin, 288–296 Atom Feed Helper, 250–253 associations, datahijackingprevention, 178–179 assign method, 233 assert_select, 23–25 method, 26 assert_parse HTML,asserting 23–25 ARTS plugin, 235–236 plug-in, 444 applications, points, starting 2 (applicationprograminterface), tags, 133–134 Apache, Mongrelloadbalancingand, 333–334 alias method, 381 alias keyword, 381 method,alert 233 Ajax, in-placeediting, 34 ago method, 272 after_save method, 173 acts_as_taggable method, 133 acts_as_reviewable plugin, 383–385 method,acts_as_ferret 147 ActiveWebService, 241 ActiveResource, 241–242 ActiveRecord, 158 ActiveCalendar, 270 action caching, 362 ActAsReviewableGenerator class, 398 AATOS (ActsasTaggable OnSteroids), installing, 132 A controller, 72–74 testing, 291–293 images, displaying, 294–296 has_attachment method, 290 forms, 293–294 data setup, 289 creation, 31–34 updates, 245 rails:edge:freeze, 242 find, 244 deletions, 245 copy operations, 245 client script, 243–244 translations and, 279–281 test setup, 407–410 table names, 158 option,:polymorphic 175–176 MySQL and, 356–357 class names, 158 callback feature, 173–174

COPYRIGHTED MATERIAL automation, 103 auto_complete_for method, 229 autocomplete, JavaScript and, 228–229 can_edit_ingredient method, 220 , 445–446 call method, 233 calendars, 270–271 CakePHP, 445 caching, 360–361 C 248 Builder::XmlMarkup, builder templates, XML, 248–249 branches directory, 42 bottlenecks, 338 bots, 80 Bloglines, 241 block helpers, 77 bindings, 368–370 benchmarks, Railsbench, 340–344 Behaviors gem, 205–206 before_save method, 174 before_filter method, 19 BDD (Behavior-Driven Design), 193 B views and, 74–76 using, 76–78 tests, 71–72 routes.rb, 71 deployment dependencies, creating, 324 tags, 134–135 storage, 364 page caching, 361–362 fragment caching, 362–363 expiration, 364 action caching, 362 protection CAPTCHA, 86–94 Proc object, 368 multistage, 325 clustered deployment, 329–333 basic, 316–318 token model, 80–81 controller logic, 83 authorization email, 84–86 Index 11/30/08 4:37:42 PM / 3 0 / 0 8

4 : 3 7 : 4

2 Index

P M Capistrano (continued)

Capistrano (continued) hierarchical databases, 170 installing, 314 indexing, 360 introduction, 313–314 legacy, 156–157 SSH and, 314 relational databases, 170 tasks, 318–320 normalization, 170 writing, 322–323 sessions variables, 320–321 ActiveRecord store, 354–355 CAPTCHA (Completely Automated Public turing test to tell SQLSessionStore, 355–356 Computers and Humans Apart), 86–94 setup, 17 charts tz, 264 RMagick, Gruff, 306–309 date and time, 262 Sparklines, 309–311 ago method, 272 classes date arithmetic, 271–273 ActAsReviewableGenerator, 398 distance_of_time_in_words method, 271 DateTime, 262 DST (daylight savings time), 263 FileList, 112 duration helpers, 271–272 FormBuilder, 64 from_now method, 272 metaprogramming, 373–375 GMT (Greenwich Mean Time), 263 Time, 262 inputting dates, 266 TimeZone, 264 text input, 268–269 TzinfoTimezone, 264 time zones, 266–268 TzTime, 265 JavaScript calendars, 270–271 class_eval method, 370 outputting dates, 271–273 commands string formats, 272–273 generators, 399–400 time zones, 263–266 , 17 time_ago_in_words, 271 revert, 44 timestamps, 263–266 svn commit, 46–47 TimeZone class, 264 svn mkdir, 42 TzinfoTimezone class, 264 svnadmin create, 42 TzTime class, 265 svnserve, 50–52 UTC (Coordinated Universal Time), 263 consuming web services, 257–259 DateTime class, 262 controller object db:abort_if_pending_migrations, 105 before_filter method, 19 db:charset, 106 testing, 19–20 db:collation, 106 controllers db:create, 105 authentication, 72–74 db:create:all, 105 create method, 13–14 db:drop, 105 delete method, 14–15 db:fixtures:identify, 105 edit method, 13 db:fixtures:load, 105 index method, 11–12 db:migrate, 105 new method, 13 db:migrate:redo, 105 show method, 12 db:migrate:reset, 105 update method, 14 db:reset, 105 cookies db:rollback, 105 life cycle, 97–98 db:schema:dump, 105 login, validation, 98–100 db:schema:load, 105 persistent login cookies, 94 db:sessions:clear, 106 persistent login mechanism, 95–97 db:sessions:create, 106 create method, 13–14 db:structure:dump, 105 created_at, 263 db:test:clone, 106 cross-site scripting security, 237–238 db:test:clone_structure, 106 CRUD (Create, Read, Update, Delete), 4 db:test:prepare, 106 CruiseControl.rb, 120–123 db:test:purge, 106 db:version, 106 delete method, 14–15, 238 D deployment, 313 Capistrano and, 313–316 data hijacking, preventing, associations and, 178–179 basic deployment, 316–318 databases hot deployment, 317 downloading, 443 , 326–328 flat databases, 170 basic deployment, 328–329

450

bbindex.inddindex.indd 450450 11/30/08/30/08 4:37:434:37:43 PMPM helpers, testing Index clustered deployment, 329–333 FixtureScenarioBuilder plugin, 206–207 multistage, 325 flat databases, 170 desc method, 112 FlexMock, 187–189 distance_of_time_in_words method, 271 expectations, 191–192 , 446 stubs, 189–191 doc:app, 107 foreign keys, 164 doc:clobber_app, 107 FormBuilder, refactoring forms, 64–67 doc:clobber_plugins, 107 FormBuilder class, 64 doc:clobber_rails, 107 form_for method, 15 doc:plugins, 107 forms doc:rails, 107 attachment_fu plugin, 293–294 doc:reapp, 107 refactoring, FormBuilder, 64–67 doc:rerails, 107 user creation form, 60–64 DOM, elements, selecting, 233 fragment caching, 362–363 downloads frameworks databases, 443 CakePHP, 445 installers, 444 Camping, 445–446 Mongrel, 443 Django, 446 platform notes , 446 , 441 , 446–447 Mac OS X, 441–442 TurboGears, 447 Windows, 442 FreeImage, 286 Rails, 442–443 from_now method, 272 Ruby, 442 Subversion, 443 text editors, 444 G DRY (Don’t Repeat Yourself), 77 DSL (domain-specific language), 112 generators DST (daylight savings time), 263 ActAsReviewableGenerator class, 398 duck punching, 378–385 basic functionality, 396–398 commands, 399–400 manifest method, 398–400 E testing, 400–402 GeneratorTestHelper, 404–406 E text editor, 444 migration templates, 406 Eclipse, 444 writing test, 402–404 Edge Rails, 53–55 GlassFish, 439 rake, 55–56 Globalize plugin, 274–275 edit method, 13 localize method, 275–276 editing, in-place, 34 translations, 276–278 Emacs, 444 displaying, 278–279 encrypted passwords, storing, 67–70 GMT (Greenwich Mean Time), 263 ERB, replacements Google Reader, 241 Haml, 422–427 Grails, 446 Liquid, 427–431 graphics Markaby, 418–421 files, uploading, 288–296 .erb files, 215 library eval method, 368–370 ImageScience, 296–297 :except option, 247 MiniMagick, 303–306 executable files, marking, 46 RMagick, 297–303 graphics packages, RMagick, 286 GraphicsMagick, 285, 286 F Gregorian calendar, 262 Gruff, 306–309 Ferret fields, 148–149 installation, 146–147 search results, 150–151 H FileList class, 112 Haml, 422–427 fixture_file_upload method, 292 has_attachment method, 290 fixtures method, 160–163 helper methods, block helpers, 77 FixtureScenario plugin, 206–207 helpers, testing, 207–209

451

bbindex.inddindex.indd 451451 11/30/08/30/08 4:37:434:37:43 PMPM hide method

hide method, 233 Liquid, 427–431 hierarchical databases, 170 localization, 273 hot deployment, 317 localize method, 275–276 HTML (Hypertext Markup Language), asserting, 23–25 localtime method, 263 Locomotive, 444 log:clear, 109 login I cookies, validation, 98–100 ImageMagick, 285, 286 persistent login cookies, 94 installation persistent login mechanism, 95–97 Mac OS X, 287 logs, performance and, 345–346 Windows, 286 images displaying, attachment_fu, 294–296 M uploading, 288–296 ImageScience, 285 manifest method, 398–400 FreeImage, 286 Markaby graphics library, 296–297 standalone, 420–421 with_image method, 296 template files, 418–420 in-place editing, 34 menus JavaScript and, 226–228 object cache, 130–131 index method, 11–12, 250 single-level, 125–130 indexing database, 360 YAML files, 128 IngredientParser class, 27 Merb, 446–447 ingredient.user method, 221 merge feature of YAML, 156–157 installers, 444 metaprogramming Instant Rails, 444 classes, 373–375 internationalization, 273 duck punching, 378–385 tracking routes, 281–282 introduction, 367 introspection introspection and, 370 metaprogramming and, 370 methods, defining dynamically, 387–389 methods, 371–373 monkey patching, 378–385 objects, 373–375 singletons, 375–378 method timings, ruby-prof, 346–352 J method_eval method, 370 JavaScript method_missing method, 248 autocomplete, 228–229 methods calendars, 270–271 acts_as_ferret, 147 DRY violations, fixing, 213–217 acts_as_taggable, 133 in-place editing, 226–228 after_save, 173 tooltips, 222–226 ago, 272 writing, RJS example, 230–232 alert, 233 JDN (Julian day number), 262 alias, 381 jEdit, 444 assert_parse, 26 JRails, running, 435–437 assign, 233 JRuby on JRails, 431 auto_complete_for, 229 JSON (JavaScript Object Notation), 241 before_filter, 19 producing, 256–257 before_save, 174 Julian day number, 262 call, 233 can_edit_ingredient, 220 class_eval, 370 create, 13–14 L defining dynamically, 387–389 legacy databases, 156–157 delete, 14–15, 238 testing, fixtures method, 160–163 desc, 112 lightboxing, RJS, 234–235 distance_of_time_in_words, 271 link_to method, 15 edit, 13 link_to_remote method, 217, 219 eval, 368–370 link_to_unless_current method, 125 fixture_file_upload, 292

452

bbindex.inddindex.indd 452452 11/30/08/30/08 4:37:444:37:44 PMPM plugins Index fixtures, 160–163 multistage deployment, 325 form_for, 15 MySQL, 17 from_now, 272 has_attachment, 290 index, 11–12, 250 N ingredient.user, 221 introspective, 371–373 nested routes, 9–10 link_to, 15 NetBeans, 444 link_to_remote, 217, 219 network protocols, REST and, 4–5 link_to_unless_current, 125 new method, 13 localize, 275–276 localtime, 263 manifest, 398–400 O method_eval, 370 object cache, menus, 130–131 method_missing, 248 objects, metaprogramming, 373–375 missing, 386–387 OOP (object-oriented programming), REST and, 4 new, 13 paginate, 152 parse, 27 render :xml, 246 P replace_html, 232 page caching, 361–362 respond_to, 11–12 paginate method, 152 returning, 254–255 paginating_find plugin, 153 sanitize, 237 pagination select, 233 paginating_find plugin, 153 show, 12 will_paginate plugin, 152 span_for, 214 parse method, 27 super, 247 parsing, 25–29 time_ago_in_words, 271 passwords, encrypted, storing, 67–70 timestamps, 8 performance time_zone_select, 266–267 fixing problems, 352–353 to_date, 262 logs, 345–346 toggle, 233 measurement, 337 to_time, 262 Railsbench, 338–344 to_xml, 246 session management unit, 28 ActiveRecord store, 354–355 update, 14, 219 cookie-based sessions, 353–354 utc, 263 SQLSessionStore, 355–356 validates_as_attachment, 291 PHP, CakePHP, 445 visual_effect, 233 plugins with_image, 296 ActiveCalendar, 270 zone_names, 267–268 acts_as_reviewable, 383–385 migrations, 7–8 ARTS, 235–236 MiniMagick, 285, 286 attachment_fu, 288–296 graphics library, 303–306 creating, 394–396 installation distributing, 414 Mac OS X, 287 FixtureScenario, 206–207 Windows, 286 FixtureScenarioBuilder, 206–207 missing methods, 386–387 Globalize, 274–275 mock object testing, 187 installing, 391–392 FlexMock, 187–189 listing, 393 expectations, 191–192 paginating_find, 153 stubs, 189–191 rails_rcov, 183–184 Mongrel repositories, 392–394 Apache and, 333–334 Shoulda, 205–206 deployment, 326–328 view_test, 204–205 basic deployment, 328–329 will_paginate, 152 clustered deployment, 329–333 writing downloading, 443 ActiveRecord test setup, 407–410 monkey patching, 378–385 acts_as_reviewable plugin, 410–414

453

bbindex.inddindex.indd 453453 11/30/08/30/08 4:37:444:37:44 PMPM POSIX (Portable Interface) shell, Capistrano and

POSIX (Portable Operating System Interface) shell, log:clear, 109 Capistrano and, 314 notes, 110 Proc object, bindings, 368 notes:fixme, 110 profiling, 350–352 notes:optimize, 110 Prototip, 222–226 notes:todo, 110 Rails in, 116–117 Rails tasks, 109–110 R rails:freeze:edge, 109 rails:freeze:gems, 109 RadRails, 444 rails:unfreeze, 109 Rails, versions, 53–55 rails:update, 110 rake command, 55–56 rails:update:configs, 110 Railsbench, setup, 338–340 rails:update:, 110 rails:edge:freeze, 242 rails:update:scripts, 110 rails:freeze:edge, 109 routes, 110 rails:freeze:gems, 109 stats, 110–111 rails_rcov plugin, 183–184 tasks, 111–112 rails:unfreeze, 109 dependencies, 113–115 rails:update, 110 file tasks, 115–116 rails:update:configs, 110 legacy database testing, 160 rails:update:javascript, 110 testing, 117–119 rails:update:scripts, 110 test, 108 Rake, 103 test:coverage, 185 capabilities of, 104–111 test:coverage:clean, 185 cleanup tasks, 108–109 test:functionals, 108 database tasks, 104–106 testing tasks, 107–108 db:charset, 106 test:integration, 108 db:collation, 106 test:plugins, 108 db:sessions:clear, 106 test:recent, 108 db:sessions:create, 106 test:uncommitted, 108 db:test:clone, 106 test:units, 108 db:test:clone_structure, 106 tmp:cache:clear, 109 db:test:prepare, 106 tmp:clear, 109 db:test:purge, 106 tmp:create, 109 db:version, 106 tmp:pids:clear, 109 management, 106 tmp:sessions:clear, 109 output, 106 tmp:sockets:clear, 109 sessions, 106 rake command, 17 db:abort_if_pending_migrations, 105 Rails version, 55–56 db:create, 105 RDoc, 56–58 db:create:all, 105 rcov db:drop, 105 installing, 183–184 db:fixtures:identify, 105 tasks, 184 db:fixtures:load, 105 RDoc, rake and, 56–58 db:migrate, 105 recipe input form, 22 db:migrate:redo, 105 redirect_to_recipe variable, 221 db:migrate:reset, 105 refactoring forms, FormBuilder, 64–67 db:reset, 105 relational databases, 170 db:rollback, 105 normalization, 170 db:schema:dump, 105 relationships db:schema:load, 105 functionality, 165–166 db:structure:dump, 105 multiple databases, 165–170 doc:app, 107 proxy model, 167 doc:clobber_app, 107 accessors, 168–169 doc:clobber_plugins, 107 remote_edit, 35 doc:clobber_rails, 107 remote_update, 35 doc:plugins, 107 render :xml method, 246 doc:rails, 107 replace_html method, 232 doc:reapp, 107 replacement tools doc:rerails, 107 ERB, 417–431 documentation tasks, 107 JRuby on JRails, 431–439

454

bbindex.inddindex.indd 454454 11/30/08/30/08 4:37:444:37:44 PMPM source control Index repositories customizing, 10–11 adding files, 43–44 display, 16 changes, committing, 46–47 nested, 9–10 checking out files, 43–44 standard, 8–9 commands routes.rb, 8–9 revert, 44 RSpec svn commit, 46–47 loading, 193–194 conflicts, 48–50 writing specs, 194–195 creating, 42–43 controller specifications, 198–199 database files, 45 model tests, 195–197 doc folder, 44 testing helpers, 201–202 executable files, marking, 46 view behavior, specifiying, 199–201 file-level changes, 50 RSS feeds life cycle, 47–50 Atom Feed Helper, 250–253 log folder, 44 channels, 254 plugins, 392–394 generating, 253–255 tmp folder, 44 items, 254 updates, 48–50 producing, 249–255 resources ruby-prof, 346–352 building, 6–16 migrations, 7–8 routes S customizing, 10–11 nested, 9–10 sequences, 67–68 standard, 8–9 sanitize method, 237 respond_to method, 11–12 scripting, security, cross-site, 237–238 JavaScript block, 215 searches REST (REpresentational State Transfer), 1, 241 Ferret and client side, 242–243 fields, 148–149 network protocols and, 4–5 installation, 146–147 OOP and, 4 results, 150–151 pages versus resources, 4 SQL and, 144–146 Rails and, 5–6 security, cross-site scripting, 237–238 reasons for, 6 select method, 233 resources, finding, 243–245 servers, Subversion, setup, 50–52 returning method, 254–255 session management revert command, 44 ActiveRecord store, 354–355 REXML toolkit, 257 cookie-based sessions, 353–354 REXML::Document, 257 SQLSessionStore, 355–356 RJS sessions, 94 lightboxing, 234–235 Shoulda plugin, 205–206 methods, 233 show method, 12, 233 testing single-level menus, 125–130 ARTS plugin, 236 singletons, 375–378 assert_select_rjs, 235–236 SOAP, 241 writing JavaScript, 230–232 Soups OnLine, introduction, 1 RMagick, 285, 286 source control, 39 draw method, 301–302 client-server model, 40 graphics library, 297–303 commands GraphicsMagick and, 286 revert, 44 Gruff, 306–309 svn commit, 46–47 Image class, 298–299 conflicts, 48–50 ImageList, 298 database files, 45 ImageMagick and, 286 doc folder, 44 installation executable files, marking, 46 Linux, 288 file-level changes, 50 Mac OS X, 287–288 log folder, 44 Windows, 286 repositories MiniMagick and, 286 adding files, 43–44 roles, uers, 78–79 checking out files, 43–44 routes committing changes, 46–47

455

bbindex.inddindex.indd 455455 11/30/08/30/08 4:37:454:37:45 PMPM source control (continued)

source control (continued) entering data, 135 creating, 42–43 models, applying to, 133–135 systems, 40 showing detail, 136–137 tmp folder, 44 viewing, 137–139 updates, 48–50 tags directory, 42 spam, 80 task method, 112 CAPTCHA, 86–94 TDD (Test Driven Development), 1, 23, 181 span_for method, 214 process, 181–182 Sparklines, 309–311 Rake testing tasks, 107–108 SQL (Structured Query Language) templates, free online, 29 injection attack, 176–177 test doubles, 187 searches and, 144–146 test:coverage, 185 SQLite3, 17 test:coverage:clean, 185 SSH (Secure Shell), Capistrano and, 314 test:functionals, 108 storage, encrypted passwords, 67–70 testing, 17–18 stubs, 187 assert_select, 23–25 FlexMock, 189–191 behavior of application, 193 Subversion, 41 Behaviors gem, 205–206 changes, committing, 46–47 controller object, 19–20 commands FixtureScenario plugin, 206–207 revert, 44 FixtureScenarioBuilder plugin, 206–207 svn commit, 46–47 generators, 400–402 svn mkdir, 42 GeneratorTestHelper, 404–406 svnadmin create, 42 migration templates, 406 conflicts, 48–50 writing test, 402–404 database files, 45 helpers, 207–209 directories legacy databases, fixtures method, 160–163 branches, 42 mock object testing, 187 tags, 42 FlexMock, 187–189 trunk, 42 rcov doc folder, 44 installing, 183–184 downloading, 443 tasks, 184 executable files, marking, 46 RJS, 235–236 file-level changes, 50 Shoulda plugin, 205–206 log folder, 44 state of application, 193 plugin installation and, 392 stubs, 187 repositories FlexMock, 189–191 adding files, 43–44 TDD, 181 checking out files, 43–44 test object, 18–19 creating, 42–43 turn and, 21–22 server, setup, 50–52 views, 20–22 tmp folder, 44 Test::Rails, 202–204 updates, 48–50 view_test plugin, 204–205 working copies, 41 ZenTest, 202–203 subversive control, introduction, 39 ZenTest, 119–120 super method, 247 test:integration, 108 svn commit command, 46–47 test:plugins, 108 svn mkdir command, 42 Test::Rails, 202–204 svnadmin create command, 42 test:recent, 108 svnserve command, 50–52 tests, authentication, 71–72 test:uncommitted, 108 Test::Unit, Behaviors gem, 205–206 T test:units, 108 text editors, 444 tagging, AATOS (Acts As Taggable On Steroids), installing, TextMate, 444 132–133 Time class, 262 tags localtime method, 263 API, 133–134 utc method, 263 caching, 134–135 time zones, 263–266 cloud, calculation, 139–142 inputting, 266–268 count display, 143 zone_names method, 267–268

456

bbindex.inddindex.indd 456456 11/30/08/30/08 4:37:454:37:45 PMPM zone_names method Index time_ago_in_words method, 271 UTC (Coordinated Universal Time), 263 timestamps, 263–266 utc method, 263 timestamps method, 8 UTF-8, 274 TimeZone class, 264 time_zone_select method, 266–267 tmp:cache:clear, 109 V tmp:clear, 109 tmp:create, 109 validates_as_attachment method, 291 tmp:pids:clear, 109 vender/plugins directory, 395 tmp:sessions:clear, 109 views tmp:sockets:clear, 109 authentication and, 74–76 to_date method, 262 form_for method, 15 toggle method, 233 link_to method, 15 tools, replacing testing, 20–22 ERB replacements, 417–431 view_test plugin, 204–205 JRuby on JRails, 431–439 Vim, 444 tooltips, JavaScript and, 222–226 visual_effect method, 233 to_time method, 262 to_xml method, 246 overriding, 247 W transactions, 177–179 translations web services, consuming, 257–259 ActiveRecord and, 279–281 websites Globalize plugin, 276–278 www.cookingforengineers.com, 2 displaying, 278–279 www.freecsstemplates.org/preview/canvass, 29 trunk directory, 42 www.freewebtemplates.com, 29 t.string syntax, 8 will_paginate plugin, 152 TurboGears, 447 with_image method, 296 turn, testing and, 21–22 working copies, 41 Twitterific, 241 www.cookingforengineers.com, 2 tz database, 264 www.freewebtemplates.com, 29 tzinfo gem, 264 TzinfoTimezone class, 264 TzTime class, 265 X XML, 241 producing, 246–248 U builder templates, 248–249 Unicode, 274 render :xml method, 246 unit method, 28 to_xml, 246 unit tests, quality, 183 update method, 14, 219 update_attributes, 188 Y updated_at, 263 user creation form, 60–64 YAML, producing, 256–257 user interface, tags and YAML files cloud calculation, 139–142 menus, 128 count display, 143 merge feature, 156–157 entering data, 135 object cache, 130–131 showing detail, 136–137 viewing, 137–139 users Z creating, introduction, 59–60 definition of, 60 ZenTest, 119–120 roles, 78–79 zone_names method, 267–268

457

bbindex.inddindex.indd 457457 11/30/08/30/08 4:37:454:37:45 PMPM