rails 4.2.10 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -10
- metadata +37 -238
- data/guides/CHANGELOG.md +0 -93
- data/guides/Rakefile +0 -92
- data/guides/assets/images/akshaysurve.jpg +0 -0
- data/guides/assets/images/belongs_to.png +0 -0
- data/guides/assets/images/book_icon.gif +0 -0
- data/guides/assets/images/bullet.gif +0 -0
- data/guides/assets/images/chapters_icon.gif +0 -0
- data/guides/assets/images/check_bullet.gif +0 -0
- data/guides/assets/images/credits_pic_blank.gif +0 -0
- data/guides/assets/images/csrf.png +0 -0
- data/guides/assets/images/edge_badge.png +0 -0
- data/guides/assets/images/favicon.ico +0 -0
- data/guides/assets/images/feature_tile.gif +0 -0
- data/guides/assets/images/footer_tile.gif +0 -0
- data/guides/assets/images/fxn.png +0 -0
- data/guides/assets/images/getting_started/article_with_comments.png +0 -0
- data/guides/assets/images/getting_started/challenge.png +0 -0
- data/guides/assets/images/getting_started/confirm_dialog.png +0 -0
- data/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
- data/guides/assets/images/getting_started/form_with_errors.png +0 -0
- data/guides/assets/images/getting_started/index_action_with_edit_link.png +0 -0
- data/guides/assets/images/getting_started/new_article.png +0 -0
- data/guides/assets/images/getting_started/rails_welcome.png +0 -0
- data/guides/assets/images/getting_started/routing_error_no_controller.png +0 -0
- data/guides/assets/images/getting_started/routing_error_no_route_matches.png +0 -0
- data/guides/assets/images/getting_started/show_action_for_articles.png +0 -0
- data/guides/assets/images/getting_started/template_is_missing_articles_new.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_create_for_articles.png +0 -0
- data/guides/assets/images/getting_started/unknown_action_new_for_articles.png +0 -0
- data/guides/assets/images/grey_bullet.gif +0 -0
- data/guides/assets/images/habtm.png +0 -0
- data/guides/assets/images/has_many.png +0 -0
- data/guides/assets/images/has_many_through.png +0 -0
- data/guides/assets/images/has_one.png +0 -0
- data/guides/assets/images/has_one_through.png +0 -0
- data/guides/assets/images/header_backdrop.png +0 -0
- data/guides/assets/images/header_tile.gif +0 -0
- data/guides/assets/images/i18n/demo_html_safe.png +0 -0
- data/guides/assets/images/i18n/demo_localized_pirate.png +0 -0
- data/guides/assets/images/i18n/demo_translated_en.png +0 -0
- data/guides/assets/images/i18n/demo_translated_pirate.png +0 -0
- data/guides/assets/images/i18n/demo_translation_missing.png +0 -0
- data/guides/assets/images/i18n/demo_untranslated.png +0 -0
- data/guides/assets/images/icons/README +0 -5
- data/guides/assets/images/icons/callouts/1.png +0 -0
- data/guides/assets/images/icons/callouts/10.png +0 -0
- data/guides/assets/images/icons/callouts/11.png +0 -0
- data/guides/assets/images/icons/callouts/12.png +0 -0
- data/guides/assets/images/icons/callouts/13.png +0 -0
- data/guides/assets/images/icons/callouts/14.png +0 -0
- data/guides/assets/images/icons/callouts/15.png +0 -0
- data/guides/assets/images/icons/callouts/2.png +0 -0
- data/guides/assets/images/icons/callouts/3.png +0 -0
- data/guides/assets/images/icons/callouts/4.png +0 -0
- data/guides/assets/images/icons/callouts/5.png +0 -0
- data/guides/assets/images/icons/callouts/6.png +0 -0
- data/guides/assets/images/icons/callouts/7.png +0 -0
- data/guides/assets/images/icons/callouts/8.png +0 -0
- data/guides/assets/images/icons/callouts/9.png +0 -0
- data/guides/assets/images/icons/caution.png +0 -0
- data/guides/assets/images/icons/example.png +0 -0
- data/guides/assets/images/icons/home.png +0 -0
- data/guides/assets/images/icons/important.png +0 -0
- data/guides/assets/images/icons/next.png +0 -0
- data/guides/assets/images/icons/note.png +0 -0
- data/guides/assets/images/icons/prev.png +0 -0
- data/guides/assets/images/icons/tip.png +0 -0
- data/guides/assets/images/icons/up.png +0 -0
- data/guides/assets/images/icons/warning.png +0 -0
- data/guides/assets/images/nav_arrow.gif +0 -0
- data/guides/assets/images/oscardelben.jpg +0 -0
- data/guides/assets/images/polymorphic.png +0 -0
- data/guides/assets/images/radar.png +0 -0
- data/guides/assets/images/rails4_features.png +0 -0
- data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
- data/guides/assets/images/rails_guides_logo.gif +0 -0
- data/guides/assets/images/rails_logo_remix.gif +0 -0
- data/guides/assets/images/session_fixation.png +0 -0
- data/guides/assets/images/tab_grey.gif +0 -0
- data/guides/assets/images/tab_info.gif +0 -0
- data/guides/assets/images/tab_note.gif +0 -0
- data/guides/assets/images/tab_red.gif +0 -0
- data/guides/assets/images/tab_yellow.gif +0 -0
- data/guides/assets/images/tab_yellow.png +0 -0
- data/guides/assets/images/vijaydev.jpg +0 -0
- data/guides/assets/javascripts/guides.js +0 -59
- data/guides/assets/javascripts/jquery.min.js +0 -4
- data/guides/assets/javascripts/responsive-tables.js +0 -43
- data/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js +0 -59
- data/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js +0 -75
- data/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js +0 -59
- data/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js +0 -65
- data/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js +0 -100
- data/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js +0 -97
- data/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js +0 -91
- data/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js +0 -55
- data/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js +0 -41
- data/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js +0 -52
- data/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js +0 -67
- data/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js +0 -52
- data/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js +0 -57
- data/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js +0 -58
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js +0 -72
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js +0 -88
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js +0 -33
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js +0 -74
- data/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js +0 -64
- data/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js +0 -55
- data/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js +0 -94
- data/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js +0 -51
- data/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js +0 -66
- data/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js +0 -56
- data/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js +0 -69
- data/guides/assets/javascripts/syntaxhighlighter/shCore.js +0 -17
- data/guides/assets/stylesheets/fixes.css +0 -16
- data/guides/assets/stylesheets/kindle.css +0 -11
- data/guides/assets/stylesheets/main.css +0 -713
- data/guides/assets/stylesheets/print.css +0 -52
- data/guides/assets/stylesheets/reset.css +0 -43
- data/guides/assets/stylesheets/responsive-tables.css +0 -50
- data/guides/assets/stylesheets/style.css +0 -13
- data/guides/assets/stylesheets/syntaxhighlighter/shCore.css +0 -226
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css +0 -328
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css +0 -331
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css +0 -339
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css +0 -324
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css +0 -324
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css +0 -324
- data/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css +0 -324
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css +0 -117
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css +0 -120
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css +0 -128
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css +0 -113
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css +0 -113
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css +0 -113
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css +0 -113
- data/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +0 -116
- data/guides/bug_report_templates/action_controller_gem.rb +0 -47
- data/guides/bug_report_templates/action_controller_master.rb +0 -54
- data/guides/bug_report_templates/active_record_gem.rb +0 -40
- data/guides/bug_report_templates/active_record_master.rb +0 -49
- data/guides/bug_report_templates/generic_gem.rb +0 -15
- data/guides/bug_report_templates/generic_master.rb +0 -26
- data/guides/rails_guides/generator.rb +0 -248
- data/guides/rails_guides/helpers.rb +0 -53
- data/guides/rails_guides/indexer.rb +0 -68
- data/guides/rails_guides/kindle.rb +0 -119
- data/guides/rails_guides/levenshtein.rb +0 -37
- data/guides/rails_guides/markdown/renderer.rb +0 -82
- data/guides/rails_guides/markdown.rb +0 -167
- data/guides/rails_guides.rb +0 -63
- data/guides/source/2_2_release_notes.md +0 -435
- data/guides/source/2_3_release_notes.md +0 -621
- data/guides/source/3_0_release_notes.md +0 -611
- data/guides/source/3_1_release_notes.md +0 -559
- data/guides/source/3_2_release_notes.md +0 -568
- data/guides/source/4_0_release_notes.md +0 -279
- data/guides/source/4_1_release_notes.md +0 -730
- data/guides/source/4_2_release_notes.md +0 -877
- data/guides/source/_license.html.erb +0 -2
- data/guides/source/_welcome.html.erb +0 -23
- data/guides/source/action_controller_overview.md +0 -1192
- data/guides/source/action_mailer_basics.md +0 -757
- data/guides/source/action_view_overview.md +0 -1561
- data/guides/source/active_job_basics.md +0 -339
- data/guides/source/active_model_basics.md +0 -554
- data/guides/source/active_record_basics.md +0 -374
- data/guides/source/active_record_callbacks.md +0 -413
- data/guides/source/active_record_migrations.md +0 -1018
- data/guides/source/active_record_postgresql.md +0 -433
- data/guides/source/active_record_querying.md +0 -1781
- data/guides/source/active_record_validations.md +0 -1179
- data/guides/source/active_support_core_extensions.md +0 -3856
- data/guides/source/active_support_instrumentation.md +0 -488
- data/guides/source/api_documentation_guidelines.md +0 -361
- data/guides/source/asset_pipeline.md +0 -1304
- data/guides/source/association_basics.md +0 -2245
- data/guides/source/autoloading_and_reloading_constants.md +0 -1311
- data/guides/source/caching_with_rails.md +0 -379
- data/guides/source/command_line.md +0 -625
- data/guides/source/configuring.md +0 -1070
- data/guides/source/contributing_to_ruby_on_rails.md +0 -628
- data/guides/source/credits.html.erb +0 -80
- data/guides/source/debugging_rails_applications.md +0 -861
- data/guides/source/development_dependencies_install.md +0 -289
- data/guides/source/documents.yaml +0 -205
- data/guides/source/engines.md +0 -1412
- data/guides/source/form_helpers.md +0 -1024
- data/guides/source/generators.md +0 -676
- data/guides/source/getting_started.md +0 -2086
- data/guides/source/i18n.md +0 -1087
- data/guides/source/index.html.erb +0 -28
- data/guides/source/initialization.md +0 -704
- data/guides/source/kindle/copyright.html.erb +0 -1
- data/guides/source/kindle/layout.html.erb +0 -27
- data/guides/source/kindle/rails_guides.opf.erb +0 -52
- data/guides/source/kindle/toc.html.erb +0 -24
- data/guides/source/kindle/toc.ncx.erb +0 -64
- data/guides/source/kindle/welcome.html.erb +0 -5
- data/guides/source/layout.html.erb +0 -140
- data/guides/source/layouts_and_rendering.md +0 -1226
- data/guides/source/maintenance_policy.md +0 -78
- data/guides/source/nested_model_forms.md +0 -228
- data/guides/source/plugins.md +0 -444
- data/guides/source/rails_application_templates.md +0 -266
- data/guides/source/rails_on_rack.md +0 -335
- data/guides/source/routing.md +0 -1155
- data/guides/source/ruby_on_rails_guides_guidelines.md +0 -127
- data/guides/source/security.md +0 -1024
- data/guides/source/testing.md +0 -1132
- data/guides/source/upgrading_ruby_on_rails.md +0 -1186
- data/guides/source/working_with_javascript_in_rails.md +0 -407
- data/guides/w3c_validator.rb +0 -97
@@ -1,611 +0,0 @@
|
|
1
|
-
Ruby on Rails 3.0 Release Notes
|
2
|
-
===============================
|
3
|
-
|
4
|
-
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!
|
5
|
-
|
6
|
-
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.
|
7
|
-
|
8
|
-
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:
|
9
|
-
|
10
|
-
* Brand new router with an emphasis on RESTful declarations
|
11
|
-
* New Action Mailer API modeled after Action Controller (now without the agonizing pain of sending multipart messages!)
|
12
|
-
* New Active Record chainable query language built on top of relational algebra
|
13
|
-
* Unobtrusive JavaScript helpers with drivers for Prototype, jQuery, and more coming (end of inline JS)
|
14
|
-
* Explicit dependency management with Bundler
|
15
|
-
|
16
|
-
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.
|
17
|
-
|
18
|
-
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 [list of commits](http://github.com/rails/rails/commits/3-0-stable) in the main Rails repository on GitHub.
|
19
|
-
|
20
|
-
--------------------------------------------------------------------------------
|
21
|
-
|
22
|
-
To install Rails 3:
|
23
|
-
|
24
|
-
```bash
|
25
|
-
# Use sudo if your setup requires it
|
26
|
-
$ gem install rails
|
27
|
-
```
|
28
|
-
|
29
|
-
|
30
|
-
Upgrading to Rails 3
|
31
|
-
--------------------
|
32
|
-
|
33
|
-
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:
|
34
|
-
|
35
|
-
### Rails 3 requires at least Ruby 1.8.7
|
36
|
-
|
37
|
-
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.
|
38
|
-
|
39
|
-
TIP: 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.
|
40
|
-
|
41
|
-
### Rails Application object
|
42
|
-
|
43
|
-
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 `config/environment.rb` from the previous versions of Rails.
|
44
|
-
|
45
|
-
Each Rails application now must have a corresponding application object. The application object is defined in `config/application.rb`. If you're upgrading an existing application to Rails 3, you must add this file and move the appropriate configurations from `config/environment.rb` to `config/application.rb`.
|
46
|
-
|
47
|
-
### script/* replaced by script/rails
|
48
|
-
|
49
|
-
The new `script/rails` replaces all the scripts that used to be in the `script` directory. You do not run `script/rails` directly though, the `rails` command detects it is being invoked in the root of a Rails application and runs the script for you. Intended usage is:
|
50
|
-
|
51
|
-
```bash
|
52
|
-
$ rails console # instead of script/console
|
53
|
-
$ rails g scaffold post title:string # instead of script/generate scaffold post title:string
|
54
|
-
```
|
55
|
-
|
56
|
-
Run `rails --help` for a list of all the options.
|
57
|
-
|
58
|
-
### Dependencies and config.gem
|
59
|
-
|
60
|
-
The `config.gem` method is gone and has been replaced by using `bundler` and a `Gemfile`, see [Vendoring Gems](#vendoring-gems) below.
|
61
|
-
|
62
|
-
### Upgrade Process
|
63
|
-
|
64
|
-
To help with the upgrade process, a plugin named [Rails Upgrade](http://github.com/rails/rails_upgrade) has been created to automate part of it.
|
65
|
-
|
66
|
-
Simply install the plugin, then run `rake rails:upgrade:check` 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 `Gemfile` based on your current `config.gem` calls and a task to generate a new routes file from your current one. To get the plugin, simply run the following:
|
67
|
-
|
68
|
-
```bash
|
69
|
-
$ ruby script/plugin install git://github.com/rails/rails_upgrade.git
|
70
|
-
```
|
71
|
-
|
72
|
-
You can see an example of how that works at [Rails Upgrade is now an Official Plugin](http://omgbloglol.com/post/364624593/rails-upgrade-is-now-an-official-plugin)
|
73
|
-
|
74
|
-
Aside from Rails Upgrade tool, if you need more help, there are people on IRC and [rubyonrails-talk](http://groups.google.com/group/rubyonrails-talk) 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!
|
75
|
-
|
76
|
-
Creating a Rails 3.0 application
|
77
|
-
--------------------------------
|
78
|
-
|
79
|
-
```bash
|
80
|
-
# You should have the 'rails' RubyGem installed
|
81
|
-
$ rails new myapp
|
82
|
-
$ cd myapp
|
83
|
-
```
|
84
|
-
|
85
|
-
### Vendoring Gems
|
86
|
-
|
87
|
-
Rails now uses a `Gemfile` in the application root to determine the gems you require for your application to start. This `Gemfile` is processed by the [Bundler](http://github.com/carlhuda/bundler,) 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.
|
88
|
-
|
89
|
-
More information: - [bundler homepage](http://gembundler.com)
|
90
|
-
|
91
|
-
### Living on the Edge
|
92
|
-
|
93
|
-
`Bundler` and `Gemfile` makes freezing your Rails application easy as pie with the new dedicated `bundle` command, so `rake freeze` is no longer relevant and has been dropped.
|
94
|
-
|
95
|
-
If you want to bundle straight from the Git repository, you can pass the `--edge` flag:
|
96
|
-
|
97
|
-
```bash
|
98
|
-
$ rails new myapp --edge
|
99
|
-
```
|
100
|
-
|
101
|
-
If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the `--dev` flag:
|
102
|
-
|
103
|
-
```bash
|
104
|
-
$ ruby /path/to/rails/bin/rails new myapp --dev
|
105
|
-
```
|
106
|
-
|
107
|
-
Rails Architectural Changes
|
108
|
-
---------------------------
|
109
|
-
|
110
|
-
There are six major changes in the architecture of Rails.
|
111
|
-
|
112
|
-
### Railties Restrung
|
113
|
-
|
114
|
-
Railties was updated to provide a consistent plugin API 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.
|
115
|
-
|
116
|
-
### All Rails core components are decoupled
|
117
|
-
|
118
|
-
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 API 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.
|
119
|
-
|
120
|
-
More information: - [The Great Decoupling](http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/)
|
121
|
-
|
122
|
-
|
123
|
-
### Active Model Abstraction
|
124
|
-
|
125
|
-
Part of decoupling the core components was extracting all ties to Active Record from Action Pack. This has now been completed. All new ORM plugins now just need to implement Active Model interfaces to work seamlessly with Action Pack.
|
126
|
-
|
127
|
-
More information: - [Make Any Ruby Object Feel Like ActiveRecord](http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/)
|
128
|
-
|
129
|
-
|
130
|
-
### Controller Abstraction
|
131
|
-
|
132
|
-
Another big part of decoupling the core components was creating a base superclass that is separated from the notions of HTTP in order to handle rendering of views etc. This creation of `AbstractController` allowed `ActionController` and `ActionMailer` to be greatly simplified with common code removed from all these libraries and put into Abstract Controller.
|
133
|
-
|
134
|
-
More Information: - [Rails Edge Architecture](http://yehudakatz.com/2009/06/11/rails-edge-architecture/)
|
135
|
-
|
136
|
-
|
137
|
-
### Arel Integration
|
138
|
-
|
139
|
-
[Arel](http://github.com/brynary/arel) (or Active Relation) has been taken on as the underpinnings of Active Record and is now required for Rails. Arel provides an SQL abstraction that simplifies out Active Record and provides the underpinnings for the relation functionality in Active Record.
|
140
|
-
|
141
|
-
More information: - [Why I wrote Arel](https://web.archive.org/web/20120718093140/http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/)
|
142
|
-
|
143
|
-
|
144
|
-
### Mail Extraction
|
145
|
-
|
146
|
-
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 [Mail](http://github.com/mikel/mail) gem. This again reduces code duplication and helps create definable boundaries between Action Mailer and the email parser.
|
147
|
-
|
148
|
-
More information: - [New Action Mailer API in Rails 3](http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3)
|
149
|
-
|
150
|
-
|
151
|
-
Documentation
|
152
|
-
-------------
|
153
|
-
|
154
|
-
The documentation in the Rails tree is being updated with all the API changes, additionally, the [Rails Edge Guides](http://edgeguides.rubyonrails.org/) are being updated one by one to reflect the changes in Rails 3.0. The guides at [guides.rubyonrails.org](http://guides.rubyonrails.org/) however will continue to contain only the stable version of Rails (at this point, version 2.3.5, until 3.0 is released).
|
155
|
-
|
156
|
-
More Information: - [Rails Documentation Projects](http://weblog.rubyonrails.org/2009/1/15/rails-documentation-projects.)
|
157
|
-
|
158
|
-
|
159
|
-
Internationalization
|
160
|
-
--------------------
|
161
|
-
|
162
|
-
A large amount of work has been done with I18n support in Rails 3, including the latest [I18n](http://github.com/svenfuchs/i18n) gem supplying many speed improvements.
|
163
|
-
|
164
|
-
* I18n for any object - I18n behavior can be added to any object by including `ActiveModel::Translation` and `ActiveModel::Validations`. There is also an `errors.messages` fallback for translations.
|
165
|
-
* Attributes can have default translations.
|
166
|
-
* Form Submit Tags automatically pull the correct status (Create or Update) depending on the object status, and so pull the correct translation.
|
167
|
-
* Labels with I18n also now work by just passing the attribute name.
|
168
|
-
|
169
|
-
More Information: - [Rails 3 I18n changes](http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/)
|
170
|
-
|
171
|
-
|
172
|
-
Railties
|
173
|
-
--------
|
174
|
-
|
175
|
-
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:
|
176
|
-
|
177
|
-
* Each application now has its own name space, application is started with `YourAppName.boot` for example, makes interacting with other applications a lot easier.
|
178
|
-
* Anything under `Rails.root/app` is now added to the load path, so you can make `app/observers/user_observer.rb` and Rails will load it without any modifications.
|
179
|
-
* Rails 3.0 now provides a `Rails.config` object, which provides a central repository of all sorts of Rails wide configuration options.
|
180
|
-
|
181
|
-
Application generation has received extra flags allowing you to skip the installation of test-unit, Active Record, Prototype and Git. Also a new `--dev` flag has been added which sets the application up with the `Gemfile` pointing to your Rails checkout (which is determined by the path to the `rails` binary). See `rails --help` for more info.
|
182
|
-
|
183
|
-
Railties generators got a huge amount of attention in Rails 3.0, basically:
|
184
|
-
|
185
|
-
* Generators were completely rewritten and are backwards incompatible.
|
186
|
-
* Rails templates API and generators API were merged (they are the same as the former).
|
187
|
-
* Generators are no longer loaded from special paths anymore, they are just found in the Ruby load path, so calling `rails generate foo` will look for `generators/foo_generator`.
|
188
|
-
* New generators provide hooks, so any template engine, ORM, test framework can easily hook in.
|
189
|
-
* New generators allow you to override the templates by placing a copy at `Rails.root/lib/templates`.
|
190
|
-
* `Rails::Generators::TestCase` is also supplied so you can create your own generators and test them.
|
191
|
-
|
192
|
-
Also, the views generated by Railties generators had some overhaul:
|
193
|
-
|
194
|
-
* Views now use `div` tags instead of `p` tags.
|
195
|
-
* Scaffolds generated now make use of `_form` partials, instead of duplicated code in the edit and new views.
|
196
|
-
* Scaffold forms now use `f.submit` which returns "Create ModelName" or "Update ModelName" depending on the state of the object passed in.
|
197
|
-
|
198
|
-
Finally a couple of enhancements were added to the rake tasks:
|
199
|
-
|
200
|
-
* `rake db:forward` was added, allowing you to roll forward your migrations individually or in groups.
|
201
|
-
* `rake routes CONTROLLER=x` was added allowing you to just view the routes for one controller.
|
202
|
-
|
203
|
-
Railties now deprecates:
|
204
|
-
|
205
|
-
* `RAILS_ROOT` in favor of `Rails.root`,
|
206
|
-
* `RAILS_ENV` in favor of `Rails.env`, and
|
207
|
-
* `RAILS_DEFAULT_LOGGER` in favor of `Rails.logger`.
|
208
|
-
|
209
|
-
`PLUGIN/rails/tasks`, and `PLUGIN/tasks` are no longer loaded all tasks now must be in `PLUGIN/lib/tasks`.
|
210
|
-
|
211
|
-
More information:
|
212
|
-
|
213
|
-
* [Discovering Rails 3 generators](http://blog.plataformatec.com.br/2010/01/discovering-rails-3-generators)
|
214
|
-
* [Making Generators for Rails 3 with Thor](http://caffeinedd.com/guides/331-making-generators-for-rails-3-with-thor)
|
215
|
-
* [The Rails Module (in Rails 3)](http://litanyagainstfear.com/blog/2010/02/03/the-rails-module/)
|
216
|
-
|
217
|
-
Action Pack
|
218
|
-
-----------
|
219
|
-
|
220
|
-
There have been significant internal and external changes in Action Pack.
|
221
|
-
|
222
|
-
|
223
|
-
### Abstract Controller
|
224
|
-
|
225
|
-
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 `ActionMailer::Base` to now just inherit from `AbstractController` and just wrap the Rails DSL onto the Mail gem.
|
226
|
-
|
227
|
-
It also provided an opportunity to clean up Action Controller, abstracting out what could to simplify the code.
|
228
|
-
|
229
|
-
Note however that Abstract Controller is not a user facing API, you will not run into it in your day to day use of Rails.
|
230
|
-
|
231
|
-
More Information: - [Rails Edge Architecture](http://yehudakatz.com/2009/06/11/rails-edge-architecture/)
|
232
|
-
|
233
|
-
|
234
|
-
### Action Controller
|
235
|
-
|
236
|
-
* `application_controller.rb` now has `protect_from_forgery` on by default.
|
237
|
-
* The `cookie_verifier_secret` has been deprecated and now instead it is assigned through `Rails.application.config.cookie_secret` and moved into its own file: `config/initializers/cookie_verification_secret.rb`.
|
238
|
-
* The `session_store` was configured in `ActionController::Base.session`, and that is now moved to `Rails.application.config.session_store`. Defaults are set up in `config/initializers/session_store.rb`.
|
239
|
-
* `cookies.secure` allowing you to set encrypted values in cookies with `cookie.secure[:key] => value`.
|
240
|
-
* `cookies.permanent` allowing you to set permanent values in the cookie hash `cookie.permanent[:key] => value` that raise exceptions on signed values if verification failures.
|
241
|
-
* You can now pass `:notice => 'This is a flash message'` or `:alert => 'Something went wrong'` to the `format` call inside a `respond_to` block. The `flash[]` hash still works as previously.
|
242
|
-
* `respond_with` method has now been added to your controllers simplifying the venerable `format` blocks.
|
243
|
-
* `ActionController::Responder` added allowing you flexibility in how your responses get generated.
|
244
|
-
|
245
|
-
Deprecations:
|
246
|
-
|
247
|
-
* `filter_parameter_logging` is deprecated in favor of `config.filter_parameters << :password`.
|
248
|
-
|
249
|
-
More Information:
|
250
|
-
|
251
|
-
* [Render Options in Rails 3](http://www.engineyard.com/blog/2010/render-options-in-rails-3/)
|
252
|
-
* [Three reasons to love ActionController::Responder](http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder)
|
253
|
-
|
254
|
-
|
255
|
-
### Action Dispatch
|
256
|
-
|
257
|
-
Action Dispatch is new in Rails 3.0 and provides a new, cleaner implementation for routing.
|
258
|
-
|
259
|
-
* Big clean up and re-write of the router, the Rails router is now `rack_mount` with a Rails DSL on top, it is a stand alone piece of software.
|
260
|
-
* Routes defined by each application are now name spaced within your Application module, that is:
|
261
|
-
|
262
|
-
```ruby
|
263
|
-
# Instead of:
|
264
|
-
|
265
|
-
ActionController::Routing::Routes.draw do |map|
|
266
|
-
map.resources :posts
|
267
|
-
end
|
268
|
-
|
269
|
-
# You do:
|
270
|
-
|
271
|
-
AppName::Application.routes do
|
272
|
-
resources :posts
|
273
|
-
end
|
274
|
-
```
|
275
|
-
|
276
|
-
* Added `match` method to the router, you can also pass any Rack application to the matched route.
|
277
|
-
* Added `constraints` method to the router, allowing you to guard routers with defined constraints.
|
278
|
-
* Added `scope` method to the router, allowing you to namespace routes for different languages or different actions, for example:
|
279
|
-
|
280
|
-
```ruby
|
281
|
-
scope 'es' do
|
282
|
-
resources :projects, :path_names => { :edit => 'cambiar' }, :path => 'proyecto'
|
283
|
-
end
|
284
|
-
|
285
|
-
# Gives you the edit action with /es/proyecto/1/cambiar
|
286
|
-
```
|
287
|
-
|
288
|
-
* Added `root` method to the router as a short cut for `match '/', :to => path`.
|
289
|
-
* You can pass optional segments into the match, for example `match "/:controller(/:action(/:id))(.:format)"`, each parenthesized segment is optional.
|
290
|
-
* Routes can be expressed via blocks, for example you can call `controller :home { match '/:action' }`.
|
291
|
-
|
292
|
-
NOTE. The old style `map` commands still work as before with a backwards compatibility layer, however this will be removed in the 3.1 release.
|
293
|
-
|
294
|
-
Deprecations
|
295
|
-
|
296
|
-
* The catch all route for non-REST applications (`/:controller/:action/:id`) is now commented out.
|
297
|
-
* Routes `:path_prefix` no longer exists and `:name_prefix` now automatically adds "_" at the end of the given value.
|
298
|
-
|
299
|
-
More Information:
|
300
|
-
* [The Rails 3 Router: Rack it Up](http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/)
|
301
|
-
* [Revamped Routes in Rails 3](https://medium.com/fusion-of-thoughts/revamped-routes-in-rails-3-b6d00654e5b0)
|
302
|
-
* [Generic Actions in Rails 3](http://yehudakatz.com/2009/12/20/generic-actions-in-rails-3/)
|
303
|
-
|
304
|
-
|
305
|
-
### Action View
|
306
|
-
|
307
|
-
#### Unobtrusive JavaScript
|
308
|
-
|
309
|
-
Major re-write was done in the Action View helpers, implementing Unobtrusive JavaScript (UJS) hooks and removing the old inline AJAX commands. This enables Rails to use any compliant UJS driver to implement the UJS hooks in the helpers.
|
310
|
-
|
311
|
-
What this means is that all previous `remote_<method>` helpers have been removed from Rails core and put into the [Prototype Legacy Helper](http://github.com/rails/prototype_legacy_helper). To get UJS hooks into your HTML, you now pass `:remote => true` instead. For example:
|
312
|
-
|
313
|
-
```ruby
|
314
|
-
form_for @post, :remote => true
|
315
|
-
```
|
316
|
-
|
317
|
-
Produces:
|
318
|
-
|
319
|
-
```html
|
320
|
-
<form action="http://host.com" id="create-post" method="post" data-remote="true">
|
321
|
-
```
|
322
|
-
|
323
|
-
#### Helpers with Blocks
|
324
|
-
|
325
|
-
Helpers like `form_for` or `div_for` that insert content from a block use `<%=` now:
|
326
|
-
|
327
|
-
```html+erb
|
328
|
-
<%= form_for @post do |f| %>
|
329
|
-
...
|
330
|
-
<% end %>
|
331
|
-
```
|
332
|
-
|
333
|
-
Your own helpers of that kind are expected to return a string, rather than appending to the output buffer by hand.
|
334
|
-
|
335
|
-
Helpers that do something else, like `cache` or `content_for`, are not affected by this change, they need `<%` as before.
|
336
|
-
|
337
|
-
#### Other Changes
|
338
|
-
|
339
|
-
* You no longer need to call `h(string)` to escape HTML output, it is on by default in all view templates. If you want the unescaped string, call `raw(string)`.
|
340
|
-
* Helpers now output HTML 5 by default.
|
341
|
-
* Form label helper now pulls values from I18n with a single value, so `f.label :name` will pull the `:name` translation.
|
342
|
-
* I18n select label on should now be :en.helpers.select instead of :en.support.select.
|
343
|
-
* 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 HTML output.
|
344
|
-
* Added `grouped_collection_select` helper to Action View.
|
345
|
-
* `content_for?` has been added allowing you to check for the existence of content in a view before rendering.
|
346
|
-
* passing `:value => nil` to form helpers will set the field's `value` attribute to nil as opposed to using the default value
|
347
|
-
* passing `:id => nil` to form helpers will cause those fields to be rendered with no `id` attribute
|
348
|
-
* passing `:alt => nil` to `image_tag` will cause the `img` tag to render with no `alt` attribute
|
349
|
-
|
350
|
-
Active Model
|
351
|
-
------------
|
352
|
-
|
353
|
-
Active Model is new in Rails 3.0. It provides an abstraction layer for any ORM libraries to use to interact with Rails by implementing an Active Model interface.
|
354
|
-
|
355
|
-
|
356
|
-
### ORM Abstraction and Action Pack Interface
|
357
|
-
|
358
|
-
Part of decoupling the core components was extracting all ties to Active Record from Action Pack. This has now been completed. All new ORM plugins now just need to implement Active Model interfaces to work seamlessly with Action Pack.
|
359
|
-
|
360
|
-
More Information: - [Make Any Ruby Object Feel Like ActiveRecord](http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/)
|
361
|
-
|
362
|
-
|
363
|
-
### Validations
|
364
|
-
|
365
|
-
Validations have been moved from Active Record into Active Model, providing an interface to validations that works across ORM libraries in Rails 3.
|
366
|
-
|
367
|
-
* There is now a `validates :attribute, options_hash` 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.
|
368
|
-
* The `validates` method has the following options:
|
369
|
-
* `:acceptance => Boolean`.
|
370
|
-
* `:confirmation => Boolean`.
|
371
|
-
* `:exclusion => { :in => Enumerable }`.
|
372
|
-
* `:inclusion => { :in => Enumerable }`.
|
373
|
-
* `:format => { :with => Regexp, :on => :create }`.
|
374
|
-
* `:length => { :maximum => Fixnum }`.
|
375
|
-
* `:numericality => Boolean`.
|
376
|
-
* `:presence => Boolean`.
|
377
|
-
* `:uniqueness => Boolean`.
|
378
|
-
|
379
|
-
NOTE: 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 API.
|
380
|
-
|
381
|
-
You can also pass in a validator object, which you can then reuse between objects that use Active Model:
|
382
|
-
|
383
|
-
```ruby
|
384
|
-
class TitleValidator < ActiveModel::EachValidator
|
385
|
-
Titles = ['Mr.', 'Mrs.', 'Dr.']
|
386
|
-
def validate_each(record, attribute, value)
|
387
|
-
unless Titles.include?(value)
|
388
|
-
record.errors[attribute] << 'must be a valid title'
|
389
|
-
end
|
390
|
-
end
|
391
|
-
end
|
392
|
-
```
|
393
|
-
|
394
|
-
```ruby
|
395
|
-
class Person
|
396
|
-
include ActiveModel::Validations
|
397
|
-
attr_accessor :title
|
398
|
-
validates :title, :presence => true, :title => true
|
399
|
-
end
|
400
|
-
|
401
|
-
# Or for Active Record
|
402
|
-
|
403
|
-
class Person < ActiveRecord::Base
|
404
|
-
validates :title, :presence => true, :title => true
|
405
|
-
end
|
406
|
-
```
|
407
|
-
|
408
|
-
There's also support for introspection:
|
409
|
-
|
410
|
-
```ruby
|
411
|
-
User.validators
|
412
|
-
User.validators_on(:login)
|
413
|
-
```
|
414
|
-
|
415
|
-
More Information:
|
416
|
-
|
417
|
-
* [Sexy Validation in Rails 3](http://thelucid.com/2010/01/08/sexy-validation-in-edge-rails-rails-3/)
|
418
|
-
* [Rails 3 Validations Explained](http://lindsaar.net/2010/1/31/validates_rails_3_awesome_is_true)
|
419
|
-
|
420
|
-
|
421
|
-
Active Record
|
422
|
-
-------------
|
423
|
-
|
424
|
-
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 API will be usable through a compatibility layer that will be supported until version 3.1.
|
425
|
-
|
426
|
-
|
427
|
-
### Query Interface
|
428
|
-
|
429
|
-
Active Record, through the use of Arel, now returns relations on its core methods. The existing API 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 API provides the following new methods that all return relations allowing them to be chained together:
|
430
|
-
|
431
|
-
* `where` - provides conditions on the relation, what gets returned.
|
432
|
-
* `select` - choose what attributes of the models you wish to have returned from the database.
|
433
|
-
* `group` - groups the relation on the attribute supplied.
|
434
|
-
* `having` - provides an expression limiting group relations (GROUP BY constraint).
|
435
|
-
* `joins` - joins the relation to another table.
|
436
|
-
* `clause` - provides an expression limiting join relations (JOIN constraint).
|
437
|
-
* `includes` - includes other relations pre-loaded.
|
438
|
-
* `order` - orders the relation based on the expression supplied.
|
439
|
-
* `limit` - limits the relation to the number of records specified.
|
440
|
-
* `lock` - locks the records returned from the table.
|
441
|
-
* `readonly` - returns an read only copy of the data.
|
442
|
-
* `from` - provides a way to select relationships from more than one table.
|
443
|
-
* `scope` - (previously `named_scope`) return relations and can be chained together with the other relation methods.
|
444
|
-
* `with_scope` - and `with_exclusive_scope` now also return relations and so can be chained.
|
445
|
-
* `default_scope` - also works with relations.
|
446
|
-
|
447
|
-
More Information:
|
448
|
-
|
449
|
-
* [Active Record Query Interface](http://m.onkey.org/2010/1/22/active-record-query-interface)
|
450
|
-
* [Let your SQL Growl in Rails 3](http://hasmanyquestions.wordpress.com/2010/01/17/let-your-sql-growl-in-rails-3/)
|
451
|
-
|
452
|
-
|
453
|
-
### Enhancements
|
454
|
-
|
455
|
-
* Added `:destroyed?` to Active Record objects.
|
456
|
-
* Added `:inverse_of` to Active Record associations allowing you to pull the instance of an already loaded association without hitting the database.
|
457
|
-
|
458
|
-
|
459
|
-
### Patches and Deprecations
|
460
|
-
|
461
|
-
Additionally, many fixes in the Active Record branch:
|
462
|
-
|
463
|
-
* SQLite 2 support has been dropped in favor of SQLite 3.
|
464
|
-
* MySQL support for column order.
|
465
|
-
* PostgreSQL adapter has had its `TIME ZONE` support fixed so it no longer inserts incorrect values.
|
466
|
-
* Support multiple schemas in table names for PostgreSQL.
|
467
|
-
* PostgreSQL support for the XML data type column.
|
468
|
-
* `table_name` is now cached.
|
469
|
-
* A large amount of work done on the Oracle adapter as well with many bug fixes.
|
470
|
-
|
471
|
-
As well as the following deprecations:
|
472
|
-
|
473
|
-
* `named_scope` in an Active Record class is deprecated and has been renamed to just `scope`.
|
474
|
-
* In `scope` methods, you should move to using the relation methods, instead of a `:conditions => {}` finder method, for example `scope :since, lambda {|time| where("created_at > ?", time) }`.
|
475
|
-
* `save(false)` is deprecated, in favor of `save(:validate => false)`.
|
476
|
-
* I18n error messages for Active Record should be changed from :en.activerecord.errors.template to `:en.errors.template`.
|
477
|
-
* `model.errors.on` is deprecated in favor of `model.errors[]`
|
478
|
-
* validates_presence_of => validates... :presence => true
|
479
|
-
* `ActiveRecord::Base.colorize_logging` and `config.active_record.colorize_logging` are deprecated in favor of `Rails::LogSubscriber.colorize_logging` or `config.colorize_logging`
|
480
|
-
|
481
|
-
NOTE: 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.
|
482
|
-
|
483
|
-
|
484
|
-
Active Resource
|
485
|
-
---------------
|
486
|
-
|
487
|
-
Active Resource was also extracted out to Active Model allowing you to use Active Resource objects with Action Pack seamlessly.
|
488
|
-
|
489
|
-
* Added validations through Active Model.
|
490
|
-
* Added observing hooks.
|
491
|
-
* HTTP proxy support.
|
492
|
-
* Added support for digest authentication.
|
493
|
-
* Moved model naming into Active Model.
|
494
|
-
* Changed Active Resource attributes to a Hash with indifferent access.
|
495
|
-
* Added `first`, `last` and `all` aliases for equivalent find scopes.
|
496
|
-
* `find_every` now does not return a `ResourceNotFound` error if nothing returned.
|
497
|
-
* Added `save!` which raises `ResourceInvalid` unless the object is `valid?`.
|
498
|
-
* `update_attribute` and `update_attributes` added to Active Resource models.
|
499
|
-
* Added `exists?`.
|
500
|
-
* Renamed `SchemaDefinition` to `Schema` and `define_schema` to `schema`.
|
501
|
-
* Use the `format` of Active Resources rather than the `content-type` of remote errors to load errors.
|
502
|
-
* Use `instance_eval` for schema block.
|
503
|
-
* Fix `ActiveResource::ConnectionError#to_s` when `@response` does not respond to #code or #message, handles Ruby 1.9 compatibility.
|
504
|
-
* Add support for errors in JSON format.
|
505
|
-
* Ensure `load` works with numeric arrays.
|
506
|
-
* Recognizes a 410 response from remote resource as the resource has been deleted.
|
507
|
-
* Add ability to set SSL options on Active Resource connections.
|
508
|
-
* Setting connection timeout also affects `Net::HTTP` `open_timeout`.
|
509
|
-
|
510
|
-
Deprecations:
|
511
|
-
|
512
|
-
* `save(false)` is deprecated, in favor of `save(:validate => false)`.
|
513
|
-
* Ruby 1.9.2: `URI.parse` and `.decode` are deprecated and are no longer used in the library.
|
514
|
-
|
515
|
-
|
516
|
-
Active Support
|
517
|
-
--------------
|
518
|
-
|
519
|
-
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.
|
520
|
-
|
521
|
-
These are the main changes in Active Support:
|
522
|
-
|
523
|
-
* Large clean up of the library removing unused methods throughout.
|
524
|
-
* Active Support no longer provides vendored versions of TZInfo, Memcache Client and Builder. These are all included as dependencies and installed via the `bundle install` command.
|
525
|
-
* Safe buffers are implemented in `ActiveSupport::SafeBuffer`.
|
526
|
-
* Added `Array.uniq_by` and `Array.uniq_by!`.
|
527
|
-
* Removed `Array#rand` and backported `Array#sample` from Ruby 1.9.
|
528
|
-
* Fixed bug on `TimeZone.seconds_to_utc_offset` returning wrong value.
|
529
|
-
* Added `ActiveSupport::Notifications` middleware.
|
530
|
-
* `ActiveSupport.use_standard_json_time_format` now defaults to true.
|
531
|
-
* `ActiveSupport.escape_html_entities_in_json` now defaults to false.
|
532
|
-
* `Integer#multiple_of?` accepts zero as an argument, returns false unless the receiver is zero.
|
533
|
-
* `string.chars` has been renamed to `string.mb_chars`.
|
534
|
-
* `ActiveSupport::OrderedHash` now can de-serialize through YAML.
|
535
|
-
* Added SAX-based parser for XmlMini, using LibXML and Nokogiri.
|
536
|
-
* Added `Object#presence` that returns the object if it's `#present?` otherwise returns `nil`.
|
537
|
-
* Added `String#exclude?` core extension that returns the inverse of `#include?`.
|
538
|
-
* Added `to_i` to `DateTime` in `ActiveSupport` so `to_yaml` works correctly on models with `DateTime` attributes.
|
539
|
-
* Added `Enumerable#exclude?` to bring parity to `Enumerable#include?` and avoid if `!x.include?`.
|
540
|
-
* Switch to on-by-default XSS escaping for rails.
|
541
|
-
* Support deep-merging in `ActiveSupport::HashWithIndifferentAccess`.
|
542
|
-
* `Enumerable#sum` now works will all enumerables, even if they don't respond to `:size`.
|
543
|
-
* `inspect` on a zero length duration returns '0 seconds' instead of empty string.
|
544
|
-
* Add `element` and `collection` to `ModelName`.
|
545
|
-
* `String#to_time` and `String#to_datetime` handle fractional seconds.
|
546
|
-
* Added support to new callbacks for around filter object that respond to `:before` and `:after` used in before and after callbacks.
|
547
|
-
* The `ActiveSupport::OrderedHash#to_a` method returns an ordered set of arrays. Matches Ruby 1.9's `Hash#to_a`.
|
548
|
-
* `MissingSourceFile` exists as a constant but it is now just equal to `LoadError`.
|
549
|
-
* Added `Class#class_attribute`, to be able to declare a class-level attribute whose value is inheritable and overwritable by subclasses.
|
550
|
-
* Finally removed `DeprecatedCallbacks` in `ActiveRecord::Associations`.
|
551
|
-
* `Object#metaclass` is now `Kernel#singleton_class` to match Ruby.
|
552
|
-
|
553
|
-
The following methods have been removed because they are now available in Ruby 1.8.7 and 1.9.
|
554
|
-
|
555
|
-
* `Integer#even?` and `Integer#odd?`
|
556
|
-
* `String#each_char`
|
557
|
-
* `String#start_with?` and `String#end_with?` (3rd person aliases still kept)
|
558
|
-
* `String#bytesize`
|
559
|
-
* `Object#tap`
|
560
|
-
* `Symbol#to_proc`
|
561
|
-
* `Object#instance_variable_defined?`
|
562
|
-
* `Enumerable#none?`
|
563
|
-
|
564
|
-
The security patch for REXML 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.
|
565
|
-
|
566
|
-
The following methods have been removed because they are no longer used in the framework:
|
567
|
-
|
568
|
-
* `Kernel#daemonize`
|
569
|
-
* `Object#remove_subclasses_of` `Object#extend_with_included_modules_from`, `Object#extended_by`
|
570
|
-
* `Class#remove_class`
|
571
|
-
* `Regexp#number_of_captures`, `Regexp.unoptionalize`, `Regexp.optionalize`, `Regexp#number_of_captures`
|
572
|
-
|
573
|
-
|
574
|
-
Action Mailer
|
575
|
-
-------------
|
576
|
-
|
577
|
-
Action Mailer has been given a new API with TMail being replaced out with the new [Mail](http://github.com/mikel/mail) 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 DSL. This reduces the amount of code and duplication of other libraries in Action Mailer considerably.
|
578
|
-
|
579
|
-
* All mailers are now in `app/mailers` by default.
|
580
|
-
* Can now send email using new API with three methods: `attachments`, `headers` and `mail`.
|
581
|
-
* Action Mailer now has native support for inline attachments using the `attachments.inline` method.
|
582
|
-
* Action Mailer emailing methods now return `Mail::Message` objects, which can then be sent the `deliver` message to send itself.
|
583
|
-
* All delivery methods are now abstracted out to the Mail gem.
|
584
|
-
* The mail delivery method can accept a hash of all valid mail header fields with their value pair.
|
585
|
-
* The `mail` delivery method acts in a similar way to Action Controller's `respond_to`, and you can explicitly or implicitly render templates. Action Mailer will turn the email into a multipart email as needed.
|
586
|
-
* You can pass a proc to the `format.mime_type` calls within the mail block and explicitly render specific types of text, or add layouts or different templates. The `render` call inside the proc is from Abstract Controller and supports the same options.
|
587
|
-
* What were mailer unit tests have been moved to functional tests.
|
588
|
-
* Action Mailer now delegates all auto encoding of header fields and bodies to Mail Gem
|
589
|
-
* Action Mailer will auto encode email bodies and headers for you
|
590
|
-
|
591
|
-
Deprecations:
|
592
|
-
|
593
|
-
* `:charset`, `:content_type`, `:mime_version`, `:implicit_parts_order` are all deprecated in favor of `ActionMailer.default :key => value` style declarations.
|
594
|
-
* Mailer dynamic `create_method_name` and `deliver_method_name` are deprecated, just call `method_name` which now returns a `Mail::Message` object.
|
595
|
-
* `ActionMailer.deliver(message)` is deprecated, just call `message.deliver`.
|
596
|
-
* `template_root` is deprecated, pass options to a render call inside a proc from the `format.mime_type` method inside the `mail` generation block
|
597
|
-
* The `body` method to define instance variables is deprecated (`body {:ivar => value}`), just declare instance variables in the method directly and they will be available in the view.
|
598
|
-
* Mailers being in `app/models` is deprecated, use `app/mailers` instead.
|
599
|
-
|
600
|
-
More Information:
|
601
|
-
|
602
|
-
* [New Action Mailer API in Rails 3](http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3)
|
603
|
-
* [New Mail Gem for Ruby](http://lindsaar.net/2010/1/23/mail-gem-version-2-released)
|
604
|
-
|
605
|
-
|
606
|
-
Credits
|
607
|
-
-------
|
608
|
-
|
609
|
-
See the [full list of contributors to Rails](http://contributors.rubyonrails.org/) for the many people who spent many hours making Rails 3. Kudos to all of them.
|
610
|
-
|
611
|
-
Rails 3.0 Release Notes were compiled by [Mikel Lindsaar](http://lindsaar.net).
|