railties 3.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2201 -0
- data/README +286 -0
- data/bin/rails +11 -0
- data/builtin/rails_info/rails/info.rb +147 -0
- data/builtin/rails_info/rails/info_controller.rb +15 -0
- data/builtin/rails_info/rails/info_helper.rb +2 -0
- data/builtin/routes.rb +3 -0
- data/guides/files/javascripts/code_highlighter.js +188 -0
- data/guides/files/javascripts/guides.js +7 -0
- data/guides/files/javascripts/highlighters.js +90 -0
- data/guides/files/stylesheets/main.css +441 -0
- data/guides/files/stylesheets/print.css +52 -0
- data/guides/files/stylesheets/reset.css +43 -0
- data/guides/files/stylesheets/style.css +13 -0
- data/guides/files/stylesheets/syntax.css +31 -0
- data/guides/images/belongs_to.png +0 -0
- data/guides/images/book_icon.gif +0 -0
- data/guides/images/bullet.gif +0 -0
- data/guides/images/chapters_icon.gif +0 -0
- data/guides/images/check_bullet.gif +0 -0
- data/guides/images/credits_pic_blank.gif +0 -0
- data/guides/images/csrf.png +0 -0
- data/guides/images/customized_error_messages.png +0 -0
- data/guides/images/error_messages.png +0 -0
- data/guides/images/feature_tile.gif +0 -0
- data/guides/images/footer_tile.gif +0 -0
- data/guides/images/fxn.png +0 -0
- data/guides/images/grey_bullet.gif +0 -0
- data/guides/images/habtm.png +0 -0
- data/guides/images/has_many.png +0 -0
- data/guides/images/has_many_through.png +0 -0
- data/guides/images/has_one.png +0 -0
- data/guides/images/has_one_through.png +0 -0
- data/guides/images/header_backdrop.png +0 -0
- data/guides/images/header_tile.gif +0 -0
- data/guides/images/i18n/demo_localized_pirate.png +0 -0
- data/guides/images/i18n/demo_translated_en.png +0 -0
- data/guides/images/i18n/demo_translated_pirate.png +0 -0
- data/guides/images/i18n/demo_translation_missing.png +0 -0
- data/guides/images/i18n/demo_untranslated.png +0 -0
- data/guides/images/icons/README +5 -0
- data/guides/images/icons/callouts/1.png +0 -0
- data/guides/images/icons/callouts/10.png +0 -0
- data/guides/images/icons/callouts/11.png +0 -0
- data/guides/images/icons/callouts/12.png +0 -0
- data/guides/images/icons/callouts/13.png +0 -0
- data/guides/images/icons/callouts/14.png +0 -0
- data/guides/images/icons/callouts/15.png +0 -0
- data/guides/images/icons/callouts/2.png +0 -0
- data/guides/images/icons/callouts/3.png +0 -0
- data/guides/images/icons/callouts/4.png +0 -0
- data/guides/images/icons/callouts/5.png +0 -0
- data/guides/images/icons/callouts/6.png +0 -0
- data/guides/images/icons/callouts/7.png +0 -0
- data/guides/images/icons/callouts/8.png +0 -0
- data/guides/images/icons/callouts/9.png +0 -0
- data/guides/images/icons/caution.png +0 -0
- data/guides/images/icons/example.png +0 -0
- data/guides/images/icons/home.png +0 -0
- data/guides/images/icons/important.png +0 -0
- data/guides/images/icons/next.png +0 -0
- data/guides/images/icons/note.png +0 -0
- data/guides/images/icons/prev.png +0 -0
- data/guides/images/icons/tip.png +0 -0
- data/guides/images/icons/up.png +0 -0
- data/guides/images/icons/warning.png +0 -0
- data/guides/images/nav_arrow.gif +0 -0
- data/guides/images/polymorphic.png +0 -0
- data/guides/images/posts_index.png +0 -0
- data/guides/images/rails_guides_logo.gif +0 -0
- data/guides/images/rails_logo_remix.gif +0 -0
- data/guides/images/rails_welcome.png +0 -0
- data/guides/images/session_fixation.png +0 -0
- data/guides/images/tab_grey.gif +0 -0
- data/guides/images/tab_info.gif +0 -0
- data/guides/images/tab_note.gif +0 -0
- data/guides/images/tab_red.gif +0 -0
- data/guides/images/tab_yellow.gif +0 -0
- data/guides/images/tab_yellow.png +0 -0
- data/guides/images/validation_error_messages.png +0 -0
- data/guides/rails_guides.rb +44 -0
- data/guides/rails_guides/generator.rb +178 -0
- data/guides/rails_guides/helpers.rb +34 -0
- data/guides/rails_guides/indexer.rb +55 -0
- data/guides/rails_guides/levenshtein.rb +31 -0
- data/guides/rails_guides/textile_extensions.rb +41 -0
- data/guides/source/2_2_release_notes.textile +422 -0
- data/guides/source/2_3_release_notes.textile +610 -0
- data/guides/source/3_0_release_notes.textile +560 -0
- data/guides/source/action_controller_overview.textile +783 -0
- data/guides/source/action_mailer_basics.textile +437 -0
- data/guides/source/action_view_overview.textile +1481 -0
- data/guides/source/active_record_basics.textile +204 -0
- data/guides/source/active_record_querying.textile +961 -0
- data/guides/source/active_support_core_extensions.textile +1835 -0
- data/guides/source/activerecord_validations_callbacks.textile +1127 -0
- data/guides/source/ajax_on_rails.textile +342 -0
- data/guides/source/association_basics.textile +1816 -0
- data/guides/source/caching_with_rails.textile +390 -0
- data/guides/source/command_line.textile +589 -0
- data/guides/source/configuring.textile +290 -0
- data/guides/source/contribute.textile +71 -0
- data/guides/source/contributing_to_rails.textile +272 -0
- data/guides/source/credits.textile.erb +52 -0
- data/guides/source/debugging_rails_applications.textile +709 -0
- data/guides/source/form_helpers.textile +768 -0
- data/guides/source/generators.textile +378 -0
- data/guides/source/getting_started.textile +1310 -0
- data/guides/source/i18n.textile +879 -0
- data/guides/source/index.textile.erb +124 -0
- data/guides/source/layout.html.erb +103 -0
- data/guides/source/layouts_and_rendering.textile +979 -0
- data/guides/source/migrations.textile +591 -0
- data/guides/source/nested_model_forms.textile +222 -0
- data/guides/source/performance_testing.textile +531 -0
- data/guides/source/plugins.textile +1512 -0
- data/guides/source/rails_application_templates.textile +238 -0
- data/guides/source/rails_on_rack.textile +306 -0
- data/guides/source/routing.textile +903 -0
- data/guides/source/security.textile +984 -0
- data/guides/source/testing.textile +946 -0
- data/lib/generators/erb.rb +8 -0
- data/lib/generators/erb/controller/controller_generator.rb +21 -0
- data/lib/generators/erb/controller/templates/view.html.erb +2 -0
- data/lib/generators/erb/mailer/mailer_generator.rb +20 -0
- data/lib/generators/erb/mailer/templates/view.text.erb +3 -0
- data/lib/generators/erb/scaffold/scaffold_generator.rb +53 -0
- data/lib/generators/erb/scaffold/templates/_form.html.erb +13 -0
- data/lib/generators/erb/scaffold/templates/edit.html.erb +6 -0
- data/lib/generators/erb/scaffold/templates/index.html.erb +27 -0
- data/lib/generators/erb/scaffold/templates/layout.html.erb +16 -0
- data/lib/generators/erb/scaffold/templates/new.html.erb +5 -0
- data/lib/generators/erb/scaffold/templates/show.html.erb +10 -0
- data/lib/generators/rails/app/USAGE +9 -0
- data/lib/generators/rails/app/app_generator.rb +262 -0
- data/lib/generators/rails/app/templates/Gemfile +34 -0
- data/lib/generators/rails/app/templates/README +243 -0
- data/lib/generators/rails/app/templates/Rakefile +10 -0
- data/lib/generators/rails/app/templates/app/controllers/application_controller.rb +3 -0
- data/lib/generators/rails/app/templates/app/helpers/application_helper.rb +2 -0
- data/lib/generators/rails/app/templates/app/models/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/app/views/layouts/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/config.ru +4 -0
- data/lib/generators/rails/app/templates/config/application.rb +51 -0
- data/lib/generators/rails/app/templates/config/boot.rb +17 -0
- data/lib/generators/rails/app/templates/config/databases/frontbase.yml +28 -0
- data/lib/generators/rails/app/templates/config/databases/ibm_db.yml +71 -0
- data/lib/generators/rails/app/templates/config/databases/mysql.yml +60 -0
- data/lib/generators/rails/app/templates/config/databases/oracle.yml +39 -0
- data/lib/generators/rails/app/templates/config/databases/postgresql.yml +51 -0
- data/lib/generators/rails/app/templates/config/databases/sqlite3.yml +22 -0
- data/lib/generators/rails/app/templates/config/environment.rb +5 -0
- data/lib/generators/rails/app/templates/config/environments/development.rb.tt +19 -0
- data/lib/generators/rails/app/templates/config/environments/production.rb.tt +33 -0
- data/lib/generators/rails/app/templates/config/environments/test.rb.tt +29 -0
- data/lib/generators/rails/app/templates/config/initializers/backtrace_silencers.rb +7 -0
- data/lib/generators/rails/app/templates/config/initializers/cookie_verification_secret.rb.tt +7 -0
- data/lib/generators/rails/app/templates/config/initializers/inflections.rb +10 -0
- data/lib/generators/rails/app/templates/config/initializers/mime_types.rb +5 -0
- data/lib/generators/rails/app/templates/config/initializers/session_store.rb.tt +15 -0
- data/lib/generators/rails/app/templates/config/locales/en.yml +5 -0
- data/lib/generators/rails/app/templates/config/routes.rb +58 -0
- data/lib/generators/rails/app/templates/db/seeds.rb +7 -0
- data/lib/generators/rails/app/templates/doc/README_FOR_APP +2 -0
- data/lib/generators/rails/app/templates/gitignore +4 -0
- data/lib/generators/rails/app/templates/public/404.html +26 -0
- data/lib/generators/rails/app/templates/public/422.html +26 -0
- data/lib/generators/rails/app/templates/public/500.html +26 -0
- data/lib/generators/rails/app/templates/public/favicon.ico +0 -0
- data/lib/generators/rails/app/templates/public/images/rails.png +0 -0
- data/lib/generators/rails/app/templates/public/index.html +278 -0
- data/lib/generators/rails/app/templates/public/javascripts/application.js +2 -0
- data/lib/generators/rails/app/templates/public/javascripts/controls.js +963 -0
- data/lib/generators/rails/app/templates/public/javascripts/dragdrop.js +973 -0
- data/lib/generators/rails/app/templates/public/javascripts/effects.js +1128 -0
- data/lib/generators/rails/app/templates/public/javascripts/prototype.js +4320 -0
- data/lib/generators/rails/app/templates/public/javascripts/rails.js +110 -0
- data/lib/generators/rails/app/templates/public/robots.txt +5 -0
- data/lib/generators/rails/app/templates/public/stylesheets/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/script/rails +9 -0
- data/lib/generators/rails/app/templates/test/fixtures/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/test/functional/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/test/integration/.empty_directory +0 -0
- data/lib/generators/rails/app/templates/test/performance/browsing_test.rb +9 -0
- data/lib/generators/rails/app/templates/test/test_helper.rb +13 -0
- data/lib/generators/rails/app/templates/test/unit/.empty_directory +0 -0
- data/lib/generators/rails/controller/USAGE +18 -0
- data/lib/generators/rails/controller/controller_generator.rb +14 -0
- data/lib/generators/rails/controller/templates/controller.rb +7 -0
- data/lib/generators/rails/generator/USAGE +11 -0
- data/lib/generators/rails/generator/generator_generator.rb +25 -0
- data/lib/generators/rails/generator/templates/%file_name%_generator.rb.tt +5 -0
- data/lib/generators/rails/generator/templates/USAGE.tt +8 -0
- data/lib/generators/rails/generator/templates/templates/.empty_directory +0 -0
- data/lib/generators/rails/helper/USAGE +17 -0
- data/lib/generators/rails/helper/helper_generator.rb +13 -0
- data/lib/generators/rails/helper/templates/helper.rb +2 -0
- data/lib/generators/rails/integration_test/USAGE +10 -0
- data/lib/generators/rails/integration_test/integration_test_generator.rb +7 -0
- data/lib/generators/rails/mailer/USAGE +15 -0
- data/lib/generators/rails/mailer/mailer_generator.rb +14 -0
- data/lib/generators/rails/mailer/templates/mailer.rb +16 -0
- data/lib/generators/rails/metal/USAGE +8 -0
- data/lib/generators/rails/metal/metal_generator.rb +11 -0
- data/lib/generators/rails/metal/templates/metal.rb +12 -0
- data/lib/generators/rails/migration/USAGE +29 -0
- data/lib/generators/rails/migration/migration_generator.rb +8 -0
- data/lib/generators/rails/model/USAGE +30 -0
- data/lib/generators/rails/model/model_generator.rb +8 -0
- data/lib/generators/rails/model_subclass/model_subclass_generator.rb +12 -0
- data/lib/generators/rails/observer/USAGE +12 -0
- data/lib/generators/rails/observer/observer_generator.rb +7 -0
- data/lib/generators/rails/performance_test/USAGE +10 -0
- data/lib/generators/rails/performance_test/performance_test_generator.rb +7 -0
- data/lib/generators/rails/plugin/USAGE +13 -0
- data/lib/generators/rails/plugin/plugin_generator.rb +47 -0
- data/lib/generators/rails/plugin/templates/MIT-LICENSE.tt +20 -0
- data/lib/generators/rails/plugin/templates/README.tt +13 -0
- data/lib/generators/rails/plugin/templates/Rakefile.tt +10 -0
- data/lib/generators/rails/plugin/templates/init.rb +1 -0
- data/lib/generators/rails/plugin/templates/install.rb +1 -0
- data/lib/generators/rails/plugin/templates/lib/%file_name%.rb.tt +1 -0
- data/lib/generators/rails/plugin/templates/lib/tasks/%file_name%_tasks.rake.tt +4 -0
- data/lib/generators/rails/plugin/templates/uninstall.rb +1 -0
- data/lib/generators/rails/resource/USAGE +23 -0
- data/lib/generators/rails/resource/resource_generator.rb +34 -0
- data/lib/generators/rails/scaffold/USAGE +29 -0
- data/lib/generators/rails/scaffold/scaffold_generator.rb +13 -0
- data/lib/generators/rails/scaffold_controller/USAGE +20 -0
- data/lib/generators/rails/scaffold_controller/scaffold_controller_generator.rb +27 -0
- data/lib/generators/rails/scaffold_controller/templates/controller.rb +85 -0
- data/lib/generators/rails/session_migration/USAGE +8 -0
- data/lib/generators/rails/session_migration/session_migration_generator.rb +8 -0
- data/lib/generators/rails/stylesheets/USAGE +5 -0
- data/lib/generators/rails/stylesheets/stylesheets_generator.rb +9 -0
- data/lib/generators/rails/stylesheets/templates/scaffold.css +61 -0
- data/lib/generators/test_unit.rb +8 -0
- data/lib/generators/test_unit/controller/controller_generator.rb +14 -0
- data/lib/generators/test_unit/controller/templates/functional_test.rb +8 -0
- data/lib/generators/test_unit/helper/helper_generator.rb +13 -0
- data/lib/generators/test_unit/helper/templates/helper_test.rb +4 -0
- data/lib/generators/test_unit/integration/integration_generator.rb +13 -0
- data/lib/generators/test_unit/integration/templates/integration_test.rb +10 -0
- data/lib/generators/test_unit/mailer/mailer_generator.rb +21 -0
- data/lib/generators/test_unit/mailer/templates/fixture +3 -0
- data/lib/generators/test_unit/mailer/templates/functional_test.rb +22 -0
- data/lib/generators/test_unit/model/model_generator.rb +24 -0
- data/lib/generators/test_unit/model/templates/fixtures.yml +23 -0
- data/lib/generators/test_unit/model/templates/unit_test.rb +8 -0
- data/lib/generators/test_unit/observer/observer_generator.rb +13 -0
- data/lib/generators/test_unit/observer/templates/unit_test.rb +8 -0
- data/lib/generators/test_unit/performance/performance_generator.rb +13 -0
- data/lib/generators/test_unit/performance/templates/performance_test.rb +9 -0
- data/lib/generators/test_unit/plugin/plugin_generator.rb +13 -0
- data/lib/generators/test_unit/plugin/templates/%file_name%_test.rb.tt +8 -0
- data/lib/generators/test_unit/plugin/templates/test_helper.rb +3 -0
- data/lib/generators/test_unit/scaffold/scaffold_generator.rb +18 -0
- data/lib/generators/test_unit/scaffold/templates/functional_test.rb +47 -0
- data/lib/rails.rb +95 -0
- data/lib/rails/all.rb +14 -0
- data/lib/rails/application.rb +125 -0
- data/lib/rails/application/bootstrap.rb +85 -0
- data/lib/rails/application/configurable.rb +19 -0
- data/lib/rails/application/configuration.rb +86 -0
- data/lib/rails/application/finisher.rb +49 -0
- data/lib/rails/application/metal_loader.rb +50 -0
- data/lib/rails/application/railties.rb +31 -0
- data/lib/rails/application/routes_reloader.rb +46 -0
- data/lib/rails/backtrace_cleaner.rb +54 -0
- data/lib/rails/code_statistics.rb +107 -0
- data/lib/rails/commands.rb +72 -0
- data/lib/rails/commands/application.rb +13 -0
- data/lib/rails/commands/console.rb +55 -0
- data/lib/rails/commands/dbconsole.rb +104 -0
- data/lib/rails/commands/destroy.rb +9 -0
- data/lib/rails/commands/generate.rb +9 -0
- data/lib/rails/commands/performance/benchmarker.rb +23 -0
- data/lib/rails/commands/performance/profiler.rb +46 -0
- data/lib/rails/commands/plugin.rb +542 -0
- data/lib/rails/commands/runner.rb +51 -0
- data/lib/rails/commands/server.rb +75 -0
- data/lib/rails/commands/update.rb +9 -0
- data/lib/rails/configuration.rb +191 -0
- data/lib/rails/console/app.rb +33 -0
- data/lib/rails/console/helpers.rb +5 -0
- data/lib/rails/console/sandbox.rb +6 -0
- data/lib/rails/deprecation.rb +62 -0
- data/lib/rails/dispatcher.rb +24 -0
- data/lib/rails/engine.rb +130 -0
- data/lib/rails/engine/configurable.rb +25 -0
- data/lib/rails/engine/configuration.rb +49 -0
- data/lib/rails/generators.rb +289 -0
- data/lib/rails/generators/actions.rb +309 -0
- data/lib/rails/generators/active_model.rb +78 -0
- data/lib/rails/generators/base.rb +362 -0
- data/lib/rails/generators/generated_attribute.rb +48 -0
- data/lib/rails/generators/migration.rb +64 -0
- data/lib/rails/generators/named_base.rb +95 -0
- data/lib/rails/generators/resource_helpers.rb +80 -0
- data/lib/rails/generators/test_case.rb +239 -0
- data/lib/rails/initializable.rb +97 -0
- data/lib/rails/paths.rb +144 -0
- data/lib/rails/performance_test_help.rb +3 -0
- data/lib/rails/plugin.rb +64 -0
- data/lib/rails/rack.rb +8 -0
- data/lib/rails/rack/debugger.rb +23 -0
- data/lib/rails/rack/log_tailer.rb +33 -0
- data/lib/rails/rack/logger.rb +34 -0
- data/lib/rails/rack/static.rb +5 -0
- data/lib/rails/railtie.rb +74 -0
- data/lib/rails/railtie/configurable.rb +23 -0
- data/lib/rails/railtie/configuration.rb +9 -0
- data/lib/rails/railties_path.rb +1 -0
- data/lib/rails/ruby_version_check.rb +10 -0
- data/lib/rails/rubyprof_ext.rb +35 -0
- data/lib/rails/source_annotation_extractor.rb +102 -0
- data/lib/rails/subscriber.rb +108 -0
- data/lib/rails/subscriber/test_helper.rb +98 -0
- data/lib/rails/tasks.rb +16 -0
- data/lib/rails/tasks/annotations.rake +20 -0
- data/lib/rails/tasks/documentation.rake +96 -0
- data/lib/rails/tasks/framework.rake +69 -0
- data/lib/rails/tasks/log.rake +9 -0
- data/lib/rails/tasks/middleware.rake +7 -0
- data/lib/rails/tasks/misc.rake +71 -0
- data/lib/rails/tasks/routes.rake +17 -0
- data/lib/rails/tasks/statistics.rake +16 -0
- data/lib/rails/tasks/tmp.rake +37 -0
- data/lib/rails/test_help.rb +30 -0
- data/lib/rails/test_unit/railtie.rb +17 -0
- data/lib/rails/test_unit/testing.rake +130 -0
- data/lib/rails/version.rb +9 -0
- data/lib/rails/webrick_server.rb +156 -0
- metadata +427 -0
@@ -0,0 +1,560 @@
|
|
1
|
+
h2. Rails 3.0: Release Notes
|
2
|
+
|
3
|
+
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 you it arrived. It's the Best Version of Rails We've Ever Done!
|
4
|
+
|
5
|
+
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.
|
6
|
+
|
7
|
+
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:
|
8
|
+
|
9
|
+
* Brand new router with an emphasis on RESTful declarations
|
10
|
+
* New Action Mailer API modelled after Action Controller (now without the agonizing pain of sending multipart messages!)
|
11
|
+
* New Active Record chainable query language built on top of "Arel":http://github.com/brynary/arel, a relational algebra engine
|
12
|
+
* Unobtrusive JavaScript helpers with drivers for Prototype, jQuery, and more coming (end of inline JS)
|
13
|
+
* Explicit dependency management with Bundler
|
14
|
+
|
15
|
+
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.
|
16
|
+
|
17
|
+
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/master in the main Rails repository on GitHub.
|
18
|
+
|
19
|
+
endprologue.
|
20
|
+
|
21
|
+
WARNING: Rails 3.0 is currently in beta. This means that there are probably bugs and that you should "report them":http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/overview if you see them. You also may not want to run the NORAD nuclear launch application off a beta version. But if you're starting development on a new application and you don't mind getting wind in your hair, please do jump on board!
|
22
|
+
|
23
|
+
h3. Upgrading to Rails 3
|
24
|
+
|
25
|
+
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:
|
26
|
+
|
27
|
+
h4. Rails 3 requires Ruby 1.8.7+
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
h4. Rails Application object
|
32
|
+
|
33
|
+
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.
|
34
|
+
|
35
|
+
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+.
|
36
|
+
|
37
|
+
h4. script/* replaced by script/rails
|
38
|
+
|
39
|
+
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 +rails+ command detects it is being invoked in the root of a Rails application and runs the script for you. Intended usage is:
|
40
|
+
|
41
|
+
<shell>
|
42
|
+
rails console # => ./script/console
|
43
|
+
rails g scaffold post title:string # => ./script/generate scaffold post title:string
|
44
|
+
</shell>
|
45
|
+
|
46
|
+
Run rails --help for a list of all the options.
|
47
|
+
|
48
|
+
h4. Dependencies and config.gem
|
49
|
+
|
50
|
+
The +config.gem+ method is gone and has been replaced by using +bundler+ and a +Gemfile+, see "Vendoring Gems":#vendoring-gems below.
|
51
|
+
|
52
|
+
h4. Upgrade Process
|
53
|
+
|
54
|
+
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.
|
55
|
+
|
56
|
+
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:
|
57
|
+
|
58
|
+
<shell>
|
59
|
+
rails plugin install git://github.com/rails/rails_upgrade.git
|
60
|
+
</shell>
|
61
|
+
|
62
|
+
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
|
63
|
+
|
64
|
+
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!
|
65
|
+
|
66
|
+
More information - "The Path to Rails 3: Approaching the upgrade":http://omgbloglol.com/post/353978923/the-path-to-rails-3-approaching-the-upgrade
|
67
|
+
|
68
|
+
|
69
|
+
h3. Creating a Rails 3.0 application
|
70
|
+
|
71
|
+
The new installing rails sequence (for the beta) is:
|
72
|
+
|
73
|
+
<shell>
|
74
|
+
$ gem install rails --prerelease
|
75
|
+
$ rails myapp
|
76
|
+
$ cd myapp
|
77
|
+
</shell>
|
78
|
+
|
79
|
+
h4. Vendoring Gems
|
80
|
+
|
81
|
+
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.
|
82
|
+
|
83
|
+
More information: - "Using bundler":http://yehudakatz.com/2009/11/03/using-the-new-gem-bundler-today/
|
84
|
+
|
85
|
+
|
86
|
+
h4. Living on the Edge
|
87
|
+
|
88
|
+
+Bundler+ and +Gemfile+ 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.
|
89
|
+
|
90
|
+
If you want to bundle straight from the Git repository, you can pass the edge flag:
|
91
|
+
|
92
|
+
<shell>
|
93
|
+
$ rails myapp --edge
|
94
|
+
</shell>
|
95
|
+
|
96
|
+
More information:
|
97
|
+
* "Spinning up a new Rails app":http://yehudakatz.com/2009/12/31/spinning-up-a-new-rails-app/
|
98
|
+
* "Rails 3 and Passenger":http://cakebaker.42dh.com/2010/01/17/rails-3-and-passenger/
|
99
|
+
|
100
|
+
|
101
|
+
h3. Rails Architectural Changes
|
102
|
+
|
103
|
+
There are six major changes in the architecture of Rails.
|
104
|
+
|
105
|
+
|
106
|
+
h4. Railties Restrung
|
107
|
+
|
108
|
+
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.
|
109
|
+
|
110
|
+
|
111
|
+
h4. All Rails core components are decoupled
|
112
|
+
|
113
|
+
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.
|
114
|
+
|
115
|
+
More information: - "The Great Decoupling":http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
|
116
|
+
|
117
|
+
|
118
|
+
h4. Active Model Abstraction
|
119
|
+
|
120
|
+
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.
|
121
|
+
|
122
|
+
More information: - "Make Any Ruby Object Feel Like ActiveRecord":http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/
|
123
|
+
|
124
|
+
|
125
|
+
h4. Controller Abstraction
|
126
|
+
|
127
|
+
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.
|
128
|
+
|
129
|
+
More Information: - "Rails Edge Architecture":http://yehudakatz.com/2009/06/11/rails-edge-architecture/
|
130
|
+
|
131
|
+
|
132
|
+
h4. Arel Integration
|
133
|
+
|
134
|
+
"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.
|
135
|
+
|
136
|
+
More information: - "Why I wrote Arel":http://magicscalingsprinkles.wordpress.com/2010/01/28/why-i-wrote-arel/.
|
137
|
+
|
138
|
+
|
139
|
+
h4. Mail Extraction
|
140
|
+
|
141
|
+
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.
|
142
|
+
|
143
|
+
More information: - "New Action Mailer API in Rails 3":http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3
|
144
|
+
|
145
|
+
|
146
|
+
h3. Documentation
|
147
|
+
|
148
|
+
The documentation in the Rails tree is being updated with all the API changes, additionally, the "Rails Edge guides":http://guides.rails.info/ 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).
|
149
|
+
|
150
|
+
More Information: - "Rails Documentation Projects":http://weblog.rubyonrails.org/2009/1/15/rails-documentation-projects.
|
151
|
+
|
152
|
+
|
153
|
+
h3. Internationalization
|
154
|
+
|
155
|
+
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.
|
156
|
+
|
157
|
+
* 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.
|
158
|
+
* Attributes can have default translations.
|
159
|
+
* Form Submit Tags automatically pull the correct status (Create or Update) depending on the object status, and so pull the correct translation.
|
160
|
+
* Labels with I18n also now work by just passing the attribute name.
|
161
|
+
|
162
|
+
More Information: - "Rails 3 I18n changes":http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/
|
163
|
+
|
164
|
+
|
165
|
+
h3. Railties
|
166
|
+
|
167
|
+
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:
|
168
|
+
|
169
|
+
* Each application now has it's own name space, application is started with <tt>YourAppName.boot</tt> for example, makes interacting with other applications a lot easier.
|
170
|
+
* 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.
|
171
|
+
* Rails 3.0 now provides a <tt>Rails.config</tt> object, which provides a central repository of all sorts of Rails wide configuration options.
|
172
|
+
|
173
|
+
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 +Gemfile+ pointing to your Rails checkout (which is determined by the path to the +rails+ binary). See <tt>rails --help</tt> for more info.
|
174
|
+
|
175
|
+
Railties generators got a huge amount of attention in Rails 3.0, basically:
|
176
|
+
|
177
|
+
* Generators were completely rewritten and are backwards incompatible.
|
178
|
+
* Rails templates API and generators API were merged (they are the same as the former).
|
179
|
+
* 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>.
|
180
|
+
* New generators provide hooks, so any template engine, ORM, test framework can easily hook in.
|
181
|
+
* New generators allow you to override the templates by placing a copy at <tt>RAILS_ROOT/lib/templates</tt>.
|
182
|
+
* <tt>Rails::Generators::TestCase</tt> is also supplied so you can create your own generators and test them.
|
183
|
+
|
184
|
+
Also, the views generated by Railties generators had some overhaul:
|
185
|
+
|
186
|
+
* Views now use +div+ tags instead of +p+ tags.
|
187
|
+
* Scaffolds generated now make use of <tt>_form</tt> partials, instead of duplicated code in the edit and new views.
|
188
|
+
* Scaffold forms now use <tt>f.submit</tt> which returns "Create ModelName" or "Update ModelName" depending on the state of the object passed in.
|
189
|
+
|
190
|
+
Finally a couple of enhancements were added to the rake tasks:
|
191
|
+
|
192
|
+
* <tt>rake db:forward</tt> was added, allowing you to roll forward your migrations individually or in groups.
|
193
|
+
* <tt>rake routes CONTROLLER=x</tt> was added allowing you to just view the routes for one controller.
|
194
|
+
|
195
|
+
Railties now deprecates:
|
196
|
+
|
197
|
+
* <tt>RAILS_ROOT</tt> in favour of <tt>Rails.root</tt>,
|
198
|
+
* <tt>RAILS_ENV</tt> in favour of <tt>Rails.env</tt>, and
|
199
|
+
* <tt>RAILS_DEFAULT_LOGGER</tt> in favour of <tt>Rails.logger</tt>.
|
200
|
+
|
201
|
+
<tt>PLUGIN/rails/tasks</tt>, and <tt>PLUGIN/tasks</tt> are no longer loaded all tasks now must be in <tt>PLUGIN/lib/tasks</tt>.
|
202
|
+
|
203
|
+
More information:
|
204
|
+
* "Discovering Rails 3 generators":http://blog.plataformatec.com.br/2010/01/discovering-rails-3-generators
|
205
|
+
* "Making Generators for Rails 3 with Thor":http://caffeinedd.com/guides/331-making-generators-for-rails-3-with-thor
|
206
|
+
|
207
|
+
|
208
|
+
h3. Action Pack
|
209
|
+
|
210
|
+
There have been significant internal and external changes in Action Pack.
|
211
|
+
|
212
|
+
|
213
|
+
h4. Abstract Controller
|
214
|
+
|
215
|
+
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 +AbstractController+ and just wrap the Rails DSL onto the Mail gem.
|
216
|
+
|
217
|
+
It also provided an opportunity to clean up Action Controller, abstracting out what could to simplify the code.
|
218
|
+
|
219
|
+
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.
|
220
|
+
|
221
|
+
More Information: - "Rails Edge Architecture":http://yehudakatz.com/2009/06/11/rails-edge-architecture/
|
222
|
+
|
223
|
+
|
224
|
+
h4. Action Controller
|
225
|
+
|
226
|
+
* <tt>application_controller.rb</tt> now has <tt>protect_from_forgery</tt> on by default.
|
227
|
+
* The <tt>cookie_verifier_secret</tt> has been moved to <tt>initializers/cookie_verification_secret.rb</tt>.
|
228
|
+
* The <tt>session_store</tt> configuration has moved to <tt>initializers/session_store.rb</tt>.
|
229
|
+
* <tt>cookies.secure</tt> allowing you to set encrypted values in cookies with <tt>cookie.secure[:key] => value</tt>.
|
230
|
+
* <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.
|
231
|
+
* 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 +respond_to+ block. The <tt>flash[]</tt> hash still works as previously.
|
232
|
+
* <tt>respond_with</tt> method has now been added to your controllers simplifying the venerable +format+ blocks.
|
233
|
+
* <tt>ActionController::Responder</tt> added allowing you flexibility in how your responses get generated.
|
234
|
+
|
235
|
+
Deprecations:
|
236
|
+
|
237
|
+
* <tt>filter_parameter_logging</tt> is deprecated in favour of <tt>config.filter_parameters << :password</tt>.
|
238
|
+
|
239
|
+
More Information:
|
240
|
+
* "Render Options in Rails 3":http://www.engineyard.com/blog/2010/render-options-in-rails-3/
|
241
|
+
* "Three reasons to love ActionController::Responder":http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder
|
242
|
+
|
243
|
+
|
244
|
+
h4. Action Dispatch
|
245
|
+
|
246
|
+
Action Dispatch is new in Rails 3.0 and provides a new, cleaner implementation for routing.
|
247
|
+
|
248
|
+
* 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.
|
249
|
+
* Routes defined by each application are now name spaced within your Application module, that is:
|
250
|
+
|
251
|
+
<ruby>
|
252
|
+
# Instead of:
|
253
|
+
|
254
|
+
ActionController::Routing::Routes.draw do
|
255
|
+
map.resources :posts
|
256
|
+
end
|
257
|
+
|
258
|
+
# You do:
|
259
|
+
|
260
|
+
AppName::Application.routes do
|
261
|
+
resources :posts
|
262
|
+
end
|
263
|
+
</ruby>
|
264
|
+
|
265
|
+
* Added +match+ method to the router, you can also pass any Rack application to the matched route.
|
266
|
+
* Added +constraints+ method to the router, allowing you to guard routers with defined constraints.
|
267
|
+
* Added +scope+ method to the router, allowing you to namespace routes for different languages or different actions, for example:
|
268
|
+
|
269
|
+
<ruby>
|
270
|
+
scope 'es' do
|
271
|
+
resources :projects, :path_names => { :edit => 'cambiar' }, :as => 'projeto'
|
272
|
+
end
|
273
|
+
|
274
|
+
# Gives you the edit action with /es/projeto/1/cambiar
|
275
|
+
</ruby>
|
276
|
+
|
277
|
+
* Added +root+ method to the router as a short cut for <tt>match '/', :to => path</tt>.
|
278
|
+
* You can pass optional segments into the match, for example <tt>match "/:controller(/:action(/:id))(.:format)"</tt>, each parenthesized segment is optional.
|
279
|
+
* Routes can be expressed via blocks, for example you can call <tt>controller :home { match '/:action' }</tt>.
|
280
|
+
|
281
|
+
NOTE. 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.
|
282
|
+
|
283
|
+
Deprecations
|
284
|
+
|
285
|
+
* The catch all route for non-REST applications (<tt>/:controller/:action/:id</tt>) is now commented out.
|
286
|
+
* Routes :path_prefix no longer exists and :name_prefix now automatically adds "_" at the end of the given value.
|
287
|
+
|
288
|
+
More Information:
|
289
|
+
* "The Rails 3 Router: Rack it Up":http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/
|
290
|
+
* "Revamped Routes in Rails 3":http://rizwanreza.com/2009/12/20/revamped-routes-in-rails-3
|
291
|
+
* "Generic Actions in Rails 3":http://yehudakatz.com/2009/12/20/generic-actions-in-rails-3/
|
292
|
+
|
293
|
+
|
294
|
+
h4. Action View
|
295
|
+
|
296
|
+
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.
|
297
|
+
|
298
|
+
What this means is that all previous <tt>remote_<method></tt> 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 <tt>:remote => true</tt> instead. For example:
|
299
|
+
|
300
|
+
<ruby>
|
301
|
+
form_for @post, :remote => true
|
302
|
+
</ruby>
|
303
|
+
|
304
|
+
Produces:
|
305
|
+
|
306
|
+
<html>
|
307
|
+
<form action="http://host.com" id="create-post" method="post" data-remote="true">
|
308
|
+
</html>
|
309
|
+
|
310
|
+
* You no longer need to call <tt>h(string)</tt> to escape HTML output, it is on by default in all view templates. If you want the unescaped string, call <tt>raw(string)</tt>.
|
311
|
+
* Helpers now output HTML 5 by default.
|
312
|
+
* 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.
|
313
|
+
* I18n select label on should now be :en.helpers.select instead of :en.support.select.
|
314
|
+
* 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.
|
315
|
+
* Added +grouped_collection_select+ helper to Action View.
|
316
|
+
* Action View now will raise exceptions if CSS stylesheets and javascript files listed in the +javascript_include_tag+ and +stylesheet_include_tag+ helpers are missing.
|
317
|
+
* +content_for?+ has been added allowing you to check for the existence of content in a view before rendering.
|
318
|
+
|
319
|
+
|
320
|
+
h3. Active Model
|
321
|
+
|
322
|
+
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.
|
323
|
+
|
324
|
+
|
325
|
+
h4. ORM Abstraction and Action Pack Interface
|
326
|
+
|
327
|
+
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.
|
328
|
+
|
329
|
+
More Information: - "Make Any Ruby Object Feel Like ActiveRecord":http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/
|
330
|
+
|
331
|
+
|
332
|
+
h4. Validations
|
333
|
+
|
334
|
+
Validations have been moved from Active Record into Active Model, providing an interface to validations that works across ORM libraries in Rails 3.
|
335
|
+
|
336
|
+
* 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.
|
337
|
+
* The +validates+ method has the following options:
|
338
|
+
* <tt>:acceptance => Boolean</tt>.
|
339
|
+
* <tt>:confirmation => Boolean</tt>.
|
340
|
+
* <tt>:exclusion => { :in => Ennumerable }</tt>.
|
341
|
+
* <tt>:inclusion => { :in => Ennumerable }</tt>.
|
342
|
+
* <tt>:format => { :with => Regexp, :on => :create }</tt>.
|
343
|
+
* <tt>:length => { :maximum => Fixnum }</tt>.
|
344
|
+
* <tt>:numericality => Boolean</tt>.
|
345
|
+
* <tt>:presence => Boolean</tt>.
|
346
|
+
* <tt>:uniqueness => Boolean</tt>.
|
347
|
+
|
348
|
+
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.
|
349
|
+
|
350
|
+
You can also pass in a validator object, which you can then reuse between objects that use Active Model:
|
351
|
+
|
352
|
+
<ruby>
|
353
|
+
class TitleValidator < ActiveModel::EachValidator
|
354
|
+
Titles = ['Mr.', 'Mrs.', 'Dr.']
|
355
|
+
def validate_each(record, attribute, value)
|
356
|
+
unless Titles.include?(value)
|
357
|
+
record.errors[attribute] << 'must be a valid title'
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
361
|
+
</ruby>
|
362
|
+
|
363
|
+
<ruby>
|
364
|
+
class Person
|
365
|
+
include ActiveModel::Validations
|
366
|
+
attr_accessor :title
|
367
|
+
validates :title, :presence => true, :title => true
|
368
|
+
end
|
369
|
+
|
370
|
+
# Or for Active Record
|
371
|
+
|
372
|
+
class Person < ActiveRecord::Base
|
373
|
+
validates :title, :presence => true, :title => true
|
374
|
+
end
|
375
|
+
</ruby>
|
376
|
+
|
377
|
+
More Information:
|
378
|
+
* "Sexy Validation in Rails 3":http://thelucid.com/2010/01/08/sexy-validation-in-edge-rails-rails-3/
|
379
|
+
* "Rails 3 Validations Explained":http://lindsaar.net/2010/1/31/validates_rails_3_awesome_is_true
|
380
|
+
|
381
|
+
|
382
|
+
h3. Active Record
|
383
|
+
|
384
|
+
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.
|
385
|
+
|
386
|
+
|
387
|
+
h4. Query Interface
|
388
|
+
|
389
|
+
Active Record, through the use of Arel, now returns relations on it's 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:
|
390
|
+
|
391
|
+
* <tt>where</tt> - provides conditions on the relation, what gets returned.
|
392
|
+
* <tt>select</tt> - choose what attributes of the models you wish to have returned from the database.
|
393
|
+
* <tt>group</tt> - groups the relation on the attribute supplied.
|
394
|
+
* <tt>having</tt> - provides an expression limiting group relations (GROUP BY constraint).
|
395
|
+
* <tt>joins</tt> - joins the relation to another table.
|
396
|
+
* <tt>clause</tt> - provides an expression limiting join relations (JOIN constraint).
|
397
|
+
* <tt>includes</tt> - includes other relations pre-loaded.
|
398
|
+
* <tt>order</tt> - orders the relation based on the expression supplied.
|
399
|
+
* <tt>limit</tt> - limits the relation to the number of records specified.
|
400
|
+
* <tt>lock</tt> - locks the records returned from the table.
|
401
|
+
* <tt>readonly</tt> - returns an read only copy of the data.
|
402
|
+
* <tt>from</tt> - provides a way to select relationships from more than one table.
|
403
|
+
* <tt>scope</tt> - (previously +named_scope+) return relations and can be chained together with the other relation methods.
|
404
|
+
* <tt>with_scope</tt> - and +with_exclusive_scope+ now also return relations and so can be chained.
|
405
|
+
* <tt>default_scope</tt> - also works with relations.
|
406
|
+
|
407
|
+
More Information:
|
408
|
+
* "Active Record Query Interface":http://m.onkey.org/2010/1/22/active-record-query-interface
|
409
|
+
* "Let your SQL Growl in Rails 3":http://hasmanyquestions.wordpress.com/2010/01/17/let-your-sql-growl-in-rails-3/
|
410
|
+
|
411
|
+
|
412
|
+
h4. Enhancements
|
413
|
+
|
414
|
+
* Added <tt>:destroyed?</tt> to Active Record objects.
|
415
|
+
* Added <tt>:inverse_of</tt> to Active Record associations allowing you to pull the instance of an already loaded association without hitting the database.
|
416
|
+
|
417
|
+
|
418
|
+
h4. Patches and Deprecations
|
419
|
+
|
420
|
+
Additionally, many fixes in the Active Record branch:
|
421
|
+
|
422
|
+
* SQLite 2 support has been dropped in favour of SQLite 3.
|
423
|
+
* MySQL support for column order.
|
424
|
+
* PostgreSQL adapter has had it's +TIME ZONE+ support fixed so it no longer inserts incorrect values.
|
425
|
+
* Support multiple schemas in table names for PostgreSQL.
|
426
|
+
* PostgreSQL support for the XML data type column.
|
427
|
+
* +table_name+ is now cached.
|
428
|
+
* A large amount of work done on the Oracle adapter as well with many bug fixes.
|
429
|
+
|
430
|
+
As well as the following deprecations:
|
431
|
+
|
432
|
+
* +named_scope+ in an Active Record class is deprecated and has been renamed to just +scope+.
|
433
|
+
* In +scope+ 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>.
|
434
|
+
* <tt>save(false)</tt> is deprecated, in favour of <tt>save(:validate => false)</tt>.
|
435
|
+
* I18n error messages for ActiveRecord should be changed from :en.activerecord.errors.template to <tt>:en.errors.template</tt>.
|
436
|
+
* <tt>model.errors.on</tt> is deprecated in favour of <tt>model.errors[]</tt>
|
437
|
+
* validates_presence_of => validates... :presence => true
|
438
|
+
* <tt>ActiveRecord::Base.colorize_logging</tt> and <tt>config.active_record.colorize_logging</tt> are deprecated in favour of <tt>Rails::Subscriber.colorize_logging</tt> or <tt>config.colorize_logging</tt>
|
439
|
+
|
440
|
+
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.
|
441
|
+
|
442
|
+
|
443
|
+
h3. Active Resource
|
444
|
+
|
445
|
+
Active Resource was also extracted out to Active Model allowing you to use Active Resource objects with Action Pack seamlessly.
|
446
|
+
|
447
|
+
* Added validations through Active Model.
|
448
|
+
* Added observing hooks.
|
449
|
+
* HTTP proxy support.
|
450
|
+
* Added support for digest authentication.
|
451
|
+
* Moved model naming into Active Model.
|
452
|
+
* Changed Active Resource attributes to a Hash with indifferent access.
|
453
|
+
* Added +first+, +last+ and +all+ aliases for equivalent find scopes.
|
454
|
+
* <tt>find_every</tt> now does not return a +ResourceNotFound+ error if nothing returned.
|
455
|
+
* Added <tt>save!</tt> which raises <tt>ResourceInvalid</tt> unless the object is <tt>valid?</tt>.
|
456
|
+
* <tt>update_attribute</tt> and <tt>update_attributes</tt> added to Active Resource models.
|
457
|
+
* Added <tt>exists?</tt>.
|
458
|
+
* Renamed <tt>SchemaDefinition</tt> to <tt>Schema</tt> and <tt>define_schema</tt> to <tt>schema</tt>.
|
459
|
+
* Use the <tt>format</tt> of Active Resources rather than the <tt>content-type</tt> of remote errors to load errors.
|
460
|
+
* Use <tt>instance_eval</tt> for schema block.
|
461
|
+
* Fix <tt>ActiveResource::ConnectionError#to_s</tt> when +@response+ does not respond to #code or #message, handles Ruby 1.9 compat.
|
462
|
+
* Add support for errors in JSON format.
|
463
|
+
* Ensure <tt>load</tt> works with numeric arrays.
|
464
|
+
* Recognises a 410 response from remote resource as the resource has been deleted.
|
465
|
+
* Add ability to set SSL options on Active Resource connections.
|
466
|
+
* Setting connection timeout also affects +Net::HTTP+ <tt>open_timeout</tt>.
|
467
|
+
|
468
|
+
Deprecations:
|
469
|
+
|
470
|
+
* <tt>save(false)</tt> is deprecated, in favour of <tt>save(:validate => false)</tt>.
|
471
|
+
* Ruby 1.9.2: <tt>URI.parse</tt> and <tt>.decode</tt> are deprecated and are no longer used in the library.
|
472
|
+
|
473
|
+
|
474
|
+
h3. Active Support
|
475
|
+
|
476
|
+
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.
|
477
|
+
|
478
|
+
These are the main changes in Active Support:
|
479
|
+
|
480
|
+
* Large clean up of the library removing unused methods throughout.
|
481
|
+
* Active Support no longer provides vendored versions of "TZInfo":http://tzinfo.rubyforge.org/, "Memcache Client":http://deveiate.org/projects/RMemCache/ and "Builder":http://builder.rubyforge.org/, these are all included as dependencies and installed via the <tt>gem bundle</tt> command.
|
482
|
+
* Safe buffers are implemented in <tt>ActiveSupport::SafeBuffer</tt>.
|
483
|
+
* Added <tt>Array.uniq_by</tt> and <tt>Array.uniq_by!</tt>.
|
484
|
+
* Fixed bug on +TimeZone.seconds_to_utc_offset+ returning wrong value.
|
485
|
+
* Added <tt>ActiveSupport::Notifications</tt> middleware.
|
486
|
+
* <tt>ActiveSupport.use_standard_json_time_format</tt> now defaults to true.
|
487
|
+
* <tt>ActiveSupport.escape_html_entities_in_json</tt> now defaults to false.
|
488
|
+
* <tt>Integer#multiple_of?</tt> accepts zero as an argument, returns false unless the receiver is zero.
|
489
|
+
* +string.chars+ has been renamed to +string.mb_chars+.
|
490
|
+
* +ActiveSupport::OrderedHash+ now can de-serialize through YAML.
|
491
|
+
* Added SAX-based parser for XmlMini, using LibXML and Nokogiri.
|
492
|
+
* Added <tt>Object#presence</tt> that returns the object if it's <tt>#present?</tt> otherwise returns +nil+.
|
493
|
+
* Added <tt>String#exclude?</tt> core extension that returns the inverse of <tt>#include?</tt>.
|
494
|
+
* Added <tt>to_i</tt> to +DateTime+ in +ActiveSupport+ so <tt>to_yaml</tt> works correctly on models with +DateTime+ attributes.
|
495
|
+
* Added <tt>Enumerable#exclude?</tt> to bring parity to <tt>Enumerable#include?</tt> and avoid if <tt>!x.include?</tt>.
|
496
|
+
* Switch to on-by-default XSS escaping for rails.
|
497
|
+
* Support deep-merging in +ActiveSupport::HashWithIndifferentAccess+.
|
498
|
+
* <tt>Enumerable#sum</tt> now works will all enumerables, even if they don't respond to <tt>:size</tt>.
|
499
|
+
* <tt>inspect</tt> on a zero length duration returns '0 seconds' instead of empty string.
|
500
|
+
* Add <tt>element</tt> and <tt>collection</tt> to <tt>ModelName</tt>.
|
501
|
+
* <tt>String#to_time</tt> and <tt>String#to_datetime</tt> handle fractional seconds.
|
502
|
+
* 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.
|
503
|
+
* The <tt>ActiveSupport::OrderedHash#to_a</tt> method returns an ordered set of arrays. Matches Ruby 1.9's <tt>Hash#to_a</tt>.
|
504
|
+
* <tt>MissingSourceFile</tt> exists as a constant but it is now just equals to <tt>LoadError</tt>
|
505
|
+
* Added <tt>Class#class_attribute</tt>, to be able to declare a class-level attribute whose value is inheritable and overwritable by subclasses.
|
506
|
+
* Finally removed +DeprecatedCallbacks+ in <tt>ActiveRecord::Associations</tt>.
|
507
|
+
|
508
|
+
The following methods have been removed because they are now available in Ruby 1.8.7 and 1.9.
|
509
|
+
|
510
|
+
* <tt>Integer#even?</tt> and <tt>Integer#odd?</tt>
|
511
|
+
* <tt>String#each_char</tt>
|
512
|
+
* <tt>String#start_with?</tt> and <tt>String#end_with?</tt> (3rd person aliases still kept)
|
513
|
+
* <tt>String#bytesize</tt>
|
514
|
+
* <tt>Object#tap</tt>
|
515
|
+
* <tt>Symbol#to_proc</tt>
|
516
|
+
* <tt>Object#instance_variable_defined?</tt>
|
517
|
+
* <tt>Enumerable#none?</tt>
|
518
|
+
|
519
|
+
The security patch for REXML remains in Active Support because early patchlevels of Ruby 1.8.7 still need it. Active Support knows whether it has to apply it or not.
|
520
|
+
|
521
|
+
The following methods have been removed because they are no longer used in the framework:
|
522
|
+
|
523
|
+
* <tt>Object#remove_subclasses_of</tt>, <tt>Object#subclasses_of</tt>, <tt>Object#extend_with_included_modules_from</tt>, <tt>Object#extended_by</tt>
|
524
|
+
* <tt>Class#subclasses</tt>, <tt>Class#reachable?</tt>, <tt>Class#remove_class</tt>
|
525
|
+
* <tt>Regexp#number_of_captures</tt>
|
526
|
+
* <tt>Regexp.unoptionalize</tt>, <tt>Regexp.optionalize</tt>, <tt>Regexp#number_of_captures</tt>
|
527
|
+
|
528
|
+
|
529
|
+
h3. Action Mailer
|
530
|
+
|
531
|
+
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.
|
532
|
+
|
533
|
+
* All mailers are now in <tt>app/mailers</tt> by default.
|
534
|
+
* Can now send email using new API with three methods: +attachments+, +headers+ and +mail+.
|
535
|
+
* ActionMailer emailing methods now return Mail::Message objects, which can then be sent the +deliver+ message to send itself.
|
536
|
+
* All delivery methods are now abstracted out to the Mail gem.
|
537
|
+
* The mail delivery method can accept a hash of all valid mail header fields with their value pair.
|
538
|
+
* The mail delivery method acts in a similar way to Action Controller's respond_to block, and you can explicitly or implicitly render templates. Action Mailer will turn the email into a multipart email as needed.
|
539
|
+
* 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 +render+ call inside the proc is from Abstract Controller, so all the same options are available as they are in Action Controller.
|
540
|
+
* What were mailer unit tests have been moved to functional tests.
|
541
|
+
|
542
|
+
Deprecations:
|
543
|
+
|
544
|
+
* <tt>:charset</tt>, <tt>:content_type</tt>, <tt>:mime_version</tt>, <tt>:implicit_parts_order</tt> are all deprecated in favour of <tt>ActionMailer.default :key => value</tt> style declarations.
|
545
|
+
* 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.
|
546
|
+
* <tt>ActionMailer.deliver(message)</tt> is deprecated, just call <tt>message.deliver</tt>.
|
547
|
+
* <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
|
548
|
+
* The body 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.
|
549
|
+
* Mailers being in <tt>app/models</tt> is deprecated, use <tt>app/mailers</tt> instead.
|
550
|
+
|
551
|
+
More Information:
|
552
|
+
* "New Action Mailer API in Rails 3":http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3
|
553
|
+
* "New Mail Gem for Ruby":http://lindsaar.net/2010/1/23/mail-gem-version-2-released
|
554
|
+
|
555
|
+
|
556
|
+
h3. Credits
|
557
|
+
|
558
|
+
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.
|
559
|
+
|
560
|
+
Rails 3.0 Release Notes were compiled by "Mikel Lindsaar":http://lindsaar.net.
|