This repository has been archived by the owner on Jan 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
3_0_release_notes.html
689 lines (656 loc) · 53.6 KB
/
3_0_release_notes.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Ruby on Rails Guides: Ruby on Rails 3.0 Release Notes</title>
<link rel="stylesheet" type="text/css" href="stylesheets/style.css" />
<link rel="stylesheet" type="text/css" href="stylesheets/print.css" media="print" />
<link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shCore.css" />
<link rel="stylesheet" type="text/css" href="stylesheets/syntaxhighlighter/shThemeRailsGuides.css" />
</head>
<body class="guide">
<div id="topNav">
<div class="wrapper">
<strong>More at <a href="http://rubyonrails.org/">rubyonrails.org:</a> </strong>
<a href="http://rubyonrails.org/">Overview</a> |
<a href="http://rubyonrails.org/download">Download</a> |
<a href="http://rubyonrails.org/deploy">Deploy</a> |
<a href="http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/overview">Code</a> |
<a href="http://rubyonrails.org/screencasts">Screencasts</a> |
<a href="http://rubyonrails.org/documentation">Documentation</a> |
<a href="http://rubyonrails.org/ecosystem">Ecosystem</a> |
<a href="http://rubyonrails.org/community">Community</a> |
<a href="http://weblog.rubyonrails.org/">Blog</a>
</div>
</div>
<div id="header">
<div class="wrapper clearfix">
<h1><a href="index.html" title="Return to home page">Guides.rubyonrails.org</a></h1>
<p class="hide"><a href="#mainCol">Skip navigation</a>.</p>
<ul class="nav">
<li><a href="index.html">홈</a></li>
<li class="index"><a href="index.html" onclick="guideMenu(); return false;" id="guidesMenu">목차</a>
<div id="guides" class="clearfix" style="display: none;">
<hr />
<dl class="L">
<dt>시작</dt>
<dd><a href="getting_started.html">레일즈 시작하기</a></dd>
<dt>모델(Models)</dt>
<dd><a href="migrations.html">레일즈 데이터베이스 마이그레이션</a></dd>
<dd><a href="active_record_validations_callbacks.html">액티브 레코드 데이터 검증(Validation)과 Callback(콜백)</a></dd>
<dd><a href="association_basics.html">액티브 레코드 Association(관계)</a></dd>
<dd><a href="active_record_querying.html">액티브 레코드 쿼리 인터페이스</a></dd>
<dt>뷰(Views)</dt>
<dd><a href="layouts_and_rendering.html">레이아웃(Layouts)과 렌더링(Rendering)</a></dd>
<dd><a href="form_helpers.html">액션 뷰 폼 핼퍼(Action View Form Helpers)</a></dd>
<dt>컨트롤러(Controllers)</dt>
<dd><a href="action_controller_overview.html">액션 컨트롤러 둘러보기</a></dd>
<dd><a href="routing.html">외부 요청에 대한 레일즈 라우팅</a></dd>
</dl>
<dl class="R">
<dt>심화내용</dt>
<dd><a href="active_support_core_extensions.html">액티브 서포트(Active Support) 확장(Core Extensions)</a></dd>
<dd><a href="i18n.html">레일즈 국제화I(nternationalization) API</a></dd>
<dd><a href="action_mailer_basics.html">액션 메일러의 기본</a></dd>
<dd><a href="testing.html">레일즈 어플리케이션 테스트하기</a></dd>
<dd><a href="security.html">레일즈 어플리케이션의 보안</a></dd>
<dd><a href="debugging_rails_applications.html">레일즈 어플리케이션 디버깅</a></dd>
<dd><a href="performance_testing.html">레일즈 어플리케이션 성능 테스트하기</a></dd>
<dd><a href="configuring.html">레일즈 어플리케이션 설정</a></dd>
<dd><a href="command_line.html">레일즈 커멘드라인 도구와 Rake 테스크</a></dd>
<dd><a href="caching_with_rails.html">레일즈를 이용한 캐싱</a></dd>
<dt>레일즈 확장하기(Extending Rails)</dt>
<dd><a href="plugins.html">레일즈 플러그인 작성의 기본</a></dd>
<dd><a href="rails_on_rack.html">렉 위의 레일즈(Rails on Rack)</a></dd>
<dd><a href="generators.html">레일즈 제너레이터(Generator) 제작과 수정</a></dd>
<dt>루비 온 레이즈에 기여하기</dt>
<dd><a href="contributing_to_ruby_on_rails.html">루비 온 레이즈에 기여하기</a></dd>
<dd><a href="api_documentation_guidelines.html">API 문서 가이드라인</a></dd>
<dd><a href="ruby_on_rails_guides_guidelines.html">루비 온 레일즈 가이드에 대한 가이드라인</a></dd>
<dt>Release Notes</dt>
<dd><a href="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</a></dd>
<dd><a href="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</a></dd>
<dd><a href="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</a></dd>
</dl>
</div>
</li>
<li><a href="contribute.html">기여하기</a></li>
<li><a href="credits.html">수고하신 분들</a></li>
</ul>
</div>
</div>
<hr class="hide" />
<div id="feature">
<div class="wrapper">
<h2>Ruby on Rails 3.0 Release Notes</h2>
<p>Rails 3.0 is ponies and rainbows! It’s going to cook you dinner and fold your laundry. You’re going to wonder how life was ever possible before it arrived. It’s the Best Version of Rails We’ve Ever Done!</p>
<p>But seriously now, it’s really good stuff. There are all the good ideas brought over from when the Merb team joined the party and brought a focus on framework agnosticism, slimmer and faster internals, and a handful of tasty APIs. If you’re coming to Rails 3.0 from Merb 1.x, you should recognize lots. If you’re coming from Rails 2.x, you’re going to love it too.</p>
<p>Even if you don’t give a hoot about any of our internal cleanups, Rails 3.0 is going to delight. We have a bunch of new features and improved APIs. It’s never been a better time to be a Rails developer. Some of the highlights are:</p>
<ul>
<li>Brand new router with an emphasis on RESTful declarations</li>
<li>New Action Mailer <span class="caps">API</span> modeled after Action Controller (now without the agonizing pain of sending multipart messages!)</li>
<li>New Active Record chainable query language built on top of relational algebra</li>
<li>Unobtrusive JavaScript helpers with drivers for Prototype, jQuery, and more coming (end of inline JS)</li>
<li>Explicit dependency management with Bundler</li>
</ul>
<p>On top of all that, we’ve tried our best to deprecate the old APIs with nice warnings. That means that you can move your existing application to Rails 3 without immediately rewriting all your old code to the latest best practices.</p>
<p>These release notes cover the major upgrades, but don’t include every little bug fix and change. Rails 3.0 consists of almost 4,000 commits by more than 250 authors! If you want to see everything, check out the <a href="http://github.com/rails/rails/commits/master">list of commits</a> in the main Rails repository on GitHub.</p>
<div id="subCol">
<h3 class="chapter"><img src="images/chapters_icon.gif" alt="" />Chapters</h3>
<ol class="chapters">
<li><a href="#upgrading-to-rails-3">Upgrading to Rails 3</a><ul><li><a href="#rails-3-requires-at-least-ruby-1-8-7">Rails 3 requires at least Ruby 1.8.7</a></li> <li><a href="#rails-application-object">Rails Application object</a></li> <li><a href="#script-replaced-by-script-rails">script/* replaced by script/rails</a></li> <li><a href="#dependencies-and-config-gem">Dependencies and config.gem</a></li> <li><a href="#upgrade-process">Upgrade Process</a></li></ul></li><li><a href="#creating-a-rails-3-0-application">Creating a Rails 3.0 application</a><ul><li><a href="#vendoring-gems">Vendoring Gems</a></li> <li><a href="#living-on-the-edge">Living on the Edge</a></li></ul></li><li><a href="#rails-architectural-changes">Rails Architectural Changes</a><ul><li><a href="#railties-restrung">Railties Restrung</a></li> <li><a href="#all-rails-core-components-are-decoupled">All Rails core components are decoupled</a></li> <li><a href="#active-model-abstraction">Active Model Abstraction</a></li> <li><a href="#controller-abstraction">Controller Abstraction</a></li> <li><a href="#arel-integration">Arel Integration</a></li> <li><a href="#mail-extraction">Mail Extraction</a></li></ul></li><li><a href="#documentation">Documentation</a></li><li><a href="#internationalization">Internationalization</a></li><li><a href="#railties">Railties</a></li><li><a href="#action-pack">Action Pack</a><ul><li><a href="#abstract-controller">Abstract Controller</a></li> <li><a href="#action-controller">Action Controller</a></li> <li><a href="#action-dispatch">Action Dispatch</a></li> <li><a href="#action-view">Action View</a></li></ul></li><li><a href="#active-model">Active Model</a><ul><li><a href="#orm-abstraction-and-action-pack-interface"><span class="caps">ORM</span> Abstraction and Action Pack Interface</a></li> <li><a href="#validations">Validations</a></li></ul></li><li><a href="#active-record">Active Record</a><ul><li><a href="#query-interface">Query Interface</a></li> <li><a href="#enhancements">Enhancements</a></li> <li><a href="#patches-and-deprecations">Patches and Deprecations</a></li></ul></li><li><a href="#active-resource">Active Resource</a></li><li><a href="#active-support">Active Support</a></li><li><a href="#action-mailer">Action Mailer</a></li><li><a href="#credits">Credits</a></li></ol></div>
</div>
</div>
<div id="container">
<div class="wrapper">
<div id="mainCol">
<p>To install Rails 3:</p>
<notextile>
<div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
# Use sudo if your setup requires it
gem install rails
</pre>
</div>
</notextile>
<h3 id="upgrading-to-rails-3">1 Upgrading to Rails 3</h3>
<p>If you’re upgrading an existing application, it’s a great idea to have good test coverage before going in. You should also first upgrade to Rails 2.3.5 and make sure your application still runs as expected before attempting to update to Rails 3. Then take heed of the following changes:</p>
<h4 id="rails-3-requires-at-least-ruby-1-8-7">1.1 Rails 3 requires at least Ruby 1.8.7</h4>
<p>Rails 3.0 requires Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially and you should upgrade as early as possible. Rails 3.0 is also compatible with Ruby 1.9.2.</p>
<div class='info'><p>Note that Ruby 1.8.7 p248 and p249 have marshaling bugs that crash Rails 3.0. Ruby Enterprise Edition have these fixed since release 1.8.7-2010.02 though. On the 1.9 front, Ruby 1.9.1 is not usable because it outright segfaults on Rails 3.0, so if you want to use Rails 3 with 1.9.x jump on 1.9.2 for smooth sailing.</p></div>
<h4 id="rails-application-object">1.2 Rails Application object</h4>
<p>As part of the groundwork for supporting running multiple Rails applications in the same process, Rails 3 introduces the concept of an Application object. An application object holds all the application specific configurations and is very similar in nature to <tt>config/environment.rb</tt> from the previous versions of Rails.</p>
<p>Each Rails application now must have a corresponding application object. The application object is defined in <tt>config/application.rb</tt>. If you’re upgrading an existing application to Rails 3, you must add this file and move the appropriate configurations from <tt>config/environment.rb</tt> to <tt>config/application.rb</tt>.</p>
<h4 id="script-replaced-by-script-rails">1.3 script/* replaced by script/rails</h4>
<p>The new <tt>script/rails</tt> replaces all the scripts that used to be in the <tt>script</tt> directory. You do not run <tt>script/rails</tt> directly though, the <tt>rails</tt> command detects it is being invoked in the root of a Rails application and runs the script for you. Intended usage is:</p>
<notextile>
<div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
rails console # instead of script/console
rails g scaffold post title:string # instead of script/generate scaffold post title:string
</pre>
</div>
</notextile>
<p>Run <tt>rails —help</tt> for a list of all the options.</p>
<h4 id="dependencies-and-config-gem">1.4 Dependencies and config.gem</h4>
<p>The <tt>config.gem</tt> method is gone and has been replaced by using <tt>bundler</tt> and a <tt>Gemfile</tt>, see <a href="#vendoring-gems">Vendoring Gems</a> below.</p>
<h4 id="upgrade-process">1.5 Upgrade Process</h4>
<p>To help with the upgrade process, a plugin named <a href="http://github.com/rails/rails_upgrade">Rails Upgrade</a> has been created to automate part of it.</p>
<p>Simply install the plugin, then run <tt>rake rails:upgrade:check</tt> to check your app for pieces that need to be updated (with links to information on how to update them). It also offers a task to generate a <tt>Gemfile</tt> based on your current <tt>config.gem</tt> calls and a task to generate a new routes file from your current one. To get the plugin, simply run the following:</p>
<notextile>
<div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
ruby script/plugin install git://github.com/rails/rails_upgrade.git
</pre>
</div>
</notextile>
<p>You can see an example of how that works at <a href="http://omgbloglol.com/post/364624593/rails-upgrade-is-now-an-official-plugin">Rails Upgrade is now an Official Plugin</a></p>
<p>Aside from Rails Upgrade tool, if you need more help, there are people on <span class="caps">IRC</span> and <a href="http://groups.google.com/group/rubyonrails-talk">rubyonrails-talk</a> that are probably doing the same thing, possibly hitting the same issues. Be sure to blog your own experiences when upgrading so others can benefit from your knowledge!</p>
<p>More information – <a href="http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade">The Path to Rails 3: Approaching the upgrade</a></p>
<h3 id="creating-a-rails-3-0-application">2 Creating a Rails 3.0 application</h3>
<notextile>
<div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
# You should have the 'rails' rubygem installed
$ rails new myapp
$ cd myapp
</pre>
</div>
</notextile>
<h4 id="vendoring-gems">2.1 Vendoring Gems</h4>
<p>Rails now uses a <tt>Gemfile</tt> in the application root to determine the gems you require for your application to start. This <tt>Gemfile</tt> is processed by the <a href="http://github.com/carlhuda/bundler">Bundler</a>, which then installs all your dependencies. It can even install all the dependencies locally to your application so that it doesn’t depend on the system gems.</p>
<p>More information: – <a href="http://gembundler.com">bundler homepage</a></p>
<h4 id="living-on-the-edge">2.2 Living on the Edge</h4>
<p><tt>Bundler</tt> and <tt>Gemfile</tt> makes freezing your Rails application easy as pie with the new dedicated <tt>bundle</tt> command, so <tt>rake freeze</tt> is no longer relevant and has been dropped.</p>
<p>If you want to bundle straight from the Git repository, you can pass the <tt>--edge</tt> flag:</p>
<notextile>
<div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
$ rails new myapp --edge
</pre>
</div>
</notextile>
<p>If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the <tt>--dev</tt> flag:</p>
<notextile>
<div class="code_container">
<pre class="brush: plain; gutter: false; toolbar: false">
$ ruby /path/to/rails/bin/rails new myapp --dev
</pre>
</div>
</notextile>
<h3 id="rails-architectural-changes">3 Rails Architectural Changes</h3>
<p>There are six major changes in the architecture of Rails.</p>
<h4 id="railties-restrung">3.1 Railties Restrung</h4>
<p>Railties was updated to provide a consistent plugin <span class="caps">API</span> for the entire Rails framework as well as a total rewrite of generators and the Rails bindings, the result is that developers can now hook into any significant stage of the generators and application framework in a consistent, defined manner.</p>
<h4 id="all-rails-core-components-are-decoupled">3.2 All Rails core components are decoupled</h4>
<p>With the merge of Merb and Rails, one of the big jobs was to remove the tight coupling between Rails core components. This has now been achieved, and all Rails core components are now using the same <span class="caps">API</span> that you can use for developing plugins. This means any plugin you make, or any core component replacement (like DataMapper or Sequel) can access all the functionality that the Rails core components have access to and extend and enhance at will.</p>
<p>More information: – <a href="http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/">The Great Decoupling</a></p>
<h4 id="active-model-abstraction">3.3 Active Model Abstraction</h4>
<p>Part of decoupling the core components was extracting all ties to Active Record from Action Pack. This has now been completed. All new <span class="caps">ORM</span> plugins now just need to implement Active Model interfaces to work seamlessly with Action Pack.</p>
<p>More information: – <a href="http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/">Make Any Ruby Object Feel Like ActiveRecord</a></p>
<h4 id="controller-abstraction">3.4 Controller Abstraction</h4>
<p>Another big part of decoupling the core components was creating a base superclass that is separated from the notions of <span class="caps">HTTP</span> in order to handle rendering of views etc. This creation of <tt>AbstractController</tt> allowed <tt>ActionController</tt> and <tt>ActionMailer</tt> to be greatly simplified with common code removed from all these libraries and put into Abstract Controller.</p>
<p>More Information: – <a href="http://yehudakatz.com/2009/06/11/rails-edge-architecture/">Rails Edge Architecture</a></p>
<h4 id="arel-integration">3.5 Arel Integration</h4>
<p><a href="http://github.com/brynary/arel">Arel</a> (or Active Relation) has been taken on as the underpinnings of Active Record and is now required for Rails. Arel provides an <span class="caps">SQL</span> abstraction that simplifies out Active Record and provides the underpinnings for the relation functionality in Active Record.</p>
<p>More information: – <a href="http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/">Why I wrote Arel</a>.</p>
<h4 id="mail-extraction">3.6 Mail Extraction</h4>
<p>Action Mailer ever since its beginnings has had monkey patches, pre parsers and even delivery and receiver agents, all in addition to having TMail vendored in the source tree. Version 3 changes that with all email message related functionality abstracted out to the <a href="http://github.com/mikel/mail">Mail</a> gem. This again reduces code duplication and helps create definable boundaries between Action Mailer and the email parser.</p>
<p>More information: – <a href="http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3">New Action Mailer <span class="caps">API</span> in Rails 3</a></p>
<h3 id="documentation">4 Documentation</h3>
<p>The documentation in the Rails tree is being updated with all the <span class="caps">API</span> changes, additionally, the <a href="http://edgeguides.rubyonrails.org/">Rails Edge Guides</a> are being updated one by one to reflect the changes in Rails 3.0. The guides at <a href="http://guides.rubyonrails.org/">guides.rubyonrails.org</a> however will continue to contain only the stable version of Rails (at this point, version 2.3.5, until 3.0 is released).</p>
<p>More Information: – <a href="http://weblog.rubyonrails.org/2009/1/15/rails-documentation-projects">Rails Documentation Projects</a>.</p>
<h3 id="internationalization">5 Internationalization</h3>
<p>A large amount of work has been done with I18n support in Rails 3, including the latest <a href="http://github.com/svenfuchs/i18n">I18n</a> gem supplying many speed improvements.</p>
<ul>
<li>I18n for any object – I18n behavior can be added to any object by including <tt>ActiveModel::Translation</tt> and <tt>ActiveModel::Validations</tt>. There is also an <tt>errors.messages</tt> fallback for translations.</li>
<li>Attributes can have default translations.</li>
<li>Form Submit Tags automatically pull the correct status (Create or Update) depending on the object status, and so pull the correct translation.</li>
<li>Labels with I18n also now work by just passing the attribute name.</li>
</ul>
<p>More Information: – <a href="http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/">Rails 3 I18n changes</a></p>
<h3 id="railties">6 Railties</h3>
<p>With the decoupling of the main Rails frameworks, Railties got a huge overhaul so as to make linking up frameworks, engines or plugins as painless and extensible as possible:</p>
<ul>
<li>Each application now has its own name space, application is started with <tt>YourAppName.boot</tt> for example, makes interacting with other applications a lot easier.</li>
<li>Anything under <tt>Rails.root/app</tt> is now added to the load path, so you can make <tt>app/observers/user_observer.rb</tt> and Rails will load it without any modifications.</li>
<li>Rails 3.0 now provides a <tt>Rails.config</tt> object, which provides a central repository of all sorts of Rails wide configuration options.</li>
</ul>
<p>Application generation has received extra flags allowing you to skip the installation of test-unit, Active Record, Prototype and Git. Also a new <tt>—dev</tt> flag has been added which sets the application up with the <tt>Gemfile</tt> pointing to your Rails checkout (which is determined by the path to the <tt>rails</tt> binary). See <tt>rails —help</tt> for more info.</p>
<p>Railties generators got a huge amount of attention in Rails 3.0, basically:</p>
<ul>
<li>Generators were completely rewritten and are backwards incompatible.</li>
<li>Rails templates <span class="caps">API</span> and generators <span class="caps">API</span> were merged (they are the same as the former).</li>
<li>Generators are no longer loaded from special paths anymore, they are just found in the Ruby load path, so calling <tt>rails generate foo</tt> will look for <tt>generators/foo_generator</tt>.</li>
<li>New generators provide hooks, so any template engine, <span class="caps">ORM</span>, test framework can easily hook in.</li>
<li>New generators allow you to override the templates by placing a copy at <tt>Rails.root/lib/templates</tt>.</li>
<li><tt>Rails::Generators::TestCase</tt> is also supplied so you can create your own generators and test them.</li>
</ul>
<p>Also, the views generated by Railties generators had some overhaul:</p>
<ul>
<li>Views now use <tt>div</tt> tags instead of <tt>p</tt> tags.</li>
<li>Scaffolds generated now make use of <tt>_form</tt> partials, instead of duplicated code in the edit and new views.</li>
<li>Scaffold forms now use <tt>f.submit</tt> which returns “Create ModelName” or “Update ModelName” depending on the state of the object passed in.</li>
</ul>
<p>Finally a couple of enhancements were added to the rake tasks:</p>
<ul>
<li><tt>rake db:forward</tt> was added, allowing you to roll forward your migrations individually or in groups.</li>
<li><tt>rake routes <span class="caps">CONTROLLER</span>=x</tt> was added allowing you to just view the routes for one controller.</li>
</ul>
<p>Railties now deprecates:</p>
<ul>
<li><tt>RAILS_ROOT</tt> in favor of <tt>Rails.root</tt>,</li>
<li><tt>RAILS_ENV</tt> in favor of <tt>Rails.env</tt>, and</li>
<li><tt>RAILS_DEFAULT_LOGGER</tt> in favor of <tt>Rails.logger</tt>.</li>
</ul>
<p><tt><span class="caps">PLUGIN</span>/rails/tasks</tt>, and <tt><span class="caps">PLUGIN</span>/tasks</tt> are no longer loaded all tasks now must be in <tt><span class="caps">PLUGIN</span>/lib/tasks</tt>.</p>
<p>More information:</p>
<ul>
<li><a href="http://blog.plataformatec.com.br/2010/01/discovering-rails-3-generators">Discovering Rails 3 generators</a></li>
<li><a href="http://caffeinedd.com/guides/331-making-generators-for-rails-3-with-thor">Making Generators for Rails 3 with Thor</a></li>
<li><a href="http://litanyagainstfear.com/blog/2010/02/03/the-rails-module/" title="in Rails 3">The Rails Module</a></li>
</ul>
<h3 id="action-pack">7 Action Pack</h3>
<p>There have been significant internal and external changes in Action Pack.</p>
<h4 id="abstract-controller">7.1 Abstract Controller</h4>
<p>Abstract Controller pulls out the generic parts of Action Controller into a reusable module that any library can use to render templates, render partials, helpers, translations, logging, any part of the request response cycle. This abstraction allowed <tt>ActionMailer::Base</tt> to now just inherit from <tt>AbstractController</tt> and just wrap the Rails <span class="caps">DSL</span> onto the Mail gem.</p>
<p>It also provided an opportunity to clean up Action Controller, abstracting out what could to simplify the code.</p>
<p>Note however that Abstract Controller is not a user facing <span class="caps">API</span>, you will not run into it in your day to day use of Rails.</p>
<p>More Information: – <a href="http://yehudakatz.com/2009/06/11/rails-edge-architecture/">Rails Edge Architecture</a></p>
<h4 id="action-controller">7.2 Action Controller</h4>
<ul>
<li><tt>application_controller.rb</tt> now has <tt>protect_from_forgery</tt> on by default.</li>
<li>The <tt>cookie_verifier_secret</tt> has been deprecated and now instead it is assigned through <tt>Rails.application.config.cookie_secret</tt> and moved into its own file: <tt>config/initializers/cookie_verification_secret.rb</tt>.</li>
<li>The <tt>session_store</tt> was configured in <tt>ActionController::Base.session</tt>, and that is now moved to <tt>Rails.application.config.session_store</tt>. Defaults are set up in <tt>config/initializers/session_store.rb</tt>.</li>
<li><tt>cookies.secure</tt> allowing you to set encrypted values in cookies with <tt>cookie.secure[:key] => value</tt>.</li>
<li><tt>cookies.permanent</tt> allowing you to set permanent values in the cookie hash <tt>cookie.permanent[:key] => value</tt> that raise exceptions on signed values if verification failures.</li>
<li>You can now pass <tt>:notice => ‘This is a flash message’</tt> or <tt>:alert => ‘Something went wrong’</tt> to the <tt>format</tt> call inside a <tt>respond_to</tt> block. The <tt>flash[]</tt> hash still works as previously.</li>
<li><tt>respond_with</tt> method has now been added to your controllers simplifying the venerable <tt>format</tt> blocks.</li>
<li><tt>ActionController::Responder</tt> added allowing you flexibility in how your responses get generated.</li>
</ul>
<p>Deprecations:</p>
<ul>
<li><tt>filter_parameter_logging</tt> is deprecated in favor of <tt>config.filter_parameters << :password</tt>.</li>
</ul>
<p>More Information:</p>
<ul>
<li><a href="http://www.engineyard.com/blog/2010/render-options-in-rails-3/">Render Options in Rails 3</a></li>
<li><a href="http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder">Three reasons to love ActionController::Responder</a></li>
</ul>
<h4 id="action-dispatch">7.3 Action Dispatch</h4>
<p>Action Dispatch is new in Rails 3.0 and provides a new, cleaner implementation for routing.</p>
<ul>
<li>Big clean up and re-write of the router, the Rails router is now <tt>rack_mount</tt> with a Rails <span class="caps">DSL</span> on top, it is a stand alone piece of software.</li>
<li>Routes defined by each application are now name spaced within your Application module, that is:</li>
</ul>
<notextile>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
# Instead of:
ActionController::Routing::Routes.draw do |map|
map.resources :posts
end
# You do:
AppName::Application.routes do
resources :posts
end
</pre>
</div>
</notextile>
<ul>
<li>Added <tt>match</tt> method to the router, you can also pass any Rack application to the matched route.</li>
<li>Added <tt>constraints</tt> method to the router, allowing you to guard routers with defined constraints.</li>
<li>Added <tt>scope</tt> method to the router, allowing you to namespace routes for different languages or different actions, for example:</li>
</ul>
<notextile>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
scope 'es' do
resources :projects, :path_names => { :edit => 'cambiar' }, :path => 'proyecto'
end
# Gives you the edit action with /es/proyecto/1/cambiar
</pre>
</div>
</notextile>
<ul>
<li>Added <tt>root</tt> method to the router as a short cut for <tt>match ‘/’, :to => path</tt>.</li>
<li>You can pass optional segments into the match, for example <tt>match “/:controller(/:action(/:id))(.:format)”</tt>, each parenthesized segment is optional.</li>
<li>Routes can be expressed via blocks, for example you can call <tt>controller :home { match ‘/:action’ }</tt>.</li>
</ul>
<div class='note'><p>The old style <tt>map</tt> commands still work as before with a backwards compatibility layer, however this will be removed in the 3.1 release.</p></div>
<p>Deprecations</p>
<ul>
<li>The catch all route for non-<span class="caps">REST</span> applications (<tt>/:controller/:action/:id</tt>) is now commented out.</li>
<li>Routes :path_prefix no longer exists and :name_prefix now automatically adds “_” at the end of the given value.</li>
</ul>
<p>More Information:</p>
<ul>
<li><a href="http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/">The Rails 3 Router: Rack it Up</a></li>
<li><a href="http://rizwanreza.com/2009/12/20/revamped-routes-in-rails-3">Revamped Routes in Rails 3</a></li>
<li><a href="http://yehudakatz.com/2009/12/20/generic-actions-in-rails-3/">Generic Actions in Rails 3</a></li>
</ul>
<h4 id="action-view">7.4 Action View</h4>
<h5 id="unobtrusive-javascript">7.4.1 Unobtrusive JavaScript</h5>
<p>Major re-write was done in the Action View helpers, implementing Unobtrusive JavaScript (<span class="caps">UJS</span>) hooks and removing the old inline <span class="caps">AJAX</span> commands. This enables Rails to use any compliant <span class="caps">UJS</span> driver to implement the <span class="caps">UJS</span> hooks in the helpers.</p>
<p>What this means is that all previous <tt>remote_<method></tt> helpers have been removed from Rails core and put into the <a href="http://github.com/rails/prototype_legacy_helper">Prototype Legacy Helper</a>. To get <span class="caps">UJS</span> hooks into your <span class="caps">HTML</span>, you now pass <tt>:remote => true</tt> instead. For example:</p>
<notextile>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
form_for @post, :remote => true
</pre>
</div>
</notextile>
<p>Produces:</p>
<notextile>
<div class="code_container">
<pre class="brush: xml; gutter: false; toolbar: false">
<form action="http://host.com" id="create-post" method="post" data-remote="true">
</pre>
</div>
</notextile>
<h5 id="helpers-with-blocks">7.4.2 Helpers with Blocks</h5>
<p>Helpers like <tt>form_for</tt> or <tt>div_for</tt> that insert content from a block use <tt><%=</tt> now:</p>
<notextile>
<div class="code_container">
<pre class="brush: ruby; html-script: true; gutter: false; toolbar: false">
<%= form_for @post do |f| %>
...
<% end %>
</pre>
</div>
</notextile>
<p>Your own helpers of that kind are expected to return a string, rather than appending to the output buffer by hand.</p>
<p>Helpers that do something else, like <tt>cache</tt> or <tt>content_for</tt>, are not affected by this change, they need <tt><%</tt> as before.</p>
<h5 id="other-changes">7.4.3 Other Changes</h5>
<ul>
<li>You no longer need to call <tt>h(string)</tt> to escape <span class="caps">HTML</span> output, it is on by default in all view templates. If you want the unescaped string, call <tt>raw(string)</tt>.</li>
<li>Helpers now output <span class="caps">HTML</span> 5 by default.</li>
<li>Form label helper now pulls values from I18n with a single value, so <tt>f.label :name</tt> will pull the <tt>:name</tt> translation.</li>
<li>I18n select label on should now be :en.helpers.select instead of :en.support.select.</li>
<li>You no longer need to place a minus sign at the end of a ruby interpolation inside an ERb template to remove the trailing carriage return in the <span class="caps">HTML</span> output.</li>
<li>Added <tt>grouped_collection_select</tt> helper to Action View.</li>
<li><tt>content_for?</tt> has been added allowing you to check for the existence of content in a view before rendering.</li>
<li>passing <tt>:value => nil</tt> to form helpers will set the field’s <tt>value</tt> attribute to nil as opposed to using the default value</li>
<li>passing <tt>:id => nil</tt> to form helpers will cause those fields to be rendered with no <tt>id</tt> attribute</li>
<li>passing <tt>:alt => nil</tt> to <tt>image_tag</tt> will cause the <tt>img</tt> tag to render with no <tt>alt</tt> attribute</li>
</ul>
<h3 id="active-model">8 Active Model</h3>
<p>Active Model is new in Rails 3.0. It provides an abstraction layer for any <span class="caps">ORM</span> libraries to use to interact with Rails by implementing an Active Model interface.</p>
<h4 id="orm-abstraction-and-action-pack-interface">8.1 <span class="caps">ORM</span> Abstraction and Action Pack Interface</h4>
<p>Part of decoupling the core components was extracting all ties to Active Record from Action Pack. This has now been completed. All new <span class="caps">ORM</span> plugins now just need to implement Active Model interfaces to work seamlessly with Action Pack.</p>
<p>More Information: – <a href="http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/">Make Any Ruby Object Feel Like ActiveRecord</a></p>
<h4 id="validations">8.2 Validations</h4>
<p>Validations have been moved from Active Record into Active Model, providing an interface to validations that works across <span class="caps">ORM</span> libraries in Rails 3.</p>
<ul>
<li>There is now a <tt>validates :attribute, options_hash</tt> shortcut method that allows you to pass options for all the validates class methods, you can pass more than one option to a validate method.</li>
<li>The <tt>validates</tt> method has the following options:
<ul>
<li><tt>:acceptance => Boolean</tt>.</li>
<li><tt>:confirmation => Boolean</tt>.</li>
<li><tt>:exclusion => { :in => Enumerable }</tt>.</li>
<li><tt>:inclusion => { :in => Enumerable }</tt>.</li>
<li><tt>:format => { :with => Regexp, :on => :create }</tt>.</li>
<li><tt>:length => { :maximum => Fixnum }</tt>.</li>
<li><tt>:numericality => Boolean</tt>.</li>
<li><tt>:presence => Boolean</tt>.</li>
<li><tt>:uniqueness => Boolean</tt>.</li>
</ul></li>
</ul>
<div class='note'><p>All the Rails version 2.3 style validation methods are still supported in Rails 3.0, the new validates method is designed as an additional aid in your model validations, not a replacement for the existing <span class="caps">API</span>.</p></div>
<p>You can also pass in a validator object, which you can then reuse between objects that use Active Model:</p>
<notextile>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
class TitleValidator < ActiveModel::EachValidator
Titles = ['Mr.', 'Mrs.', 'Dr.']
def validate_each(record, attribute, value)
unless Titles.include?(value)
record.errors[attribute] << 'must be a valid title'
end
end
end
</pre>
</div>
</notextile>
<notextile>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
class Person
include ActiveModel::Validations
attr_accessor :title
validates :title, :presence => true, :title => true
end
# Or for Active Record
class Person < ActiveRecord::Base
validates :title, :presence => true, :title => true
end
</pre>
</div>
</notextile>
<p>There’s also support for introspection:</p>
<notextile>
<div class="code_container">
<pre class="brush: ruby; gutter: false; toolbar: false">
User.validators
User.validators_on(:login)
</pre>
</div>
</notextile>
<p>More Information:</p>
<ul>
<li><a href="http://thelucid.com/2010/01/08/sexy-validation-in-edge-rails-rails-3/">Sexy Validation in Rails 3</a></li>
<li><a href="http://lindsaar.net/2010/1/31/validates_rails_3_awesome_is_true">Rails 3 Validations Explained</a></li>
</ul>
<h3 id="active-record">9 Active Record</h3>
<p>Active Record received a lot of attention in Rails 3.0, including abstraction into Active Model, a full update to the Query interface using Arel, validation updates and many enhancements and fixes. All of the Rails 2.x <span class="caps">API</span> will be usable through a compatibility layer that will be supported until version 3.1.</p>
<h4 id="query-interface">9.1 Query Interface</h4>
<p>Active Record, through the use of Arel, now returns relations on its core methods. The existing <span class="caps">API</span> in Rails 2.3.x is still supported and will not be deprecated until Rails 3.1 and not removed until Rails 3.2, however, the new <span class="caps">API</span> provides the following new methods that all return relations allowing them to be chained together:</p>
<ul>
<li><tt>where</tt> – provides conditions on the relation, what gets returned.</li>
<li><tt>select</tt> – choose what attributes of the models you wish to have returned from the database.</li>
<li><tt>group</tt> – groups the relation on the attribute supplied.</li>
<li><tt>having</tt> – provides an expression limiting group relations (<span class="caps">GROUP</span> BY constraint).</li>
<li><tt>joins</tt> – joins the relation to another table.</li>
<li><tt>clause</tt> – provides an expression limiting join relations (<span class="caps">JOIN</span> constraint).</li>
<li><tt>includes</tt> – includes other relations pre-loaded.</li>
<li><tt>order</tt> – orders the relation based on the expression supplied.</li>
<li><tt>limit</tt> – limits the relation to the number of records specified.</li>
<li><tt>lock</tt> – locks the records returned from the table.</li>
<li><tt>readonly</tt> – returns an read only copy of the data.</li>
<li><tt>from</tt> – provides a way to select relationships from more than one table.</li>
<li><tt>scope</tt> – (previously <tt>named_scope</tt>) return relations and can be chained together with the other relation methods.</li>
<li><tt>with_scope</tt> – and <tt>with_exclusive_scope</tt> now also return relations and so can be chained.</li>
<li><tt>default_scope</tt> – also works with relations.</li>
</ul>
<p>More Information:</p>
<ul>
<li><a href="http://m.onkey.org/2010/1/22/active-record-query-interface">Active Record Query Interface</a></li>
<li><a href="http://hasmanyquestions.wordpress.com/2010/01/17/let-your-sql-growl-in-rails-3/">Let your <span class="caps">SQL</span> Growl in Rails 3</a></li>
</ul>
<h4 id="enhancements">9.2 Enhancements</h4>
<ul>
<li>Added <tt>:destroyed?</tt> to Active Record objects.</li>
<li>Added <tt>:inverse_of</tt> to Active Record associations allowing you to pull the instance of an already loaded association without hitting the database.</li>
</ul>
<h4 id="patches-and-deprecations">9.3 Patches and Deprecations</h4>
<p>Additionally, many fixes in the Active Record branch:</p>
<ul>
<li>SQLite 2 support has been dropped in favor of SQLite 3.</li>
<li>MySQL support for column order.</li>
<li>PostgreSQL adapter has had its <tt>TIME ZONE</tt> support fixed so it no longer inserts incorrect values.</li>
<li>Support multiple schemas in table names for PostgreSQL.</li>
<li>PostgreSQL support for the <span class="caps">XML</span> data type column.</li>
<li><tt>table_name</tt> is now cached.</li>
<li>A large amount of work done on the Oracle adapter as well with many bug fixes.</li>
</ul>
<p>As well as the following deprecations:</p>
<ul>
<li><tt>named_scope</tt> in an Active Record class is deprecated and has been renamed to just <tt>scope</tt>.</li>
<li>In <tt>scope</tt> methods, you should move to using the relation methods, instead of a <tt>:conditions => {}</tt> finder method, for example <tt>scope :since, lambda {|time| where(“created_at > ?”, time) }</tt>.</li>
<li><tt>save(false)</tt> is deprecated, in favor of <tt>save(:validate => false)</tt>.</li>
<li>I18n error messages for ActiveRecord should be changed from :en.activerecord.errors.template to <tt>:en.errors.template</tt>.</li>
<li><tt>model.errors.on</tt> is deprecated in favor of <tt>model.errors[]</tt></li>
<li>validates_presence_of => validates… :presence => true</li>
<li><tt>ActiveRecord::Base.colorize_logging</tt> and <tt>config.active_record.colorize_logging</tt> are deprecated in favor of <tt>Rails::LogSubscriber.colorize_logging</tt> or <tt>config.colorize_logging</tt></li>
</ul>
<div class='note'><p>While an implementation of State Machine has been in Active Record edge for some months now, it has been removed from the Rails 3.0 release.</p></div>
<h3 id="active-resource">10 Active Resource</h3>
<p>Active Resource was also extracted out to Active Model allowing you to use Active Resource objects with Action Pack seamlessly.</p>
<ul>
<li>Added validations through Active Model.</li>
<li>Added observing hooks.</li>
<li><span class="caps">HTTP</span> proxy support.</li>
<li>Added support for digest authentication.</li>
<li>Moved model naming into Active Model.</li>
<li>Changed Active Resource attributes to a Hash with indifferent access.</li>
<li>Added <tt>first</tt>, <tt>last</tt> and <tt>all</tt> aliases for equivalent find scopes.</li>
<li><tt>find_every</tt> now does not return a <tt>ResourceNotFound</tt> error if nothing returned.</li>
<li>Added <tt>save!</tt> which raises <tt>ResourceInvalid</tt> unless the object is <tt>valid?</tt>.</li>
<li><tt>update_attribute</tt> and <tt>update_attributes</tt> added to Active Resource models.</li>
<li>Added <tt>exists?</tt>.</li>
<li>Renamed <tt>SchemaDefinition</tt> to <tt>Schema</tt> and <tt>define_schema</tt> to <tt>schema</tt>.</li>
<li>Use the <tt>format</tt> of Active Resources rather than the <tt>content-type</tt> of remote errors to load errors.</li>
<li>Use <tt>instance_eval</tt> for schema block.</li>
<li>Fix <tt>ActiveResource::ConnectionError#to_s</tt> when <tt>@response</tt> does not respond to #code or #message, handles Ruby 1.9 compatibility.</li>
<li>Add support for errors in <span class="caps">JSON</span> format.</li>
<li>Ensure <tt>load</tt> works with numeric arrays.</li>
<li>Recognizes a 410 response from remote resource as the resource has been deleted.</li>
<li>Add ability to set <span class="caps">SSL</span> options on Active Resource connections.</li>
<li>Setting connection timeout also affects <tt>Net::HTTP</tt> <tt>open_timeout</tt>.</li>
</ul>
<p>Deprecations:</p>
<ul>
<li><tt>save(false)</tt> is deprecated, in favor of <tt>save(:validate => false)</tt>.</li>
<li>Ruby 1.9.2: <tt><span class="caps">URI</span>.parse</tt> and <tt>.decode</tt> are deprecated and are no longer used in the library.</li>
</ul>
<h3 id="active-support">11 Active Support</h3>
<p>A large effort was made in Active Support to make it cherry pickable, that is, you no longer have to require the entire Active Support library to get pieces of it. This allows the various core components of Rails to run slimmer.</p>
<p>These are the main changes in Active Support:</p>
<ul>
<li>Large clean up of the library removing unused methods throughout.</li>
<li>Active Support no longer provides vendored versions of <a href="http://tzinfo.rubyforge.org/">TZInfo</a>, <a href="http://deveiate.org/projects/RMemCache/">Memcache Client</a> and <a href="http://builder.rubyforge.org/">Builder</a>, these are all included as dependencies and installed via the <tt>bundle install</tt> command.</li>
<li>Safe buffers are implemented in <tt>ActiveSupport::SafeBuffer</tt>.</li>
<li>Added <tt>Array.uniq_by</tt> and <tt>Array.uniq_by!</tt>.</li>
<li>Removed <tt>Array#rand</tt> and backported <tt>Array#sample</tt> from Ruby 1.9.</li>
<li>Fixed bug on <tt>TimeZone.seconds_to_utc_offset</tt> returning wrong value.</li>
<li>Added <tt>ActiveSupport::Notifications</tt> middleware.</li>
<li><tt>ActiveSupport.use_standard_json_time_format</tt> now defaults to true.</li>
<li><tt>ActiveSupport.escape_html_entities_in_json</tt> now defaults to false.</li>
<li><tt>Integer#multiple_of?</tt> accepts zero as an argument, returns false unless the receiver is zero.</li>
<li><tt>string.chars</tt> has been renamed to <tt>string.mb_chars</tt>.</li>
<li><tt>ActiveSupport::OrderedHash</tt> now can de-serialize through <span class="caps">YAML</span>.</li>
<li>Added <span class="caps">SAX</span>-based parser for XmlMini, using LibXML and Nokogiri.</li>
<li>Added <tt>Object#presence</tt> that returns the object if it’s <tt>#present?</tt> otherwise returns <tt>nil</tt>.</li>
<li>Added <tt>String#exclude?</tt> core extension that returns the inverse of <tt>#include?</tt>.</li>
<li>Added <tt>to_i</tt> to <tt>DateTime</tt> in <tt>ActiveSupport</tt> so <tt>to_yaml</tt> works correctly on models with <tt>DateTime</tt> attributes.</li>
<li>Added <tt>Enumerable#exclude?</tt> to bring parity to <tt>Enumerable#include?</tt> and avoid if <tt>!x.include?</tt>.</li>
<li>Switch to on-by-default <span class="caps">XSS</span> escaping for rails.</li>
<li>Support deep-merging in <tt>ActiveSupport::HashWithIndifferentAccess</tt>.</li>
<li><tt>Enumerable#sum</tt> now works will all enumerables, even if they don’t respond to <tt>:size</tt>.</li>
<li><tt>inspect</tt> on a zero length duration returns ‘0 seconds’ instead of empty string.</li>
<li>Add <tt>element</tt> and <tt>collection</tt> to <tt>ModelName</tt>.</li>
<li><tt>String#to_time</tt> and <tt>String#to_datetime</tt> handle fractional seconds.</li>
<li>Added support to new callbacks for around filter object that respond to <tt>:before</tt> and <tt>:after</tt> used in before and after callbacks.</li>
<li>The <tt>ActiveSupport::OrderedHash#to_a</tt> method returns an ordered set of arrays. Matches Ruby 1.9’s <tt>Hash#to_a</tt>.</li>
<li><tt>MissingSourceFile</tt> exists as a constant but it is now just equals to <tt>LoadError</tt>.</li>
<li>Added <tt>Class#class_attribute</tt>, to be able to declare a class-level attribute whose value is inheritable and overwritable by subclasses.</li>
<li>Finally removed <tt>DeprecatedCallbacks</tt> in <tt>ActiveRecord::Associations</tt>.</li>
<li><tt>Object#metaclass</tt> is now <tt>Kernel#singleton_class</tt> to match Ruby.</li>
</ul>
<p>The following methods have been removed because they are now available in Ruby 1.8.7 and 1.9.</p>
<ul>
<li><tt>Integer#even?</tt> and <tt>Integer#odd?</tt></li>
<li><tt>String#each_char</tt></li>
<li><tt>String#start_with?</tt> and <tt>String#end_with?</tt> (3rd person aliases still kept)</li>
<li><tt>String#bytesize</tt></li>
<li><tt>Object#tap</tt></li>
<li><tt>Symbol#to_proc</tt></li>
<li><tt>Object#instance_variable_defined?</tt></li>
<li><tt>Enumerable#none?</tt></li>
</ul>
<p>The security patch for <span class="caps">REXML</span> remains in Active Support because early patch-levels of Ruby 1.8.7 still need it. Active Support knows whether it has to apply it or not.</p>
<p>The following methods have been removed because they are no longer used in the framework:</p>
<ul>
<li><tt>Kernel#daemonize</tt></li>
<li><tt>Object#remove_subclasses_of</tt> <tt>Object#extend_with_included_modules_from</tt>, <tt>Object#extended_by</tt></li>
<li><tt>Class#remove_class</tt></li>
<li><tt>Regexp#number_of_captures</tt>, <tt>Regexp.unoptionalize</tt>, <tt>Regexp.optionalize</tt>, <tt>Regexp#number_of_captures</tt></li>
</ul>
<h3 id="action-mailer">12 Action Mailer</h3>
<p>Action Mailer has been given a new <span class="caps">API</span> with TMail being replaced out with the new <a href="http://github.com/mikel/mail">Mail</a> as the Email library. Action Mailer itself has been given an almost complete re-write with pretty much every line of code touched. The result is that Action Mailer now simply inherits from Abstract Controller and wraps the Mail gem in a Rails <span class="caps">DSL</span>. This reduces the amount of code and duplication of other libraries in Action Mailer considerably.</p>
<ul>
<li>All mailers are now in <tt>app/mailers</tt> by default.</li>
<li>Can now send email using new <span class="caps">API</span> with three methods: <tt>attachments</tt>, <tt>headers</tt> and <tt>mail</tt>.</li>
<li>ActionMailer now has native support for inline attachments using the <tt>attachments.inline</tt> method.</li>
<li>Action Mailer emailing methods now return <tt>Mail::Message</tt> objects, which can then be sent the <tt>deliver</tt> message to send itself.</li>
<li>All delivery methods are now abstracted out to the Mail gem.</li>
<li>The mail delivery method can accept a hash of all valid mail header fields with their value pair.</li>
<li>The <tt>mail</tt> delivery method acts in a similar way to Action Controller’s <tt>respond_to</tt>, and you can explicitly or implicitly render templates. Action Mailer will turn the email into a multipart email as needed.</li>
<li>You can pass a proc to the <tt>format.mime_type</tt> calls within the mail block and explicitly render specific types of text, or add layouts or different templates. The <tt>render</tt> call inside the proc is from Abstract Controller and supports the same options.</li>
<li>What were mailer unit tests have been moved to functional tests.</li>
<li>Action Mailer now delegates all auto encoding of header fields and bodies to Mail Gem</li>
<li>Action Mailer will auto encode email bodies and headers for you</li>
</ul>
<p>Deprecations:</p>
<ul>
<li><tt>:charset</tt>, <tt>:content_type</tt>, <tt>:mime_version</tt>, <tt>:implicit_parts_order</tt> are all deprecated in favor of <tt>ActionMailer.default :key => value</tt> style declarations.</li>
<li>Mailer dynamic <tt>create_method_name</tt> and <tt>deliver_method_name</tt> are deprecated, just call <tt>method_name</tt> which now returns a <tt>Mail::Message</tt> object.</li>
<li><tt>ActionMailer.deliver(message)</tt> is deprecated, just call <tt>message.deliver</tt>.</li>
<li><tt>template_root</tt> is deprecated, pass options to a render call inside a proc from the <tt>format.mime_type</tt> method inside the <tt>mail</tt> generation block</li>
<li>The <tt>body</tt> method to define instance variables is deprecated (<tt>body {:ivar => value}</tt>), just declare instance variables in the method directly and they will be available in the view.</li>
<li>Mailers being in <tt>app/models</tt> is deprecated, use <tt>app/mailers</tt> instead.</li>
</ul>
<p>More Information:</p>
<ul>
<li><a href="http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3">New Action Mailer <span class="caps">API</span> in Rails 3</a></li>
<li><a href="http://lindsaar.net/2010/1/23/mail-gem-version-2-released">New Mail Gem for Ruby</a></li>
</ul>
<h3 id="credits">13 Credits</h3>
<p>See the <a href="http://contributors.rubyonrails.org/">full list of contributors to Rails</a> for the many people who spent many hours making Rails 3. Kudos to all of them.</p>
<p>Rails 3.0 Release Notes were compiled by <a href="http://lindsaar.net">Mikel Lindsaar</a>.</p>
<h3>Feedback</h3>
<p>
You're encouraged to help in keeping the quality of this guide.
</p>
<p>
If you see any typos or factual errors you are confident to
patch, please clone <a href="https://github.com/lifo/docrails">docrails</a>
and push the change yourself. That branch of Rails has public write access.
Commits are still reviewed, but that happens after you've submitted your
contribution. <a href="https://github.com/lifo/docrails">docrails</a> is
cross-merged with master periodically.
</p>
<p>
You may also find incomplete content, or stuff that is not up to date.
Please do add any missing documentation for master. Check the
<a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a>
for style and conventions.
</p>
<p>
Issues may also be reported in <a href="https://github.com/lifo/docrails/issues">Github</a>.
</p>
<p>And last but not least, any kind of discussion regarding Ruby on Rails
documentation is very welcome in the <a href="http://groups.google.com/group/rubyonrails-docs">rubyonrails-docs mailing list</a>.
</p>
</div>
</div>
</div>
<hr class="hide" />
<div id="footer">
<div class="wrapper">
<p>This work is licensed under a <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons Attribution-Share Alike 3.0</a> License</p>
<p>"Rails", "Ruby on Rails", and the Rails logo are trademarks of David Heinemeier Hansson. All rights reserved.</p>
</div>
</div>
<script type="text/javascript" src="javascripts/guides.js"></script>
<script type="text/javascript" src="javascripts/syntaxhighlighter/shCore.js"></script>
<script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushRuby.js"></script>
<script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushXml.js"></script>
<script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushSql.js"></script>
<script type="text/javascript" src="javascripts/syntaxhighlighter/shBrushPlain.js"></script>
<script type="text/javascript">
SyntaxHighlighter.all()
</script>
</body>
</html>