aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Gemfile2
-rw-r--r--README.rdoc2
-rw-r--r--actionmailer/actionmailer.gemspec2
-rw-r--r--actionmailer/lib/action_mailer/base.rb8
-rw-r--r--actionmailer/lib/rails/generators/mailer/templates/mailer.rb4
-rw-r--r--actionpack/CHANGELOG.md11
-rw-r--r--actionpack/lib/abstract_controller/layouts.rb20
-rw-r--r--actionpack/lib/abstract_controller/rendering.rb1
-rw-r--r--actionpack/lib/action_controller/base.rb2
-rw-r--r--actionpack/lib/action_controller/caching/actions.rb4
-rw-r--r--actionpack/lib/action_controller/caching/sweeping.rb7
-rw-r--r--actionpack/lib/action_controller/metal/force_ssl.rb2
-rw-r--r--actionpack/lib/action_controller/metal/helpers.rb1
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb135
-rw-r--r--actionpack/lib/action_controller/metal/redirecting.rb2
-rw-r--r--actionpack/lib/action_controller/railtie.rb31
-rw-r--r--actionpack/lib/action_controller/railties/helpers.rb22
-rw-r--r--actionpack/lib/action_controller/railties/paths.rb25
-rw-r--r--actionpack/lib/action_controller/test_case.rb6
-rw-r--r--actionpack/lib/action_dispatch.rb1
-rw-r--r--actionpack/lib/action_dispatch/http/response.rb9
-rw-r--r--actionpack/lib/action_dispatch/middleware/show_exceptions.rb2
-rw-r--r--actionpack/lib/action_dispatch/middleware/ssl.rb70
-rw-r--r--actionpack/lib/action_dispatch/middleware/static.rb1
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb11
-rw-r--r--actionpack/lib/action_dispatch/testing/assertions/response.rb2
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb29
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb15
-rw-r--r--actionpack/lib/action_view/renderer/partial_renderer.rb2
-rw-r--r--actionpack/lib/action_view/template/resolver.rb8
-rw-r--r--actionpack/test/abstract/abstract_controller_test.rb4
-rw-r--r--actionpack/test/abstract/collector_test.rb4
-rw-r--r--actionpack/test/abstract/helper_test.rb4
-rw-r--r--actionpack/test/abstract/layouts_test.rb33
-rw-r--r--actionpack/test/controller/base_test.rb5
-rw-r--r--actionpack/test/controller/http_digest_authentication_test.rb2
-rw-r--r--actionpack/test/controller/redirect_test.rb20
-rw-r--r--actionpack/test/controller/render_test.rb39
-rw-r--r--actionpack/test/controller/request_forgery_protection_test.rb24
-rw-r--r--actionpack/test/controller/sweeper_test.rb16
-rw-r--r--actionpack/test/dispatch/routing_test.rb18
-rw-r--r--actionpack/test/dispatch/ssl_test.rb157
-rw-r--r--actionpack/test/dispatch/static_test.rb4
-rw-r--r--actionpack/test/fixtures/layouts/with_html_partial.html.erb1
-rw-r--r--actionpack/test/fixtures/reply.rb2
-rw-r--r--actionpack/test/fixtures/test/_partial_only_html.html1
-rw-r--r--actionpack/test/fixtures/test/with_html_partial.html.erb1
-rw-r--r--actionpack/test/fixtures/test/with_partial.html.erb1
-rw-r--r--actionpack/test/fixtures/test/with_partial.text.erb1
-rw-r--r--actionpack/test/fixtures/test/with_xml_template.html.erb1
-rw-r--r--actionpack/test/template/active_model_helper_test.rb4
-rw-r--r--actionpack/test/template/date_helper_test.rb28
-rw-r--r--activemodel/lib/active_model/mass_assignment_security/sanitizer.rb12
-rw-r--r--activemodel/lib/active_model/naming.rb5
-rw-r--r--activemodel/test/cases/naming_test.rb24
-rw-r--r--activerecord/CHANGELOG.md31
-rw-r--r--activerecord/lib/active_record/autosave_association.rb9
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract_adapter.rb39
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb2
-rw-r--r--activerecord/lib/active_record/core.rb2
-rw-r--r--activerecord/lib/active_record/fixtures.rb8
-rw-r--r--activerecord/lib/active_record/inheritance.rb14
-rw-r--r--activerecord/lib/active_record/model_schema.rb3
-rw-r--r--activerecord/lib/active_record/railties/databases.rake1
-rw-r--r--activerecord/lib/active_record/relation.rb6
-rw-r--r--activerecord/lib/active_record/scoping/default.rb25
-rw-r--r--activerecord/lib/active_record/scoping/named.rb35
-rw-r--r--activerecord/lib/active_record/validations/uniqueness.rb20
-rw-r--r--activerecord/lib/rails/generators/active_record/migration/templates/migration.rb5
-rw-r--r--activerecord/test/cases/adapters/postgresql/explain_test.rb7
-rw-r--r--activerecord/test/cases/autosave_association_test.rb10
-rw-r--r--activerecord/test/cases/base_test.rb12
-rw-r--r--activerecord/test/cases/fixtures_test.rb2
-rw-r--r--activerecord/test/cases/named_scope_test.rb64
-rw-r--r--activerecord/test/cases/relations_test.rb22
-rw-r--r--activerecord/test/cases/schema_dumper_test.rb2
-rw-r--r--activerecord/test/cases/validations/uniqueness_validation_test.rb12
-rw-r--r--activerecord/test/models/author.rb4
-rw-r--r--activerecord/test/models/bulb.rb2
-rw-r--r--activerecord/test/models/car.rb12
-rw-r--r--activerecord/test/models/categorization.rb2
-rw-r--r--activerecord/test/models/category.rb2
-rw-r--r--activerecord/test/models/comment.rb14
-rw-r--r--activerecord/test/models/developer.rb32
-rw-r--r--activerecord/test/models/organization.rb2
-rw-r--r--activerecord/test/models/person.rb4
-rw-r--r--activerecord/test/models/post.rb16
-rw-r--r--activerecord/test/models/project.rb2
-rw-r--r--activerecord/test/models/reference.rb2
-rw-r--r--activerecord/test/models/reply.rb2
-rw-r--r--activerecord/test/models/topic.rb23
-rw-r--r--activerecord/test/models/toy.rb2
-rw-r--r--activerecord/test/models/without_table.rb2
-rw-r--r--activesupport/lib/active_support/basic_object.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/hash/slice.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/module/delegation.rb16
-rw-r--r--activesupport/lib/active_support/core_ext/object/duplicable.rb13
-rw-r--r--activesupport/lib/active_support/core_ext/proc.rb3
-rw-r--r--activesupport/lib/active_support/dependencies.rb29
-rw-r--r--activesupport/lib/active_support/file_update_checker.rb17
-rw-r--r--activesupport/lib/active_support/hash_with_indifferent_access.rb6
-rw-r--r--activesupport/lib/active_support/log_subscriber.rb8
-rw-r--r--activesupport/lib/active_support/notifications.rb7
-rw-r--r--activesupport/lib/active_support/notifications/fanout.rb103
-rw-r--r--activesupport/lib/active_support/notifications/instrumenter.rb8
-rw-r--r--activesupport/lib/active_support/railtie.rb27
-rw-r--r--activesupport/lib/active_support/rescuable.rb6
-rw-r--r--activesupport/lib/active_support/tagged_logging.rb2
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb13
-rw-r--r--activesupport/test/core_ext/duplicable_test.rb12
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb9
-rw-r--r--activesupport/test/core_ext/proc_test.rb12
-rw-r--r--activesupport/test/file_update_checker_test.rb15
-rw-r--r--activesupport/test/notifications/evented_notification_test.rb67
-rw-r--r--activesupport/test/ordered_options_test.rb1
-rw-r--r--activesupport/test/tagged_logging_test.rb7
-rw-r--r--activesupport/test/time_zone_test.rb17
-rw-r--r--guides/Rakefile11
-rw-r--r--guides/assets/images/belongs_to.png (renamed from railties/guides/assets/images/belongs_to.png)bin34017 -> 34017 bytes
-rw-r--r--guides/assets/images/book_icon.gif (renamed from railties/guides/assets/images/book_icon.gif)bin337 -> 337 bytes
-rw-r--r--guides/assets/images/bullet.gif (renamed from railties/guides/assets/images/bullet.gif)bin60 -> 60 bytes
-rw-r--r--guides/assets/images/challenge.png (renamed from railties/guides/assets/images/challenge.png)bin54134 -> 54134 bytes
-rw-r--r--guides/assets/images/chapters_icon.gif (renamed from railties/guides/assets/images/chapters_icon.gif)bin628 -> 628 bytes
-rw-r--r--guides/assets/images/check_bullet.gif (renamed from railties/guides/assets/images/check_bullet.gif)bin384 -> 384 bytes
-rw-r--r--guides/assets/images/credits_pic_blank.gif (renamed from railties/guides/assets/images/credits_pic_blank.gif)bin613 -> 613 bytes
-rw-r--r--guides/assets/images/csrf.png (renamed from railties/guides/assets/images/csrf.png)bin41996 -> 41996 bytes
-rw-r--r--guides/assets/images/customized_error_messages.png (renamed from railties/guides/assets/images/customized_error_messages.png)bin5055 -> 5055 bytes
-rw-r--r--guides/assets/images/edge_badge.png (renamed from railties/guides/assets/images/edge_badge.png)bin7945 -> 7945 bytes
-rw-r--r--guides/assets/images/error_messages.png (renamed from railties/guides/assets/images/error_messages.png)bin14645 -> 14645 bytes
-rw-r--r--guides/assets/images/feature_tile.gif (renamed from railties/guides/assets/images/feature_tile.gif)bin43 -> 43 bytes
-rw-r--r--guides/assets/images/footer_tile.gif (renamed from railties/guides/assets/images/footer_tile.gif)bin44 -> 44 bytes
-rw-r--r--guides/assets/images/fxn.png (renamed from railties/guides/assets/images/fxn.png)bin20664 -> 20664 bytes
-rw-r--r--guides/assets/images/getting_started/new_post.pngbin0 -> 14334 bytes
-rw-r--r--guides/assets/images/getting_started/routing_error_no_controller.pngbin0 -> 15744 bytes
-rw-r--r--guides/assets/images/getting_started/routing_error_no_route_matches.pngbin0 -> 16065 bytes
-rw-r--r--guides/assets/images/getting_started/template_is_missing_posts_new.pngbin0 -> 15168 bytes
-rw-r--r--guides/assets/images/getting_started/unknown_action_create_for_posts.pngbin0 -> 12652 bytes
-rw-r--r--guides/assets/images/getting_started/unknown_action_new_for_posts.pngbin0 -> 12756 bytes
-rw-r--r--guides/assets/images/grey_bullet.gif (renamed from railties/guides/assets/images/grey_bullet.gif)bin45 -> 45 bytes
-rw-r--r--guides/assets/images/habtm.png (renamed from railties/guides/assets/images/habtm.png)bin63801 -> 63801 bytes
-rw-r--r--guides/assets/images/has_many.png (renamed from railties/guides/assets/images/has_many.png)bin38582 -> 38582 bytes
-rw-r--r--guides/assets/images/has_many_through.png (renamed from railties/guides/assets/images/has_many_through.png)bin100220 -> 100220 bytes
-rw-r--r--guides/assets/images/has_one.png (renamed from railties/guides/assets/images/has_one.png)bin39022 -> 39022 bytes
-rw-r--r--guides/assets/images/has_one_through.png (renamed from railties/guides/assets/images/has_one_through.png)bin92594 -> 92594 bytes
-rw-r--r--guides/assets/images/header_backdrop.png (renamed from railties/guides/assets/images/header_backdrop.png)bin882 -> 882 bytes
-rw-r--r--guides/assets/images/header_tile.gif (renamed from railties/guides/assets/images/header_tile.gif)bin44 -> 44 bytes
-rw-r--r--guides/assets/images/i18n/demo_html_safe.png (renamed from railties/guides/assets/images/i18n/demo_html_safe.png)bin11946 -> 11946 bytes
-rw-r--r--guides/assets/images/i18n/demo_localized_pirate.png (renamed from railties/guides/assets/images/i18n/demo_localized_pirate.png)bin15027 -> 15027 bytes
-rw-r--r--guides/assets/images/i18n/demo_translated_en.png (renamed from railties/guides/assets/images/i18n/demo_translated_en.png)bin12057 -> 12057 bytes
-rw-r--r--guides/assets/images/i18n/demo_translated_pirate.png (renamed from railties/guides/assets/images/i18n/demo_translated_pirate.png)bin13392 -> 13392 bytes
-rw-r--r--guides/assets/images/i18n/demo_translation_missing.png (renamed from railties/guides/assets/images/i18n/demo_translation_missing.png)bin13143 -> 13143 bytes
-rw-r--r--guides/assets/images/i18n/demo_untranslated.png (renamed from railties/guides/assets/images/i18n/demo_untranslated.png)bin11925 -> 11925 bytes
-rw-r--r--guides/assets/images/icons/README (renamed from railties/guides/assets/images/icons/README)0
-rw-r--r--guides/assets/images/icons/callouts/1.png (renamed from railties/guides/assets/images/icons/callouts/1.png)bin329 -> 329 bytes
-rw-r--r--guides/assets/images/icons/callouts/10.png (renamed from railties/guides/assets/images/icons/callouts/10.png)bin361 -> 361 bytes
-rw-r--r--guides/assets/images/icons/callouts/11.png (renamed from railties/guides/assets/images/icons/callouts/11.png)bin565 -> 565 bytes
-rw-r--r--guides/assets/images/icons/callouts/12.png (renamed from railties/guides/assets/images/icons/callouts/12.png)bin617 -> 617 bytes
-rw-r--r--guides/assets/images/icons/callouts/13.png (renamed from railties/guides/assets/images/icons/callouts/13.png)bin623 -> 623 bytes
-rw-r--r--guides/assets/images/icons/callouts/14.png (renamed from railties/guides/assets/images/icons/callouts/14.png)bin411 -> 411 bytes
-rw-r--r--guides/assets/images/icons/callouts/15.png (renamed from railties/guides/assets/images/icons/callouts/15.png)bin640 -> 640 bytes
-rw-r--r--guides/assets/images/icons/callouts/2.png (renamed from railties/guides/assets/images/icons/callouts/2.png)bin353 -> 353 bytes
-rw-r--r--guides/assets/images/icons/callouts/3.png (renamed from railties/guides/assets/images/icons/callouts/3.png)bin350 -> 350 bytes
-rw-r--r--guides/assets/images/icons/callouts/4.png (renamed from railties/guides/assets/images/icons/callouts/4.png)bin345 -> 345 bytes
-rw-r--r--guides/assets/images/icons/callouts/5.png (renamed from railties/guides/assets/images/icons/callouts/5.png)bin348 -> 348 bytes
-rw-r--r--guides/assets/images/icons/callouts/6.png (renamed from railties/guides/assets/images/icons/callouts/6.png)bin355 -> 355 bytes
-rw-r--r--guides/assets/images/icons/callouts/7.png (renamed from railties/guides/assets/images/icons/callouts/7.png)bin344 -> 344 bytes
-rw-r--r--guides/assets/images/icons/callouts/8.png (renamed from railties/guides/assets/images/icons/callouts/8.png)bin357 -> 357 bytes
-rw-r--r--guides/assets/images/icons/callouts/9.png (renamed from railties/guides/assets/images/icons/callouts/9.png)bin357 -> 357 bytes
-rw-r--r--guides/assets/images/icons/caution.png (renamed from railties/guides/assets/images/icons/caution.png)bin2554 -> 2554 bytes
-rw-r--r--guides/assets/images/icons/example.png (renamed from railties/guides/assets/images/icons/example.png)bin2354 -> 2354 bytes
-rw-r--r--guides/assets/images/icons/home.png (renamed from railties/guides/assets/images/icons/home.png)bin1340 -> 1340 bytes
-rw-r--r--guides/assets/images/icons/important.png (renamed from railties/guides/assets/images/icons/important.png)bin2657 -> 2657 bytes
-rw-r--r--guides/assets/images/icons/next.png (renamed from railties/guides/assets/images/icons/next.png)bin1302 -> 1302 bytes
-rw-r--r--guides/assets/images/icons/note.png (renamed from railties/guides/assets/images/icons/note.png)bin2730 -> 2730 bytes
-rw-r--r--guides/assets/images/icons/prev.png (renamed from railties/guides/assets/images/icons/prev.png)bin1348 -> 1348 bytes
-rw-r--r--guides/assets/images/icons/tip.png (renamed from railties/guides/assets/images/icons/tip.png)bin2602 -> 2602 bytes
-rw-r--r--guides/assets/images/icons/up.png (renamed from railties/guides/assets/images/icons/up.png)bin1320 -> 1320 bytes
-rw-r--r--guides/assets/images/icons/warning.png (renamed from railties/guides/assets/images/icons/warning.png)bin2828 -> 2828 bytes
-rw-r--r--guides/assets/images/jaimeiniesta.jpg (renamed from railties/guides/assets/images/jaimeiniesta.jpg)bin11913 -> 11913 bytes
-rw-r--r--guides/assets/images/nav_arrow.gif (renamed from railties/guides/assets/images/nav_arrow.gif)bin427 -> 427 bytes
-rw-r--r--guides/assets/images/polymorphic.png (renamed from railties/guides/assets/images/polymorphic.png)bin85248 -> 85248 bytes
-rw-r--r--guides/assets/images/posts_index.png (renamed from railties/guides/assets/images/posts_index.png)bin60846 -> 60846 bytes
-rw-r--r--guides/assets/images/radar.png (renamed from railties/guides/assets/images/radar.png)bin19521 -> 19521 bytes
-rw-r--r--guides/assets/images/rails_guides_kindle_cover.jpg (renamed from railties/guides/assets/images/rails_guides_kindle_cover.jpg)bin31785 -> 31785 bytes
-rw-r--r--guides/assets/images/rails_guides_logo.gif (renamed from railties/guides/assets/images/rails_guides_logo.gif)bin5114 -> 5114 bytes
-rw-r--r--guides/assets/images/rails_logo_remix.gif (renamed from railties/guides/assets/images/rails_logo_remix.gif)bin8533 -> 8533 bytes
-rw-r--r--guides/assets/images/rails_welcome.png (renamed from railties/guides/assets/images/rails_welcome.png)bin121314 -> 121314 bytes
-rw-r--r--guides/assets/images/session_fixation.png (renamed from railties/guides/assets/images/session_fixation.png)bin47860 -> 47860 bytes
-rw-r--r--guides/assets/images/tab_grey.gif (renamed from railties/guides/assets/images/tab_grey.gif)bin4924 -> 4924 bytes
-rw-r--r--guides/assets/images/tab_info.gif (renamed from railties/guides/assets/images/tab_info.gif)bin4762 -> 4762 bytes
-rw-r--r--guides/assets/images/tab_note.gif (renamed from railties/guides/assets/images/tab_note.gif)bin4807 -> 4807 bytes
-rw-r--r--guides/assets/images/tab_red.gif (renamed from railties/guides/assets/images/tab_red.gif)bin4753 -> 4753 bytes
-rw-r--r--guides/assets/images/tab_yellow.gif (renamed from railties/guides/assets/images/tab_yellow.gif)bin4759 -> 4759 bytes
-rw-r--r--guides/assets/images/tab_yellow.png (renamed from railties/guides/assets/images/tab_yellow.png)bin1611 -> 1611 bytes
-rw-r--r--guides/assets/images/validation_error_messages.png (renamed from railties/guides/assets/images/validation_error_messages.png)bin1107 -> 1107 bytes
-rw-r--r--guides/assets/images/vijaydev.jpg (renamed from railties/guides/assets/images/vijaydev.jpg)bin4610 -> 4610 bytes
-rw-r--r--guides/assets/javascripts/guides.js (renamed from railties/guides/assets/javascripts/guides.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushBash.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushCss.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushJava.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushPython.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushSass.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushScala.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushSql.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushVb.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shBrushXml.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js)0
-rw-r--r--guides/assets/javascripts/syntaxhighlighter/shCore.js (renamed from railties/guides/assets/javascripts/syntaxhighlighter/shCore.js)0
-rw-r--r--guides/assets/stylesheets/fixes.css (renamed from railties/guides/assets/stylesheets/fixes.css)0
-rw-r--r--guides/assets/stylesheets/kindle.css (renamed from railties/guides/assets/stylesheets/kindle.css)0
-rw-r--r--guides/assets/stylesheets/main.css (renamed from railties/guides/assets/stylesheets/main.css)0
-rw-r--r--guides/assets/stylesheets/print.css (renamed from railties/guides/assets/stylesheets/print.css)0
-rw-r--r--guides/assets/stylesheets/reset.css (renamed from railties/guides/assets/stylesheets/reset.css)0
-rw-r--r--guides/assets/stylesheets/style.css (renamed from railties/guides/assets/stylesheets/style.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shCore.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shCore.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css)0
-rwxr-xr-xguides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css)0
-rw-r--r--guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css (renamed from railties/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css)0
-rw-r--r--guides/code/getting_started/Gemfile (renamed from railties/guides/code/getting_started/Gemfile)0
-rw-r--r--guides/code/getting_started/README.rdoc (renamed from railties/guides/code/getting_started/README.rdoc)0
-rw-r--r--guides/code/getting_started/Rakefile (renamed from railties/guides/code/getting_started/Rakefile)0
-rw-r--r--guides/code/getting_started/app/assets/images/rails.png (renamed from railties/guides/code/getting_started/app/assets/images/rails.png)bin6646 -> 6646 bytes
-rw-r--r--guides/code/getting_started/app/assets/javascripts/application.js (renamed from railties/guides/code/getting_started/app/assets/javascripts/application.js)0
-rw-r--r--guides/code/getting_started/app/assets/javascripts/comments.js.coffee (renamed from railties/guides/code/getting_started/app/assets/javascripts/comments.js.coffee)0
-rw-r--r--guides/code/getting_started/app/assets/javascripts/home.js.coffee (renamed from railties/guides/code/getting_started/app/assets/javascripts/home.js.coffee)0
-rw-r--r--guides/code/getting_started/app/assets/javascripts/posts.js.coffee (renamed from railties/guides/code/getting_started/app/assets/javascripts/posts.js.coffee)0
-rw-r--r--guides/code/getting_started/app/assets/stylesheets/application.css (renamed from railties/guides/code/getting_started/app/assets/stylesheets/application.css)0
-rw-r--r--guides/code/getting_started/app/assets/stylesheets/comments.css.scss (renamed from railties/guides/code/getting_started/app/assets/stylesheets/comments.css.scss)0
-rw-r--r--guides/code/getting_started/app/assets/stylesheets/home.css.scss (renamed from railties/guides/code/getting_started/app/assets/stylesheets/home.css.scss)0
-rw-r--r--guides/code/getting_started/app/assets/stylesheets/posts.css.scss (renamed from railties/guides/code/getting_started/app/assets/stylesheets/posts.css.scss)0
-rw-r--r--guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss (renamed from railties/guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss)0
-rw-r--r--guides/code/getting_started/app/controllers/application_controller.rb (renamed from railties/guides/code/getting_started/app/controllers/application_controller.rb)0
-rw-r--r--guides/code/getting_started/app/controllers/comments_controller.rb (renamed from railties/guides/code/getting_started/app/controllers/comments_controller.rb)0
-rw-r--r--guides/code/getting_started/app/controllers/home_controller.rb (renamed from railties/guides/code/getting_started/app/controllers/home_controller.rb)0
-rw-r--r--guides/code/getting_started/app/controllers/posts_controller.rb (renamed from railties/guides/code/getting_started/app/controllers/posts_controller.rb)0
-rw-r--r--guides/code/getting_started/app/helpers/application_helper.rb (renamed from railties/guides/code/getting_started/app/helpers/application_helper.rb)0
-rw-r--r--guides/code/getting_started/app/helpers/comments_helper.rb (renamed from railties/guides/code/getting_started/app/helpers/comments_helper.rb)0
-rw-r--r--guides/code/getting_started/app/helpers/home_helper.rb (renamed from railties/guides/code/getting_started/app/helpers/home_helper.rb)0
-rw-r--r--guides/code/getting_started/app/helpers/posts_helper.rb (renamed from railties/guides/code/getting_started/app/helpers/posts_helper.rb)0
-rw-r--r--guides/code/getting_started/app/mailers/.gitkeep (renamed from railties/guides/code/getting_started/app/mailers/.gitkeep)0
-rw-r--r--guides/code/getting_started/app/models/.gitkeep (renamed from railties/guides/code/getting_started/app/models/.gitkeep)0
-rw-r--r--guides/code/getting_started/app/models/comment.rb (renamed from railties/guides/code/getting_started/app/models/comment.rb)0
-rw-r--r--guides/code/getting_started/app/models/post.rb (renamed from railties/guides/code/getting_started/app/models/post.rb)0
-rw-r--r--guides/code/getting_started/app/models/tag.rb (renamed from railties/guides/code/getting_started/app/models/tag.rb)0
-rw-r--r--guides/code/getting_started/app/views/comments/_comment.html.erb (renamed from railties/guides/code/getting_started/app/views/comments/_comment.html.erb)0
-rw-r--r--guides/code/getting_started/app/views/comments/_form.html.erb (renamed from railties/guides/code/getting_started/app/views/comments/_form.html.erb)0
-rw-r--r--guides/code/getting_started/app/views/home/index.html.erb (renamed from railties/guides/code/getting_started/app/views/home/index.html.erb)0
-rw-r--r--guides/code/getting_started/app/views/layouts/application.html.erb (renamed from railties/guides/code/getting_started/app/views/layouts/application.html.erb)0
-rw-r--r--guides/code/getting_started/app/views/posts/_form.html.erb (renamed from railties/guides/code/getting_started/app/views/posts/_form.html.erb)0
-rw-r--r--guides/code/getting_started/app/views/posts/edit.html.erb (renamed from railties/guides/code/getting_started/app/views/posts/edit.html.erb)0
-rw-r--r--guides/code/getting_started/app/views/posts/index.html.erb (renamed from railties/guides/code/getting_started/app/views/posts/index.html.erb)0
-rw-r--r--guides/code/getting_started/app/views/posts/new.html.erb (renamed from railties/guides/code/getting_started/app/views/posts/new.html.erb)0
-rw-r--r--guides/code/getting_started/app/views/posts/show.html.erb (renamed from railties/guides/code/getting_started/app/views/posts/show.html.erb)0
-rw-r--r--guides/code/getting_started/app/views/tags/_form.html.erb (renamed from railties/guides/code/getting_started/app/views/tags/_form.html.erb)0
-rw-r--r--guides/code/getting_started/config.ru (renamed from railties/guides/code/getting_started/config.ru)0
-rw-r--r--guides/code/getting_started/config/application.rb (renamed from railties/guides/code/getting_started/config/application.rb)0
-rw-r--r--guides/code/getting_started/config/boot.rb (renamed from railties/guides/code/getting_started/config/boot.rb)0
-rw-r--r--guides/code/getting_started/config/database.yml (renamed from railties/guides/code/getting_started/config/database.yml)0
-rw-r--r--guides/code/getting_started/config/environment.rb (renamed from railties/guides/code/getting_started/config/environment.rb)0
-rw-r--r--guides/code/getting_started/config/environments/development.rb (renamed from railties/guides/code/getting_started/config/environments/development.rb)0
-rw-r--r--guides/code/getting_started/config/environments/production.rb (renamed from railties/guides/code/getting_started/config/environments/production.rb)0
-rw-r--r--guides/code/getting_started/config/environments/test.rb (renamed from railties/guides/code/getting_started/config/environments/test.rb)0
-rw-r--r--guides/code/getting_started/config/initializers/backtrace_silencers.rb (renamed from railties/guides/code/getting_started/config/initializers/backtrace_silencers.rb)0
-rw-r--r--guides/code/getting_started/config/initializers/inflections.rb (renamed from railties/guides/code/getting_started/config/initializers/inflections.rb)0
-rw-r--r--guides/code/getting_started/config/initializers/mime_types.rb (renamed from railties/guides/code/getting_started/config/initializers/mime_types.rb)0
-rw-r--r--guides/code/getting_started/config/initializers/secret_token.rb (renamed from railties/guides/code/getting_started/config/initializers/secret_token.rb)0
-rw-r--r--guides/code/getting_started/config/initializers/session_store.rb (renamed from railties/guides/code/getting_started/config/initializers/session_store.rb)0
-rw-r--r--guides/code/getting_started/config/initializers/wrap_parameters.rb (renamed from railties/guides/code/getting_started/config/initializers/wrap_parameters.rb)0
-rw-r--r--guides/code/getting_started/config/locales/en.yml (renamed from railties/guides/code/getting_started/config/locales/en.yml)0
-rw-r--r--guides/code/getting_started/config/routes.rb (renamed from railties/guides/code/getting_started/config/routes.rb)0
-rw-r--r--guides/code/getting_started/db/migrate/20110901012504_create_posts.rb (renamed from railties/guides/code/getting_started/db/migrate/20110901012504_create_posts.rb)0
-rw-r--r--guides/code/getting_started/db/migrate/20110901012815_create_comments.rb (renamed from railties/guides/code/getting_started/db/migrate/20110901012815_create_comments.rb)0
-rw-r--r--guides/code/getting_started/db/migrate/20110901013701_create_tags.rb (renamed from railties/guides/code/getting_started/db/migrate/20110901013701_create_tags.rb)0
-rw-r--r--guides/code/getting_started/db/schema.rb (renamed from railties/guides/code/getting_started/db/schema.rb)0
-rw-r--r--guides/code/getting_started/db/seeds.rb (renamed from railties/guides/code/getting_started/db/seeds.rb)0
-rw-r--r--guides/code/getting_started/doc/README_FOR_APP (renamed from railties/guides/code/getting_started/doc/README_FOR_APP)0
-rw-r--r--guides/code/getting_started/lib/assets/.gitkeep (renamed from railties/guides/code/getting_started/lib/assets/.gitkeep)0
-rw-r--r--guides/code/getting_started/lib/tasks/.gitkeep (renamed from railties/guides/code/getting_started/lib/tasks/.gitkeep)0
-rw-r--r--guides/code/getting_started/public/404.html (renamed from railties/guides/code/getting_started/public/404.html)0
-rw-r--r--guides/code/getting_started/public/422.html (renamed from railties/guides/code/getting_started/public/422.html)0
-rw-r--r--guides/code/getting_started/public/500.html (renamed from railties/guides/code/getting_started/public/500.html)0
-rw-r--r--guides/code/getting_started/public/favicon.ico (renamed from railties/guides/code/getting_started/public/favicon.ico)0
-rw-r--r--guides/code/getting_started/public/robots.txt (renamed from railties/guides/code/getting_started/public/robots.txt)0
-rwxr-xr-xguides/code/getting_started/script/rails (renamed from railties/guides/code/getting_started/script/rails)0
-rw-r--r--guides/code/getting_started/test/fixtures/.gitkeep (renamed from railties/guides/code/getting_started/test/fixtures/.gitkeep)0
-rw-r--r--guides/code/getting_started/test/fixtures/comments.yml (renamed from railties/guides/code/getting_started/test/fixtures/comments.yml)0
-rw-r--r--guides/code/getting_started/test/fixtures/posts.yml (renamed from railties/guides/code/getting_started/test/fixtures/posts.yml)0
-rw-r--r--guides/code/getting_started/test/fixtures/tags.yml (renamed from railties/guides/code/getting_started/test/fixtures/tags.yml)0
-rw-r--r--guides/code/getting_started/test/functional/.gitkeep (renamed from railties/guides/code/getting_started/test/functional/.gitkeep)0
-rw-r--r--guides/code/getting_started/test/functional/comments_controller_test.rb (renamed from railties/guides/code/getting_started/test/functional/comments_controller_test.rb)0
-rw-r--r--guides/code/getting_started/test/functional/home_controller_test.rb (renamed from railties/guides/code/getting_started/test/functional/home_controller_test.rb)0
-rw-r--r--guides/code/getting_started/test/functional/posts_controller_test.rb (renamed from railties/guides/code/getting_started/test/functional/posts_controller_test.rb)0
-rw-r--r--guides/code/getting_started/test/integration/.gitkeep (renamed from railties/guides/code/getting_started/test/integration/.gitkeep)0
-rw-r--r--guides/code/getting_started/test/performance/browsing_test.rb (renamed from railties/guides/code/getting_started/test/performance/browsing_test.rb)0
-rw-r--r--guides/code/getting_started/test/test_helper.rb (renamed from railties/guides/code/getting_started/test/test_helper.rb)0
-rw-r--r--guides/code/getting_started/test/unit/.gitkeep (renamed from railties/guides/code/getting_started/test/unit/.gitkeep)0
-rw-r--r--guides/code/getting_started/test/unit/comment_test.rb (renamed from railties/guides/code/getting_started/test/unit/comment_test.rb)0
-rw-r--r--guides/code/getting_started/test/unit/helpers/comments_helper_test.rb (renamed from railties/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb)0
-rw-r--r--guides/code/getting_started/test/unit/helpers/home_helper_test.rb (renamed from railties/guides/code/getting_started/test/unit/helpers/home_helper_test.rb)0
-rw-r--r--guides/code/getting_started/test/unit/helpers/posts_helper_test.rb (renamed from railties/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb)0
-rw-r--r--guides/code/getting_started/test/unit/post_test.rb (renamed from railties/guides/code/getting_started/test/unit/post_test.rb)0
-rw-r--r--guides/code/getting_started/test/unit/tag_test.rb (renamed from railties/guides/code/getting_started/test/unit/tag_test.rb)0
-rw-r--r--guides/code/getting_started/vendor/assets/stylesheets/.gitkeep (renamed from railties/guides/code/getting_started/vendor/assets/stylesheets/.gitkeep)0
-rw-r--r--guides/code/getting_started/vendor/plugins/.gitkeep (renamed from railties/guides/code/getting_started/vendor/plugins/.gitkeep)0
-rw-r--r--guides/rails_guides.rb (renamed from railties/guides/rails_guides.rb)4
-rw-r--r--guides/rails_guides/generator.rb (renamed from railties/guides/rails_guides/generator.rb)0
-rw-r--r--guides/rails_guides/helpers.rb (renamed from railties/guides/rails_guides/helpers.rb)0
-rw-r--r--guides/rails_guides/indexer.rb (renamed from railties/guides/rails_guides/indexer.rb)0
-rw-r--r--guides/rails_guides/levenshtein.rb (renamed from railties/guides/rails_guides/levenshtein.rb)0
-rw-r--r--guides/rails_guides/textile_extensions.rb (renamed from railties/guides/rails_guides/textile_extensions.rb)0
-rw-r--r--guides/source/2_2_release_notes.textile (renamed from railties/guides/source/2_2_release_notes.textile)0
-rw-r--r--guides/source/2_3_release_notes.textile (renamed from railties/guides/source/2_3_release_notes.textile)0
-rw-r--r--guides/source/3_0_release_notes.textile (renamed from railties/guides/source/3_0_release_notes.textile)0
-rw-r--r--guides/source/3_1_release_notes.textile (renamed from railties/guides/source/3_1_release_notes.textile)0
-rw-r--r--guides/source/3_2_release_notes.textile (renamed from railties/guides/source/3_2_release_notes.textile)0
-rw-r--r--guides/source/_license.html.erb (renamed from railties/guides/source/_license.html.erb)0
-rw-r--r--guides/source/_welcome.html.erb (renamed from railties/guides/source/_welcome.html.erb)0
-rw-r--r--guides/source/action_controller_overview.textile (renamed from railties/guides/source/action_controller_overview.textile)0
-rw-r--r--guides/source/action_mailer_basics.textile (renamed from railties/guides/source/action_mailer_basics.textile)2
-rw-r--r--guides/source/action_view_overview.textile (renamed from railties/guides/source/action_view_overview.textile)0
-rw-r--r--guides/source/active_model_basics.textile (renamed from railties/guides/source/active_model_basics.textile)0
-rw-r--r--guides/source/active_record_basics.textile (renamed from railties/guides/source/active_record_basics.textile)0
-rw-r--r--guides/source/active_record_querying.textile (renamed from railties/guides/source/active_record_querying.textile)0
-rw-r--r--guides/source/active_record_validations_callbacks.textile (renamed from railties/guides/source/active_record_validations_callbacks.textile)0
-rw-r--r--guides/source/active_support_core_extensions.textile (renamed from railties/guides/source/active_support_core_extensions.textile)0
-rw-r--r--guides/source/active_support_instrumentation.textile448
-rw-r--r--guides/source/ajax_on_rails.textile (renamed from railties/guides/source/ajax_on_rails.textile)0
-rw-r--r--guides/source/api_documentation_guidelines.textile (renamed from railties/guides/source/api_documentation_guidelines.textile)45
-rw-r--r--guides/source/asset_pipeline.textile (renamed from railties/guides/source/asset_pipeline.textile)4
-rw-r--r--guides/source/association_basics.textile (renamed from railties/guides/source/association_basics.textile)4
-rw-r--r--guides/source/caching_with_rails.textile (renamed from railties/guides/source/caching_with_rails.textile)18
-rw-r--r--guides/source/command_line.textile (renamed from railties/guides/source/command_line.textile)0
-rw-r--r--guides/source/configuring.textile (renamed from railties/guides/source/configuring.textile)97
-rw-r--r--guides/source/contributing_to_ruby_on_rails.textile (renamed from railties/guides/source/contributing_to_ruby_on_rails.textile)111
-rw-r--r--guides/source/credits.html.erb (renamed from railties/guides/source/credits.html.erb)0
-rw-r--r--guides/source/debugging_rails_applications.textile (renamed from railties/guides/source/debugging_rails_applications.textile)0
-rw-r--r--guides/source/documents.yaml (renamed from railties/guides/source/documents.yaml)0
-rw-r--r--guides/source/engines.textile (renamed from railties/guides/source/engines.textile)15
-rw-r--r--guides/source/form_helpers.textile (renamed from railties/guides/source/form_helpers.textile)0
-rw-r--r--guides/source/generators.textile (renamed from railties/guides/source/generators.textile)0
-rw-r--r--guides/source/getting_started.textile (renamed from railties/guides/source/getting_started.textile)611
-rw-r--r--guides/source/i18n.textile (renamed from railties/guides/source/i18n.textile)0
-rw-r--r--guides/source/index.html.erb (renamed from railties/guides/source/index.html.erb)0
-rw-r--r--guides/source/initialization.textile (renamed from railties/guides/source/initialization.textile)0
-rw-r--r--guides/source/kindle/KINDLE.md (renamed from railties/guides/source/kindle/KINDLE.md)0
-rw-r--r--guides/source/kindle/copyright.html.erb (renamed from railties/guides/source/kindle/copyright.html.erb)0
-rw-r--r--guides/source/kindle/layout.html.erb (renamed from railties/guides/source/kindle/layout.html.erb)0
-rw-r--r--guides/source/kindle/rails_guides.opf.erb (renamed from railties/guides/source/kindle/rails_guides.opf.erb)0
-rw-r--r--guides/source/kindle/toc.html.erb (renamed from railties/guides/source/kindle/toc.html.erb)0
-rw-r--r--guides/source/kindle/toc.ncx.erb (renamed from railties/guides/source/kindle/toc.ncx.erb)0
-rw-r--r--guides/source/kindle/welcome.html.erb (renamed from railties/guides/source/kindle/welcome.html.erb)0
-rw-r--r--guides/source/layout.html.erb (renamed from railties/guides/source/layout.html.erb)0
-rw-r--r--guides/source/layouts_and_rendering.textile (renamed from railties/guides/source/layouts_and_rendering.textile)0
-rw-r--r--guides/source/migrations.textile (renamed from railties/guides/source/migrations.textile)0
-rw-r--r--guides/source/nested_model_forms.textile (renamed from railties/guides/source/nested_model_forms.textile)0
-rw-r--r--guides/source/performance_testing.textile (renamed from railties/guides/source/performance_testing.textile)0
-rw-r--r--guides/source/plugins.textile (renamed from railties/guides/source/plugins.textile)13
-rw-r--r--guides/source/rails_application_templates.textile (renamed from railties/guides/source/rails_application_templates.textile)0
-rw-r--r--guides/source/rails_on_rack.textile (renamed from railties/guides/source/rails_on_rack.textile)0
-rw-r--r--guides/source/routing.textile (renamed from railties/guides/source/routing.textile)0
-rw-r--r--guides/source/ruby_on_rails_guides_guidelines.textile (renamed from railties/guides/source/ruby_on_rails_guides_guidelines.textile)21
-rw-r--r--guides/source/security.textile (renamed from railties/guides/source/security.textile)0
-rw-r--r--guides/source/testing.textile (renamed from railties/guides/source/testing.textile)0
-rw-r--r--guides/source/upgrading_ruby_on_rails.textile (renamed from railties/guides/source/upgrading_ruby_on_rails.textile)0
-rw-r--r--guides/w3c_validator.rb (renamed from railties/guides/w3c_validator.rb)0
-rw-r--r--rails.gemspec11
-rw-r--r--railties/CHANGELOG.md2
-rwxr-xr-xrailties/Rakefile12
-rw-r--r--railties/guides/source/active_support_instrumentation.textile96
-rw-r--r--railties/guides/source/api_app.textile273
-rw-r--r--railties/lib/rails/application.rb11
-rw-r--r--railties/lib/rails/code_statistics.rb8
-rw-r--r--railties/lib/rails/commands/console.rb13
-rw-r--r--railties/lib/rails/commands/server.rb5
-rw-r--r--railties/lib/rails/configuration.rb18
-rw-r--r--railties/lib/rails/engine.rb2
-rw-r--r--railties/lib/rails/generators.rb4
-rw-r--r--railties/lib/rails/generators/app_base.rb7
-rw-r--r--railties/lib/rails/generators/erb/scaffold/templates/index.html.erb2
-rw-r--r--railties/lib/rails/generators/named_base.rb5
-rw-r--r--railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb5
-rw-r--r--railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt5
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/application.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/db/seeds.rb.tt4
-rw-r--r--railties/lib/rails/generators/rails/resource/resource_generator.rb5
-rw-r--r--railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb5
-rw-r--r--railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb20
-rw-r--r--railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb2
-rw-r--r--railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb13
-rw-r--r--railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb10
-rw-r--r--railties/lib/rails/paths.rb31
-rw-r--r--railties/lib/rails/source_annotation_extractor.rb2
-rw-r--r--railties/railties.gemspec3
-rw-r--r--railties/test/application/loading_test.rb31
-rw-r--r--railties/test/application/middleware_test.rb36
-rw-r--r--railties/test/application/rake/notes_test.rb7
-rw-r--r--railties/test/application/rake_test.rb17
-rw-r--r--railties/test/commands/console_test.rb19
-rw-r--r--railties/test/commands/server_test.rb26
-rw-r--r--railties/test/generators/app_generator_test.rb3
-rw-r--r--railties/test/generators/migration_generator_test.rb18
-rw-r--r--railties/test/generators/shared_generator_tests.rb15
-rw-r--r--railties/test/isolation/abstract_unit.rb7
435 files changed, 2404 insertions, 1466 deletions
diff --git a/.gitignore b/.gitignore
index 52a431867c..854fdbf450 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,6 @@ debug.log
/railties/test/fixtures/tmp
/railties/test/initializer/root/log
/railties/doc
-/railties/guides/output
/railties/tmp
+/guides/output
/RDOC_MAIN.rdoc
diff --git a/Gemfile b/Gemfile
index 5e2be55e61..b19f532b87 100644
--- a/Gemfile
+++ b/Gemfile
@@ -8,7 +8,7 @@ else
gem 'arel'
end
-gem 'rack-test', :git => "https://github.com/brynary/rack-test.git"
+gem 'rack-test', :git => "git://github.com/brynary/rack-test.git"
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'jquery-rails'
diff --git a/README.rdoc b/README.rdoc
index 78640b39aa..c9fb595efb 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -47,7 +47,7 @@ can read more about Action Pack in its {README}[link:/rails/rails/blob/master/ac
cd myapp; rails server
- Run with <tt>--help</tt> for options.
+ Run with <tt>--help</tt> or <tt>-h</tt> for options.
4. Go to http://localhost:3000 and you'll see:
diff --git a/actionmailer/actionmailer.gemspec b/actionmailer/actionmailer.gemspec
index f03240acb1..90503edc20 100644
--- a/actionmailer/actionmailer.gemspec
+++ b/actionmailer/actionmailer.gemspec
@@ -17,5 +17,5 @@ Gem::Specification.new do |s|
s.requirements << 'none'
s.add_dependency('actionpack', version)
- s.add_dependency('mail', '~> 2.4.3')
+ s.add_dependency('mail', '~> 2.4.4')
end
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index 64f82f24a2..4af2d0a4a8 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -14,15 +14,15 @@ module ActionMailer #:nodoc:
#
# $ rails generate mailer Notifier
#
- # The generated model inherits from <tt>ActionMailer::Base</tt>. Emails are defined by creating methods
- # within the model which are then used to set variables to be used in the mail template, to
- # change options on the mail, or to add attachments.
+ # The generated model inherits from <tt>ActionMailer::Base</tt>. A mailer model defines methods
+ # used to generate an email message. In these methods, you can setup variables to be used in
+ # the mailer views, options on the mail itself such as the <tt>:from</tt> address, and attachments.
#
# Examples:
#
# class Notifier < ActionMailer::Base
# default :from => 'no-reply@example.com',
- # :return_path => 'system@example.com'
+ # :return_path => 'system@example.com'
#
# def welcome(recipient)
# @account = recipient
diff --git a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb
index aaa1f79732..f6ed7cf8ac 100644
--- a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb
+++ b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb
@@ -1,6 +1,6 @@
<% module_namespacing do -%>
class <%= class_name %> < ActionMailer::Base
- default <%= key_value :from, '"from@example.com"' %>
+ default from: "from@example.com"
<% actions.each do |action| -%>
# Subject can be set in your I18n file at config/locales/en.yml
@@ -11,7 +11,7 @@ class <%= class_name %> < ActionMailer::Base
def <%= action %>
@greeting = "Hi"
- mail <%= key_value :to, '"to@example.org"' %>
+ mail to: "to@example.org"
end
<% end -%>
end
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 20b6820065..92efb060a2 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* Added ActionDispatch::SSL middleware that when included force all the requests to be under HTTPS protocol. *Rafael Mendonça França*
+
* Add `include_hidden` option to select tag. With `:include_hidden => false` select with `multiple` attribute doesn't generate hidden input with blank value. *Vasiliy Ermolovich*
* Removed default `size` option from the `text_field`, `search_field`, `telephone_field`, `url_field`, `email_field` helpers. *Philip Arndt*
@@ -89,6 +91,9 @@
* check_box with `:form` html5 attribute will now replicate the `:form`
attribute to the hidden field as well. *Carlos Antonio da Silva*
+* Turn off verbose mode of rack-cache, we still have X-Rack-Cache to
+ check that info. Closes #5245. *Santiago Pastorino*
+
* `label` form helper accepts :for => nil to not generate the attribute. *Carlos Antonio da Silva*
* Add `:format` option to number_to_percentage *Rodrigo Flores*
@@ -117,12 +122,14 @@
* `favicon_link_tag` helper will now use the favicon in app/assets by default. *Lucas Caton*
-* `ActionView::Helpers::TextHelper#highlight` now defaults to the
- HTML5 `mark` element. *Brian Cardarella*
+* `ActionView::Helpers::TextHelper#highlight` now defaults to the
+ HTML5 `mark` element. *Brian Cardarella*
## Rails 3.2.3 (unreleased) ##
+* Do not include the authenticity token in forms where remote: true as ajax forms use the meta-tag value *DHH*
+
* Upgrade rack-cache to 1.2. *José Valim*
* ActionController::SessionManagement is removed. *Santiago Pastorino*
diff --git a/actionpack/lib/abstract_controller/layouts.rb b/actionpack/lib/abstract_controller/layouts.rb
index a82e3dc90a..6f13ebe0d0 100644
--- a/actionpack/lib/abstract_controller/layouts.rb
+++ b/actionpack/lib/abstract_controller/layouts.rb
@@ -89,7 +89,7 @@ module AbstractController
# class TillController < BankController
# layout false
#
- # In these examples, we have three implicit lookup scenrios:
+ # In these examples, we have three implicit lookup scenarios:
# * The BankController uses the "bank" layout.
# * The ExchangeController uses the "exchange" layout.
# * The CurrencyController inherits the layout from BankController.
@@ -120,6 +120,7 @@ module AbstractController
# def writers_and_readers
# logged_in? ? "writer_layout" : "reader_layout"
# end
+ # end
#
# Now when a new request for the index action is processed, the layout will vary depending on whether the person accessing
# is logged in or not.
@@ -127,7 +128,14 @@ module AbstractController
# If you want to use an inline method, such as a proc, do something like this:
#
# class WeblogController < ActionController::Base
- # layout proc{ |controller| controller.logged_in? ? "writer_layout" : "reader_layout" }
+ # layout proc { |controller| controller.logged_in? ? "writer_layout" : "reader_layout" }
+ # end
+ #
+ # If an argument isn't given to the proc, it's evaluated in the context of
+ # the current controller anyway.
+ #
+ # class WeblogController < ActionController::Base
+ # layout proc { logged_in? ? "writer_layout" : "reader_layout" }
# end
#
# Of course, the most common way of specifying a layout is still just as a plain template name:
@@ -298,12 +306,12 @@ module AbstractController
end
RUBY
when Proc
- define_method :_layout_from_proc, &_layout
- "_layout_from_proc(self)"
+ define_method :_layout_from_proc, &_layout
+ _layout.arity == 0 ? "_layout_from_proc" : "_layout_from_proc(self)"
when false
nil
when true
- raise ArgumentError, "Layouts must be specified as a String, Symbol, false, or nil"
+ raise ArgumentError, "Layouts must be specified as a String, Symbol, Proc, false, or nil"
when nil
name_clause
end
@@ -363,7 +371,7 @@ module AbstractController
when false, nil then nil
else
raise ArgumentError,
- "String, true, or false, expected for `layout'; you passed #{name.inspect}"
+ "String, Proc, :default, true, or false, expected for `layout'; you passed #{name.inspect}"
end
end
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb
index ddc93464cd..7d73c6af8d 100644
--- a/actionpack/lib/abstract_controller/rendering.rb
+++ b/actionpack/lib/abstract_controller/rendering.rb
@@ -105,6 +105,7 @@ module AbstractController
# Find and renders a template based on the options given.
# :api: private
def _render_template(options) #:nodoc:
+ lookup_context.rendered_format = nil if options[:formats]
view_renderer.render(view_context, options)
end
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb
index 6ce78f34b5..71425cd542 100644
--- a/actionpack/lib/action_controller/base.rb
+++ b/actionpack/lib/action_controller/base.rb
@@ -171,7 +171,7 @@ module ActionController
class Base < Metal
abstract!
- # Shortcut helper that returns all the ActionController modules except the ones passed in the argument:
+ # Shortcut helper that returns all the ActionController::Base modules except the ones passed in the argument:
#
# class MetalController
# ActionController::Base.without_modules(:ParamsWrapper, :Streaming).each do |left|
diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb
index ba96735e56..ceac11bbfb 100644
--- a/actionpack/lib/action_controller/caching/actions.rb
+++ b/actionpack/lib/action_controller/caching/actions.rb
@@ -170,14 +170,14 @@ module ActionController #:nodoc:
options.reverse_merge!(:format => @extension) if options.is_a?(Hash)
end
- path = controller.url_for(options).split(%r{://}).last
+ path = controller.url_for(options).split('://', 2).last
@path = normalize!(path)
end
private
def normalize!(path)
path << 'index' if path[-1] == ?/
- path << ".#{extension}" if extension and !path.split('?').first.ends_with?(".#{extension}")
+ path << ".#{extension}" if extension and !path.split('?', 2).first.ends_with?(".#{extension}")
URI.parser.unescape(path)
end
end
diff --git a/actionpack/lib/action_controller/caching/sweeping.rb b/actionpack/lib/action_controller/caching/sweeping.rb
index 49cf70ec21..bb176ca3f9 100644
--- a/actionpack/lib/action_controller/caching/sweeping.rb
+++ b/actionpack/lib/action_controller/caching/sweeping.rb
@@ -54,6 +54,11 @@ module ActionController #:nodoc:
class Sweeper < ActiveRecord::Observer #:nodoc:
attr_accessor :controller
+ def initialize(*args)
+ super
+ @controller = nil
+ end
+
def before(controller)
self.controller = controller
callback(:before) if controller.perform_caching
@@ -88,7 +93,7 @@ module ActionController #:nodoc:
end
def method_missing(method, *arguments, &block)
- return unless @controller
+ super unless @controller
@controller.__send__(method, *arguments, &block)
end
end
diff --git a/actionpack/lib/action_controller/metal/force_ssl.rb b/actionpack/lib/action_controller/metal/force_ssl.rb
index a1e40fc4e0..ac12cbb625 100644
--- a/actionpack/lib/action_controller/metal/force_ssl.rb
+++ b/actionpack/lib/action_controller/metal/force_ssl.rb
@@ -44,7 +44,7 @@ module ActionController
redirect_options = {:protocol => 'https://', :status => :moved_permanently}
redirect_options.merge!(:host => host) if host
redirect_options.merge!(:params => request.query_parameters)
- flash.keep
+ flash.keep if respond_to?(:flash)
redirect_to redirect_options
end
end
diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb
index d070eaae5d..1a4bca12d2 100644
--- a/actionpack/lib/action_controller/metal/helpers.rb
+++ b/actionpack/lib/action_controller/metal/helpers.rb
@@ -52,6 +52,7 @@ module ActionController
module Helpers
extend ActiveSupport::Concern
+ class << self; attr_accessor :helpers_path; end
include AbstractController::Helpers
included do
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index 73e044a092..fbb5d01e86 100644
--- a/actionpack/lib/action_controller/metal/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
@@ -195,20 +195,106 @@ module ActionController #:nodoc:
end
end
- # respond_with wraps a resource around a responder for default representation.
- # First it invokes respond_to, if a response cannot be found (ie. no block
- # for the request was given and template was not available), it instantiates
- # an ActionController::Responder with the controller and resource.
+ # For a given controller action, respond_with generates an appropriate
+ # response based on the mime-type requested by the client.
#
- # ==== Example
+ # If the method is called with just a resource, as in this example -
#
- # def index
- # @users = User.all
- # respond_with(@users)
+ # class PeopleController < ApplicationController
+ # respond_to :html, :xml, :json
+ #
+ # def index
+ # @people = Person.all
+ # respond_with @people
+ # end
# end
#
- # It also accepts a block to be given. It's used to overwrite a default
- # response:
+ # then the mime-type of the response is typically selected based on the
+ # request's Accept header and the set of available formats declared
+ # by previous calls to the controller's class method +respond_to+. Alternatively
+ # the mime-type can be selected by explicitly setting <tt>request.format</tt> in
+ # the controller.
+ #
+ # If an acceptable format is not identified, the application returns a
+ # '406 - not acceptable' status. Otherwise, the default response is to render
+ # a template named after the current action and the selected format,
+ # e.g. <tt>index.html.erb</tt>. If no template is available, the behavior
+ # depends on the selected format:
+ #
+ # * for an html response - if the request method is +get+, an exception
+ # is raised but for other requests such as +post+ the response
+ # depends on whether the resource has any validation errors (i.e.
+ # assuming that an attempt has been made to save the resource,
+ # e.g. by a +create+ action) -
+ # 1. If there are no errors, i.e. the resource
+ # was saved successfully, the response +redirect+'s to the resource
+ # i.e. its +show+ action.
+ # 2. If there are validation errors, the response
+ # renders a default action, which is <tt>:new</tt> for a
+ # +post+ request or <tt>:edit</tt> for +put+.
+ # Thus an example like this -
+ #
+ # respond_to :html, :xml
+ #
+ # def create
+ # @user = User.new(params[:user])
+ # flash[:notice] = 'User was successfully created.' if @user.save
+ # respond_with(@user)
+ # end
+ #
+ # is equivalent, in the absence of <tt>create.html.erb</tt>, to -
+ #
+ # def create
+ # @user = User.new(params[:user])
+ # respond_to do |format|
+ # if @user.save
+ # flash[:notice] = 'User was successfully created.'
+ # format.html { redirect_to(@user) }
+ # format.xml { render :xml => @user }
+ # else
+ # format.html { render :action => "new" }
+ # format.xml { render :xml => @user }
+ # end
+ # end
+ # end
+ #
+ # * for a javascript request - if the template isn't found, an exception is
+ # raised.
+ # * for other requests - i.e. data formats such as xml, json, csv etc, if
+ # the resource passed to +respond_with+ responds to <code>to_<format></code>,
+ # the method attempts to render the resource in the requested format
+ # directly, e.g. for an xml request, the response is equivalent to calling
+ # <code>render :xml => resource</code>.
+ #
+ # === Nested resources
+ #
+ # As outlined above, the +resources+ argument passed to +respond_with+
+ # can play two roles. It can be used to generate the redirect url
+ # for successful html requests (e.g. for +create+ actions when
+ # no template exists), while for formats other than html and javascript
+ # it is the object that gets rendered, by being converted directly to the
+ # required format (again assuming no template exists).
+ #
+ # For redirecting successful html requests, +respond_with+ also supports
+ # the use of nested resources, which are supplied in the same way as
+ # in <code>form_for</code> and <code>polymorphic_url</code>. For example -
+ #
+ # def create
+ # @project = Project.find(params[:project_id])
+ # @task = @project.comments.build(params[:task])
+ # flash[:notice] = 'Task was successfully created.' if @task.save
+ # respond_with(@project, @task)
+ # end
+ #
+ # This would cause +respond_with+ to redirect to <code>project_task_url</code>
+ # instead of <code>task_url</code>. For request formats other than html or
+ # javascript, if multiple resources are passed in this way, it is the last
+ # one specified that is rendered.
+ #
+ # === Customizing response behavior
+ #
+ # Like +respond_to+, +respond_with+ may also be called with a block that
+ # can be used to overwrite any of the default responses, e.g. -
#
# def create
# @user = User.new(params[:user])
@@ -219,13 +305,24 @@ module ActionController #:nodoc:
# end
# end
#
- # All options given to respond_with are sent to the underlying responder,
- # except for the option :responder itself. Since the responder interface
- # is quite simple (it just needs to respond to call), you can even give
- # a proc to it.
- #
- # In order to use respond_with, first you need to declare the formats your
- # controller responds to in the class level with a call to <tt>respond_to</tt>.
+ # The argument passed to the block is an ActionController::MimeResponds::Collector
+ # object which stores the responses for the formats defined within the
+ # block. Note that formats with responses defined explicitly in this way
+ # do not have to first be declared using the class method +respond_to+.
+ #
+ # Also, a hash passed to +respond_with+ immediately after the specified
+ # resource(s) is interpreted as a set of options relevant to all
+ # formats. Any option accepted by +render+ can be used, e.g.
+ # respond_with @people, :status => 200
+ # However, note that these options are ignored after an unsuccessful attempt
+ # to save a resource, e.g. when automatically rendering <tt>:new</tt>
+ # after a post request.
+ #
+ # Two additional options are relevant specifically to +respond_with+ -
+ # 1. <tt>:location</tt> - overwrites the default redirect location used after
+ # a successful html +post+ request.
+ # 2. <tt>:action</tt> - overwrites the default render action used after an
+ # unsuccessful html +post+ request.
#
def respond_with(*resources, &block)
raise "In order to use respond_with, first you need to declare the formats your " <<
@@ -283,8 +380,8 @@ module ActionController #:nodoc:
end
end
- # A container of responses available for requests with different mime-types
- # sent to the current controller action.
+ # A container for responses available from the current controller for
+ # requests for different mime-types sent to a particular action.
#
# The public controller methods +respond_with+ and +respond_to+ may be called
# with a block that is used to define responses to different mime-types, e.g.
diff --git a/actionpack/lib/action_controller/metal/redirecting.rb b/actionpack/lib/action_controller/metal/redirecting.rb
index b07742e0e1..3ffb7ef426 100644
--- a/actionpack/lib/action_controller/metal/redirecting.rb
+++ b/actionpack/lib/action_controller/metal/redirecting.rb
@@ -93,7 +93,7 @@ module ActionController
_compute_redirect_to_location options.call
else
url_for(options)
- end.gsub(/[\r\n]/, '')
+ end.gsub(/[\0\r\n]/, '')
end
end
end
diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb
index 3e170d7872..851a2c4aee 100644
--- a/actionpack/lib/action_controller/railtie.rb
+++ b/actionpack/lib/action_controller/railtie.rb
@@ -3,33 +3,32 @@ require "action_controller"
require "action_dispatch/railtie"
require "action_view/railtie"
require "abstract_controller/railties/routes_helpers"
-require "action_controller/railties/paths"
+require "action_controller/railties/helpers"
module ActionController
class Railtie < Rails::Railtie #:nodoc:
config.action_controller = ActiveSupport::OrderedOptions.new
- initializer "action_controller.logger" do
- ActiveSupport.on_load(:action_controller) { self.logger ||= Rails.logger }
- end
-
- initializer "action_controller.initialize_framework_caches" do
- ActiveSupport.on_load(:action_controller) { self.cache_store ||= Rails.cache }
- end
-
initializer "action_controller.assets_config", :group => :all do |app|
app.config.action_controller.assets_dir ||= app.config.paths["public"].first
end
+ initializer "action_controller.set_helpers_path" do |app|
+ ActionController::Helpers.helpers_path = app.helpers_paths
+ end
+
initializer "action_controller.set_configs" do |app|
paths = app.config.paths
options = app.config.action_controller
+ options.logger ||= Rails.logger
+ options.cache_store ||= Rails.cache
+
options.javascripts_dir ||= paths["public/javascripts"].first
options.stylesheets_dir ||= paths["public/stylesheets"].first
options.page_cache_directory ||= paths["public"].first
- # make sure readers methods get compiled
+ # Ensure readers methods get compiled
options.asset_path ||= app.config.asset_path
options.asset_host ||= app.config.asset_host
options.relative_url_root ||= app.config.relative_url_root
@@ -37,8 +36,16 @@ module ActionController
ActiveSupport.on_load(:action_controller) do
include app.routes.mounted_helpers
extend ::AbstractController::Railties::RoutesHelpers.with(app.routes)
- extend ::ActionController::Railties::Paths.with(app)
- options.each { |k,v| send("#{k}=", v) }
+ extend ::ActionController::Railties::Helpers
+
+ options.each do |k,v|
+ k = "#{k}="
+ if respond_to?(k)
+ send(k, v)
+ elsif !Base.respond_to?(k)
+ raise "Invalid option key: #{k}"
+ end
+ end
end
end
diff --git a/actionpack/lib/action_controller/railties/helpers.rb b/actionpack/lib/action_controller/railties/helpers.rb
new file mode 100644
index 0000000000..3985c6b273
--- /dev/null
+++ b/actionpack/lib/action_controller/railties/helpers.rb
@@ -0,0 +1,22 @@
+module ActionController
+ module Railties
+ module Helpers
+ def inherited(klass)
+ super
+ return unless klass.respond_to?(:helpers_path=)
+
+ if namespace = klass.parents.detect { |m| m.respond_to?(:railtie_helpers_paths) }
+ paths = namespace.railtie_helpers_paths
+ else
+ paths = ActionController::Helpers.helpers_path
+ end
+
+ klass.helpers_path = paths
+
+ if klass.superclass == ActionController::Base && ActionController::Base.include_all_helpers
+ klass.helper :all
+ end
+ end
+ end
+ end
+end
diff --git a/actionpack/lib/action_controller/railties/paths.rb b/actionpack/lib/action_controller/railties/paths.rb
deleted file mode 100644
index bbe63149ad..0000000000
--- a/actionpack/lib/action_controller/railties/paths.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-module ActionController
- module Railties
- module Paths
- def self.with(app)
- Module.new do
- define_method(:inherited) do |klass|
- super(klass)
-
- if namespace = klass.parents.detect { |m| m.respond_to?(:railtie_helpers_paths) }
- paths = namespace.railtie_helpers_paths
- else
- paths = app.helpers_paths
- end
-
- klass.helpers_path = paths
-
- if klass.superclass == ActionController::Base && ActionController::Base.include_all_helpers
- klass.helper :all
- end
- end
- end
- end
- end
- end
-end
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index 7af30ed690..9bd2e622ad 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -479,7 +479,6 @@ module ActionController
@request.session["flash"].sweep
@controller.request = @request
- @controller.params.merge!(parameters)
build_request_uri(action, parameters)
@controller.class.class_eval { include Testing }
@controller.recycle!
@@ -505,11 +504,6 @@ module ActionController
end
end
- # Cause the action to be rescued according to the regular rules for rescue_action when the visitor is not local
- def rescue_action_in_public!
- @request.remote_addr = '208.77.188.166' # example.com
- end
-
included do
include ActionController::TemplateAssertions
include ActionDispatch::Assertions
diff --git a/actionpack/lib/action_dispatch.rb b/actionpack/lib/action_dispatch.rb
index a9542a7d1b..e3b04ac097 100644
--- a/actionpack/lib/action_dispatch.rb
+++ b/actionpack/lib/action_dispatch.rb
@@ -61,6 +61,7 @@ module ActionDispatch
autoload :Reloader
autoload :RemoteIp
autoload :ShowExceptions
+ autoload :SSL
autoload :Static
end
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb
index 84732085f0..078229efd2 100644
--- a/actionpack/lib/action_dispatch/http/response.rb
+++ b/actionpack/lib/action_dispatch/http/response.rb
@@ -51,12 +51,13 @@ module ActionDispatch # :nodoc:
# If a character set has been defined for this response (see charset=) then
# the character set information will also be included in the content type
# information.
- attr_accessor :charset, :content_type
+ attr_accessor :charset
+ attr_reader :content_type
CONTENT_TYPE = "Content-Type".freeze
SET_COOKIE = "Set-Cookie".freeze
LOCATION = "Location".freeze
-
+
cattr_accessor(:default_charset) { "utf-8" }
include Rack::Response::Helpers
@@ -83,6 +84,10 @@ module ActionDispatch # :nodoc:
@status = Rack::Utils.status_code(status)
end
+ def content_type=(content_type)
+ @content_type = content_type.to_s
+ end
+
# The response code of the request
def response_code
@status
diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
index 836136eb95..ab740a0190 100644
--- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
+++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
@@ -9,7 +9,7 @@ module ActionDispatch
# of ShowExceptions. Everytime there is an exception, ShowExceptions will
# store the exception in env["action_dispatch.exception"], rewrite the
# PATH_INFO to the exception status code and call the rack app.
- #
+ #
# If the application returns a "X-Cascade" pass response, this middleware
# will send an empty response as result with the correct status code.
# If any exception happens inside the exceptions app, this middleware
diff --git a/actionpack/lib/action_dispatch/middleware/ssl.rb b/actionpack/lib/action_dispatch/middleware/ssl.rb
new file mode 100644
index 0000000000..9098f4e170
--- /dev/null
+++ b/actionpack/lib/action_dispatch/middleware/ssl.rb
@@ -0,0 +1,70 @@
+module ActionDispatch
+ class SSL
+ YEAR = 31536000
+
+ def self.default_hsts_options
+ { :expires => YEAR, :subdomains => false }
+ end
+
+ def initialize(app, options = {})
+ @app = app
+
+ @hsts = options.fetch(:hsts, {})
+ @hsts = {} if @hsts == true
+ @hsts = self.class.default_hsts_options.merge(@hsts) if @hsts
+
+ @host = options[:host]
+ @port = options[:port]
+ end
+
+ def call(env)
+ request = Request.new(env)
+
+ if request.ssl?
+ status, headers, body = @app.call(env)
+ headers = hsts_headers.merge(headers)
+ flag_cookies_as_secure!(headers)
+ [status, headers, body]
+ else
+ redirect_to_https(request)
+ end
+ end
+
+ private
+ def redirect_to_https(request)
+ url = URI(request.url)
+ url.scheme = "https"
+ url.host = @host if @host
+ url.port = @port if @port
+ headers = hsts_headers.merge('Content-Type' => 'text/html',
+ 'Location' => url.to_s)
+
+ [301, headers, []]
+ end
+
+ # http://tools.ietf.org/html/draft-hodges-strict-transport-sec-02
+ def hsts_headers
+ if @hsts
+ value = "max-age=#{@hsts[:expires]}"
+ value += "; includeSubDomains" if @hsts[:subdomains]
+ { 'Strict-Transport-Security' => value }
+ else
+ {}
+ end
+ end
+
+ def flag_cookies_as_secure!(headers)
+ if cookies = headers['Set-Cookie']
+ cookies = cookies.split("\n")
+
+ headers['Set-Cookie'] = cookies.map { |cookie|
+ if cookie !~ /;\s+secure(;|$)/
+ "#{cookie}; secure"
+ else
+ cookie
+ end
+ }.join("\n")
+ end
+ end
+ end
+end
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb
index 63b7422287..9073e6582d 100644
--- a/actionpack/lib/action_dispatch/middleware/static.rb
+++ b/actionpack/lib/action_dispatch/middleware/static.rb
@@ -39,6 +39,7 @@ module ActionDispatch
end
def escape_glob_chars(path)
+ path.force_encoding('binary') if path.respond_to? :force_encoding
path.gsub(/[*?{}\[\]]/, "\\\\\\&")
end
end
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index cd215034dc..20cdf67cf0 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1,6 +1,6 @@
require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/object/blank'
-require 'active_support/core_ext/object/inclusion'
+require 'active_support/core_ext/enumerable'
require 'active_support/inflector'
require 'action_dispatch/routing/redirection'
@@ -880,17 +880,18 @@ module ActionDispatch
# CANONICAL_ACTIONS holds all actions that does not need a prefix or
# a path appended since they fit properly in their scope level.
VALID_ON_OPTIONS = [:new, :collection, :member]
- RESOURCE_OPTIONS = [:as, :controller, :path, :only, :except]
+ RESOURCE_OPTIONS = [:as, :controller, :path, :only, :except, :param]
CANONICAL_ACTIONS = %w(index create new show update destroy)
class Resource #:nodoc:
- attr_reader :controller, :path, :options
+ attr_reader :controller, :path, :options, :param
def initialize(entities, options = {})
@name = entities.to_s
@path = (options[:path] || @name).to_s
@controller = (options[:controller] || @name).to_s
@as = options[:as]
+ @param = options[:param] || :id
@options = options
end
@@ -935,7 +936,7 @@ module ActionDispatch
alias :collection_scope :path
def member_scope
- "#{path}/:id"
+ "#{path}/:#{param}"
end
def new_scope(new_path)
@@ -943,7 +944,7 @@ module ActionDispatch
end
def nested_scope
- "#{path}/:#{singular}_id"
+ "#{path}/:#{singular}_#{param}"
end
end
diff --git a/actionpack/lib/action_dispatch/testing/assertions/response.rb b/actionpack/lib/action_dispatch/testing/assertions/response.rb
index 094cfbfc76..a5e7a8c715 100644
--- a/actionpack/lib/action_dispatch/testing/assertions/response.rb
+++ b/actionpack/lib/action_dispatch/testing/assertions/response.rb
@@ -83,7 +83,7 @@ module ActionDispatch
refer
else
@controller.url_for(fragment)
- end.gsub(/[\r\n]/, '')
+ end.gsub(/[\0\r\n]/, '')
end
end
end
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index 2d37923825..2bfc6371f5 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -625,13 +625,18 @@ module ActionView
# time_tag Date.today, :pubdate => true # =>
# <time datetime="2010-11-04" pubdate="pubdate">November 04, 2010</time>
#
- def time_tag(date_or_time, *args)
+ # <%= time_tag Time.now do %>
+ # <span>Right now</span>
+ # <% end %>
+ # # => <time datetime="2010-11-04T17:55:45+01:00"><span>Right now</span></time>
+ #
+ def time_tag(date_or_time, *args, &block)
options = args.extract_options!
format = options.delete(:format) || :long
content = args.first || I18n.l(date_or_time, :format => format)
datetime = date_or_time.acts_like?(:time) ? date_or_time.xmlschema : date_or_time.rfc3339
- content_tag(:time, content, options.reverse_merge(:datetime => datetime))
+ content_tag(:time, content, options.reverse_merge(:datetime => datetime), &block)
end
end
@@ -669,11 +674,7 @@ module ActionView
@options[:discard_minute] ||= true if @options[:discard_hour]
@options[:discard_second] ||= true unless @options[:include_seconds] && !@options[:discard_minute]
- # If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are
- # valid (otherwise it could be 31 and February wouldn't be a valid date)
- if @datetime && @options[:discard_day] && !@options[:discard_month]
- @datetime = @datetime.change(:day => 1)
- end
+ set_day_if_discarded
if @options[:tag] && @options[:ignore_date]
select_time
@@ -696,11 +697,7 @@ module ActionView
@options[:discard_month] ||= true unless order.include?(:month)
@options[:discard_day] ||= true if @options[:discard_month] || !order.include?(:day)
- # If the day is hidden and the month is visible, the day should be set to the 1st so all month choices are
- # valid (otherwise it could be 31 and February wouldn't be a valid date)
- if @datetime && @options[:discard_day] && !@options[:discard_month]
- @datetime = @datetime.change(:day => 1)
- end
+ set_day_if_discarded
[:day, :month, :year].each { |o| order.unshift(o) unless order.include?(o) }
@@ -802,6 +799,14 @@ module ActionView
end
end
+ # If the day is hidden, the day should be set to the 1st so all month and year choices are
+ # valid. Otherwise, February 31st or February 29th, 2011 can be selected, which are invalid.
+ def set_day_if_discarded
+ if @datetime && @options[:discard_day]
+ @datetime = @datetime.change(:day => 1)
+ end
+ end
+
# Returns translated month names, but also ensures that a custom month
# name array has a leading nil element.
def month_names
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 9fad30a48f..41d895c15e 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -27,7 +27,9 @@ module ActionView
# is added to simulate the verb over post.
# * <tt>:authenticity_token</tt> - Authenticity token to use in the form. Use only if you need to
# pass custom authenticity token string, or to not add authenticity_token field at all
- # (by passing <tt>false</tt>).
+ # (by passing <tt>false</tt>). If this is a remote form, the authenticity_token will by default
+ # not be included as the ajax handler will get it from the meta-tag (but you can force it to be
+ # rendered anyway in that case by passing <tt>true</tt>).
# * A list of parameters to feed to the URL the form will be posted to.
# * <tt>:remote</tt> - If set to true, will allow the Unobtrusive JavaScript drivers to control the
# submit behavior. By default this behavior is an ajax submit.
@@ -616,8 +618,17 @@ module ActionView
# responsibility of the caller to escape all the values.
html_options["action"] = url_for(url_for_options)
html_options["accept-charset"] = "UTF-8"
+
html_options["data-remote"] = true if html_options.delete("remote")
- html_options["authenticity_token"] = html_options.delete("authenticity_token") if html_options.has_key?("authenticity_token")
+
+ if html_options["data-remote"] && html_options["authenticity_token"] == true
+ # Include the default authenticity_token, which is only generated when its set to nil,
+ # but we needed the true value to override the default of no authenticity_token on data-remote.
+ html_options["authenticity_token"] = nil
+ elsif html_options["data-remote"]
+ # The authenticity token is taken from the meta tag in this case
+ html_options["authenticity_token"] = false
+ end
end
end
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb
index 245a19deec..232667ec01 100644
--- a/actionpack/lib/action_view/renderer/partial_renderer.rb
+++ b/actionpack/lib/action_view/renderer/partial_renderer.rb
@@ -32,7 +32,7 @@ module ActionView
#
# <%= render :partial => "account", :object => @buyer %>
#
- # would provide the +@buyer+ object to the partial, available under the local variable +account+ and is
+ # would provide the <tt>@buyer</tt> object to the partial, available under the local variable +account+ and is
# equivalent to:
#
# <%= render :partial => "account", :locals => { :account => @buyer } %>
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb
index 7fa86866a7..8ea2e5bfe4 100644
--- a/actionpack/lib/action_view/template/resolver.rb
+++ b/actionpack/lib/action_view/template/resolver.rb
@@ -176,7 +176,7 @@ module ActionView
end
end
- # A resolver that loads files from the filesystem. It allows to set your own
+ # A resolver that loads files from the filesystem. It allows setting your own
# resolving pattern. Such pattern can be a glob string supported by some variables.
#
# ==== Examples
@@ -192,7 +192,7 @@ module ActionView
#
# FileSystemResolver.new("/path/to/views", ":prefix/{:formats/,}:action{.:locale,}{.:formats,}{.:handlers,}")
#
- # If you don't specify pattern then the default will be used.
+ # If you don't specify a pattern then the default will be used.
#
# In order to use any of the customized resolvers above in a Rails application, you just need
# to configure ActionController::Base.view_paths in an initializer, for example:
@@ -204,10 +204,10 @@ module ActionView
#
# ==== Pattern format and variables
#
- # Pattern have to be a valid glob string, and it allows you to use the
+ # Pattern has to be a valid glob string, and it allows you to use the
# following variables:
#
- # * <tt>:prefix</tt> - usualy the controller path
+ # * <tt>:prefix</tt> - usually the controller path
# * <tt>:action</tt> - name of the action
# * <tt>:locale</tt> - possible locale versions
# * <tt>:formats</tt> - possible request formats (for example html, json, xml...)
diff --git a/actionpack/test/abstract/abstract_controller_test.rb b/actionpack/test/abstract/abstract_controller_test.rb
index 30d6a7ae14..62f82a4c7a 100644
--- a/actionpack/test/abstract/abstract_controller_test.rb
+++ b/actionpack/test/abstract/abstract_controller_test.rb
@@ -29,7 +29,7 @@ module AbstractController
# Test Render mixin
# ====
class RenderingController < AbstractController::Base
- include ::AbstractController::Rendering
+ include AbstractController::Rendering
def _prefixes
[]
@@ -153,7 +153,7 @@ module AbstractController
# ====
# self._layout is used when defined
class WithLayouts < PrefixedViews
- include Layouts
+ include AbstractController::Layouts
private
def self.layout(formats)
diff --git a/actionpack/test/abstract/collector_test.rb b/actionpack/test/abstract/collector_test.rb
index 2ebcebbbb7..c14d24905b 100644
--- a/actionpack/test/abstract/collector_test.rb
+++ b/actionpack/test/abstract/collector_test.rb
@@ -3,7 +3,7 @@ require 'abstract_unit'
module AbstractController
module Testing
class MyCollector
- include Collector
+ include AbstractController::Collector
attr_accessor :responses
def initialize
@@ -54,4 +54,4 @@ module AbstractController
end
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/test/abstract/helper_test.rb b/actionpack/test/abstract/helper_test.rb
index b28a5b5afb..9a7445de7b 100644
--- a/actionpack/test/abstract/helper_test.rb
+++ b/actionpack/test/abstract/helper_test.rb
@@ -7,7 +7,7 @@ module AbstractController
class ControllerWithHelpers < AbstractController::Base
include AbstractController::Rendering
- include Helpers
+ include AbstractController::Helpers
def with_module
render :inline => "Module <%= included_method %>"
@@ -44,7 +44,7 @@ module AbstractController
class AbstractHelpersBlock < ControllerWithHelpers
helper do
- include ::AbstractController::Testing::HelperyTest
+ include AbstractController::Testing::HelperyTest
end
end
diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb
index e07a6de4a9..58795aa327 100644
--- a/actionpack/test/abstract/layouts_test.rb
+++ b/actionpack/test/abstract/layouts_test.rb
@@ -72,6 +72,27 @@ module AbstractControllerTests
end
end
+ class WithZeroArityProc < Base
+ layout proc { "overwrite" }
+
+ def index
+ render :template => ActionView::Template::Text.new("Hello zero arity proc!")
+ end
+ end
+
+ class WithProcInContextOfInstance < Base
+ def an_instance_method; end
+
+ layout proc {
+ break unless respond_to? :an_instance_method
+ "overwrite"
+ }
+
+ def index
+ render :template => ActionView::Template::Text.new("Hello again zero arity proc!")
+ end
+ end
+
class WithSymbol < Base
layout :hello
@@ -221,6 +242,18 @@ module AbstractControllerTests
assert_equal "Overwrite Hello proc!", controller.response_body
end
+ test "when layout is specified as a proc without parameters it works just the same" do
+ controller = WithZeroArityProc.new
+ controller.process(:index)
+ assert_equal "Overwrite Hello zero arity proc!", controller.response_body
+ end
+
+ test "when layout is specified as a proc without parameters the block is evaluated in the context of an instance" do
+ controller = WithProcInContextOfInstance.new
+ controller.process(:index)
+ assert_equal "Overwrite Hello again zero arity proc!", controller.response_body
+ end
+
test "when layout is specified as a symbol, call the requested method and use the layout returned" do
controller = WithSymbol.new
controller.process(:index)
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index 03d9873fc7..2d4083252e 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -130,8 +130,6 @@ class PerformActionTest < ActionController::TestCase
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
@request.host = "www.nextangle.com"
-
- rescue_action_in_public!
end
def test_process_should_be_precise
@@ -155,7 +153,6 @@ class UrlOptionsTest < ActionController::TestCase
def setup
super
@request.host = 'www.example.com'
- rescue_action_in_public!
end
def test_url_for_query_params_included
@@ -206,7 +203,6 @@ class DefaultUrlOptionsTest < ActionController::TestCase
def setup
super
@request.host = 'www.example.com'
- rescue_action_in_public!
end
def test_default_url_options_override
@@ -257,7 +253,6 @@ class EmptyUrlOptionsTest < ActionController::TestCase
def setup
super
@request.host = 'www.example.com'
- rescue_action_in_public!
end
def test_ensure_url_for_works_as_expected_when_called_with_no_options_if_default_url_options_is_not_set
diff --git a/actionpack/test/controller/http_digest_authentication_test.rb b/actionpack/test/controller/http_digest_authentication_test.rb
index a91e3cafa5..828ea5b0fb 100644
--- a/actionpack/test/controller/http_digest_authentication_test.rb
+++ b/actionpack/test/controller/http_digest_authentication_test.rb
@@ -274,6 +274,6 @@ class HttpDigestAuthenticationTest < ActionController::TestCase
end
def decode_credentials(header)
- ActionController::HttpAuthentication::Digest.decode_credentials(@response.headers['WWW-Authenticate'])
+ ActionController::HttpAuthentication::Digest.decode_credentials(header)
end
end
diff --git a/actionpack/test/controller/redirect_test.rb b/actionpack/test/controller/redirect_test.rb
index b1d76150f8..6dab42d75d 100644
--- a/actionpack/test/controller/redirect_test.rb
+++ b/actionpack/test/controller/redirect_test.rb
@@ -103,6 +103,14 @@ class RedirectController < ActionController::Base
redirect_to proc { {:action => "hello_world"} }
end
+ def redirect_with_header_break
+ redirect_to "/lol\r\nwat"
+ end
+
+ def redirect_with_null_bytes
+ redirect_to "\000/lol\r\nwat"
+ end
+
def rescue_errors(e) raise e end
protected
@@ -120,6 +128,18 @@ class RedirectTest < ActionController::TestCase
assert_equal "http://test.host/redirect/hello_world", redirect_to_url
end
+ def test_redirect_with_header_break
+ get :redirect_with_header_break
+ assert_response :redirect
+ assert_equal "http://test.host/lolwat", redirect_to_url
+ end
+
+ def test_redirect_with_null_bytes
+ get :redirect_with_null_bytes
+ assert_response :redirect
+ assert_equal "http://test.host/lolwat", redirect_to_url
+ end
+
def test_redirect_with_no_status
get :simple_redirect
assert_response 302
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index 8167fc2fd2..09d9e65d38 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -559,6 +559,23 @@ class TestController < ActionController::Base
render :template => "test/hello_world"
end
+ def render_to_string_with_template_and_html_partial
+ @text = render_to_string :template => "test/with_partial", :formats => [:text]
+ @html = render_to_string :template => "test/with_partial", :formats => [:html]
+ render :template => "test/with_html_partial"
+ end
+
+ def render_to_string_and_render_with_different_formats
+ @html = render_to_string :template => "test/with_partial", :formats => [:html]
+ render :template => "test/with_partial", :formats => [:text]
+ end
+
+ def render_template_within_a_template_with_other_format
+ render :template => "test/with_xml_template",
+ :formats => [:html],
+ :layout => "with_html_partial"
+ end
+
def partial_with_counter
render :partial => "counter", :locals => { :counter_counter => 5 }
end
@@ -1268,6 +1285,28 @@ class RenderTest < ActionController::TestCase
assert_equal "text/html", @response.content_type
end
+ def test_render_to_string_with_template_and_html_partial
+ get :render_to_string_with_template_and_html_partial
+ assert_equal "**only partial**\n", assigns(:text)
+ assert_equal "<strong>only partial</strong>\n", assigns(:html)
+ assert_equal "<strong>only html partial</strong>\n", @response.body
+ assert_equal "text/html", @response.content_type
+ end
+
+ def test_render_to_string_and_render_with_different_formats
+ get :render_to_string_and_render_with_different_formats
+ assert_equal "<strong>only partial</strong>\n", assigns(:html)
+ assert_equal "**only partial**\n", @response.body
+ assert_equal "text/plain", @response.content_type
+ end
+
+ def test_render_template_within_a_template_with_other_format
+ get :render_template_within_a_template_with_other_format
+ expected = "only html partial<p>This is grand!</p>"
+ assert_equal expected, @response.body.strip
+ assert_equal "text/html", @response.content_type
+ end
+
def test_partial_with_counter
get :partial_with_counter
assert_equal "5", @response.body
diff --git a/actionpack/test/controller/request_forgery_protection_test.rb b/actionpack/test/controller/request_forgery_protection_test.rb
index ef795dad89..7b722bd3d7 100644
--- a/actionpack/test/controller/request_forgery_protection_test.rb
+++ b/actionpack/test/controller/request_forgery_protection_test.rb
@@ -35,6 +35,16 @@ module RequestForgeryProtectionActions
def form_for_without_protection
render :inline => "<%= form_for(:some_resource, :authenticity_token => false ) {} %>"
end
+
+ def form_for_remote
+ render :inline => "<%= form_for(:some_resource, :remote => true ) {} %>"
+ end
+
+ def form_for_remote_with_token
+ render :inline => "<%= form_for(:some_resource, :remote => true, :authenticity_token => true ) {} %>"
+ end
+
+ def rescue_action(e) raise e end
end
# sample controllers
@@ -98,6 +108,20 @@ module RequestForgeryProtectionTests
assert_select 'form>div>input[name=?][value=?]', 'custom_authenticity_token', @token
end
+ def test_should_render_form_without_token_tag_if_remote
+ assert_not_blocked do
+ get :form_for_remote
+ end
+ assert_no_match(/authenticity_token/, response.body)
+ end
+
+ def test_should_render_form_with_token_tag_if_remote_and_authenticity_token_requested
+ assert_not_blocked do
+ get :form_for_remote_with_token
+ end
+ assert_select 'form>div>input[name=?][value=?]', 'custom_authenticity_token', @token
+ end
+
def test_should_allow_get
assert_not_blocked { get :index }
end
diff --git a/actionpack/test/controller/sweeper_test.rb b/actionpack/test/controller/sweeper_test.rb
new file mode 100644
index 0000000000..0561efc62f
--- /dev/null
+++ b/actionpack/test/controller/sweeper_test.rb
@@ -0,0 +1,16 @@
+require 'abstract_unit'
+
+
+class SweeperTest < ActionController::TestCase
+
+ class ::AppSweeper < ActionController::Caching::Sweeper; end
+
+ def test_sweeper_should_not_ignore_unknown_method_calls
+ sweeper = ActionController::Caching::Sweeper.send(:new)
+ assert_raise NameError do
+ sweeper.instance_eval do
+ some_method_that_doesnt_exist
+ end
+ end
+ end
+end
diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb
index 700666600b..cc4279d9dd 100644
--- a/actionpack/test/dispatch/routing_test.rb
+++ b/actionpack/test/dispatch/routing_test.rb
@@ -475,6 +475,11 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
get :preview, :on => :member
end
+ resources :profiles, :param => :username do
+ get :details, :on => :member
+ resources :messages
+ end
+
scope :as => "routes" do
get "/c/:id", :as => :collision, :to => "collision#show"
get "/collision", :to => "collision#show"
@@ -2183,6 +2188,19 @@ class TestRoutingMapper < ActionDispatch::IntegrationTest
assert_equal "/posts/1/admin", post_admin_root_path(:post_id => '1')
end
+ def test_custom_param
+ get '/profiles/bob'
+ assert_equal 'profiles#show', @response.body
+ assert_equal 'bob', @request.params[:username]
+
+ get '/profiles/bob/details'
+ assert_equal 'bob', @request.params[:username]
+
+ get '/profiles/bob/messages/34'
+ assert_equal 'bob', @request.params[:profile_username]
+ assert_equal '34', @request.params[:id]
+ end
+
private
def with_https
old_https = https?
diff --git a/actionpack/test/dispatch/ssl_test.rb b/actionpack/test/dispatch/ssl_test.rb
new file mode 100644
index 0000000000..6f075a9074
--- /dev/null
+++ b/actionpack/test/dispatch/ssl_test.rb
@@ -0,0 +1,157 @@
+require 'abstract_unit'
+
+class SSLTest < ActionDispatch::IntegrationTest
+ def default_app
+ lambda { |env|
+ headers = {'Content-Type' => "text/html"}
+ headers['Set-Cookie'] = "id=1; path=/\ntoken=abc; path=/; secure; HttpOnly"
+ [200, headers, ["OK"]]
+ }
+ end
+
+ def app
+ @app ||= ActionDispatch::SSL.new(default_app)
+ end
+ attr_writer :app
+
+ def test_allows_https_url
+ get "https://example.org/path?key=value"
+ assert_response :success
+ end
+
+ def test_allows_https_proxy_header_url
+ get "http://example.org/", {}, 'HTTP_X_FORWARDED_PROTO' => "https"
+ assert_response :success
+ end
+
+ def test_redirects_http_to_https
+ get "http://example.org/path?key=value"
+ assert_response :redirect
+ assert_equal "https://example.org/path?key=value",
+ response.headers['Location']
+ end
+
+ def test_hsts_header_by_default
+ get "https://example.org/"
+ assert_equal "max-age=31536000",
+ response.headers['Strict-Transport-Security']
+ end
+
+ def test_hsts_header
+ self.app = ActionDispatch::SSL.new(default_app, :hsts => true)
+ get "https://example.org/"
+ assert_equal "max-age=31536000",
+ response.headers['Strict-Transport-Security']
+ end
+
+ def test_disable_hsts_header
+ self.app = ActionDispatch::SSL.new(default_app, :hsts => false)
+ get "https://example.org/"
+ refute response.headers['Strict-Transport-Security']
+ end
+
+ def test_hsts_expires
+ self.app = ActionDispatch::SSL.new(default_app, :hsts => { :expires => 500 })
+ get "https://example.org/"
+ assert_equal "max-age=500",
+ response.headers['Strict-Transport-Security']
+ end
+
+ def test_hsts_include_subdomains
+ self.app = ActionDispatch::SSL.new(default_app, :hsts => { :subdomains => true })
+ get "https://example.org/"
+ assert_equal "max-age=31536000; includeSubDomains",
+ response.headers['Strict-Transport-Security']
+ end
+
+ def test_flag_cookies_as_secure
+ get "https://example.org/"
+ assert_equal ["id=1; path=/; secure", "token=abc; path=/; secure; HttpOnly" ],
+ response.headers['Set-Cookie'].split("\n")
+ end
+
+ def test_flag_cookies_as_secure_at_end_of_line
+ self.app = ActionDispatch::SSL.new(lambda { |env|
+ headers = {
+ 'Content-Type' => "text/html",
+ 'Set-Cookie' => "problem=def; path=/; HttpOnly; secure"
+ }
+ [200, headers, ["OK"]]
+ })
+
+ get "https://example.org/"
+ assert_equal ["problem=def; path=/; HttpOnly; secure"],
+ response.headers['Set-Cookie'].split("\n")
+ end
+
+ def test_flag_cookies_as_secure_with_more_spaces_before
+ self.app = ActionDispatch::SSL.new(lambda { |env|
+ headers = {
+ 'Content-Type' => "text/html",
+ 'Set-Cookie' => "problem=def; path=/; HttpOnly; secure"
+ }
+ [200, headers, ["OK"]]
+ })
+
+ get "https://example.org/"
+ assert_equal ["problem=def; path=/; HttpOnly; secure"],
+ response.headers['Set-Cookie'].split("\n")
+ end
+
+ def test_flag_cookies_as_secure_with_more_spaces_after
+ self.app = ActionDispatch::SSL.new(lambda { |env|
+ headers = {
+ 'Content-Type' => "text/html",
+ 'Set-Cookie' => "problem=def; path=/; secure; HttpOnly"
+ }
+ [200, headers, ["OK"]]
+ })
+
+ get "https://example.org/"
+ assert_equal ["problem=def; path=/; secure; HttpOnly"],
+ response.headers['Set-Cookie'].split("\n")
+ end
+
+ def test_no_cookies
+ self.app = ActionDispatch::SSL.new(lambda { |env|
+ [200, {'Content-Type' => "text/html"}, ["OK"]]
+ })
+ get "https://example.org/"
+ assert !response.headers['Set-Cookie']
+ end
+
+ def test_redirect_to_host
+ self.app = ActionDispatch::SSL.new(default_app, :host => "ssl.example.org")
+ get "http://example.org/path?key=value"
+ assert_equal "https://ssl.example.org/path?key=value",
+ response.headers['Location']
+ end
+
+ def test_redirect_to_port
+ self.app = ActionDispatch::SSL.new(default_app, :port => 8443)
+ get "http://example.org/path?key=value"
+ assert_equal "https://example.org:8443/path?key=value",
+ response.headers['Location']
+ end
+
+ def test_redirect_to_host_and_port
+ self.app = ActionDispatch::SSL.new(default_app, :host => "ssl.example.org", :port => 8443)
+ get "http://example.org/path?key=value"
+ assert_equal "https://ssl.example.org:8443/path?key=value",
+ response.headers['Location']
+ end
+
+ def test_redirect_to_secure_host_when_on_subdomain
+ self.app = ActionDispatch::SSL.new(default_app, :host => "ssl.example.org")
+ get "http://ssl.example.org/path?key=value"
+ assert_equal "https://ssl.example.org/path?key=value",
+ response.headers['Location']
+ end
+
+ def test_redirect_to_secure_subdomain_when_on_deep_subdomain
+ self.app = ActionDispatch::SSL.new(default_app, :host => "example.co.uk")
+ get "http://double.rainbow.what.does.it.mean.example.co.uk/path?key=value"
+ assert_equal "https://example.co.uk/path?key=value",
+ response.headers['Location']
+ end
+end
diff --git a/actionpack/test/dispatch/static_test.rb b/actionpack/test/dispatch/static_test.rb
index 092ca3e20a..112f470786 100644
--- a/actionpack/test/dispatch/static_test.rb
+++ b/actionpack/test/dispatch/static_test.rb
@@ -7,6 +7,10 @@ module StaticTests
assert_equal "Hello, World!", get("/nofile").body
end
+ def test_handles_urls_with_bad_encoding
+ assert_equal "Hello, World!", get("/doorkeeper%E3E4").body
+ end
+
def test_sets_cache_control
response = get("/index.html")
assert_html "/index.html", response
diff --git a/actionpack/test/fixtures/layouts/with_html_partial.html.erb b/actionpack/test/fixtures/layouts/with_html_partial.html.erb
new file mode 100644
index 0000000000..fd2896aeaa
--- /dev/null
+++ b/actionpack/test/fixtures/layouts/with_html_partial.html.erb
@@ -0,0 +1 @@
+<%= render :partial => "partial_only_html" %><%= yield %>
diff --git a/actionpack/test/fixtures/reply.rb b/actionpack/test/fixtures/reply.rb
index 19cba93673..0d3b0a7c98 100644
--- a/actionpack/test/fixtures/reply.rb
+++ b/actionpack/test/fixtures/reply.rb
@@ -1,5 +1,5 @@
class Reply < ActiveRecord::Base
- scope :base
+ scope :base, -> { scoped }
belongs_to :topic, :include => [:replies]
belongs_to :developer
diff --git a/actionpack/test/fixtures/test/_partial_only_html.html b/actionpack/test/fixtures/test/_partial_only_html.html
new file mode 100644
index 0000000000..d2d630bd40
--- /dev/null
+++ b/actionpack/test/fixtures/test/_partial_only_html.html
@@ -0,0 +1 @@
+only html partial \ No newline at end of file
diff --git a/actionpack/test/fixtures/test/with_html_partial.html.erb b/actionpack/test/fixtures/test/with_html_partial.html.erb
new file mode 100644
index 0000000000..d84d909d64
--- /dev/null
+++ b/actionpack/test/fixtures/test/with_html_partial.html.erb
@@ -0,0 +1 @@
+<strong><%= render :partial => "partial_only_html" %></strong>
diff --git a/actionpack/test/fixtures/test/with_partial.html.erb b/actionpack/test/fixtures/test/with_partial.html.erb
new file mode 100644
index 0000000000..7502364cf5
--- /dev/null
+++ b/actionpack/test/fixtures/test/with_partial.html.erb
@@ -0,0 +1 @@
+<strong><%= render :partial => "partial_only" %></strong>
diff --git a/actionpack/test/fixtures/test/with_partial.text.erb b/actionpack/test/fixtures/test/with_partial.text.erb
new file mode 100644
index 0000000000..5f068ebf27
--- /dev/null
+++ b/actionpack/test/fixtures/test/with_partial.text.erb
@@ -0,0 +1 @@
+**<%= render :partial => "partial_only" %>**
diff --git a/actionpack/test/fixtures/test/with_xml_template.html.erb b/actionpack/test/fixtures/test/with_xml_template.html.erb
new file mode 100644
index 0000000000..e54a7cd001
--- /dev/null
+++ b/actionpack/test/fixtures/test/with_xml_template.html.erb
@@ -0,0 +1 @@
+<%= render :template => "test/greeting", :formats => :xml %>
diff --git a/actionpack/test/template/active_model_helper_test.rb b/actionpack/test/template/active_model_helper_test.rb
index 18468ee91a..24511df444 100644
--- a/actionpack/test/template/active_model_helper_test.rb
+++ b/actionpack/test/template/active_model_helper_test.rb
@@ -43,14 +43,14 @@ class ActiveModelHelperTest < ActionView::TestCase
def test_date_select_with_errors
assert_dom_equal(
- %(<div class="field_with_errors"><select id="post_updated_at_1i" name="post[updated_at(1i)]">\n<option selected="selected" value="2004">2004</option>\n<option value="2005">2005</option>\n</select>\n<input id="post_updated_at_2i" name="post[updated_at(2i)]" type="hidden" value="6" />\n<input id="post_updated_at_3i" name="post[updated_at(3i)]" type="hidden" value="15" />\n</div>),
+ %(<div class="field_with_errors"><select id="post_updated_at_1i" name="post[updated_at(1i)]">\n<option selected="selected" value="2004">2004</option>\n<option value="2005">2005</option>\n</select>\n<input id="post_updated_at_2i" name="post[updated_at(2i)]" type="hidden" value="6" />\n<input id="post_updated_at_3i" name="post[updated_at(3i)]" type="hidden" value="1" />\n</div>),
date_select("post", "updated_at", :discard_month => true, :discard_day => true, :start_year => 2004, :end_year => 2005)
)
end
def test_datetime_select_with_errors
assert_dom_equal(
- %(<div class="field_with_errors"><input id="post_updated_at_1i" name="post[updated_at(1i)]" type="hidden" value="2004" />\n<input id="post_updated_at_2i" name="post[updated_at(2i)]" type="hidden" value="6" />\n<input id="post_updated_at_3i" name="post[updated_at(3i)]" type="hidden" value="15" />\n<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n<option selected="selected" value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n</select>\n : <select id="post_updated_at_5i" name="post[updated_at(5i)]">\n<option selected="selected" value="00">00</option>\n</select>\n</div>),
+ %(<div class="field_with_errors"><input id="post_updated_at_1i" name="post[updated_at(1i)]" type="hidden" value="2004" />\n<input id="post_updated_at_2i" name="post[updated_at(2i)]" type="hidden" value="6" />\n<input id="post_updated_at_3i" name="post[updated_at(3i)]" type="hidden" value="1" />\n<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n<option selected="selected" value="00">00</option>\n<option value="01">01</option>\n<option value="02">02</option>\n<option value="03">03</option>\n<option value="04">04</option>\n<option value="05">05</option>\n<option value="06">06</option>\n<option value="07">07</option>\n<option value="08">08</option>\n<option value="09">09</option>\n<option value="10">10</option>\n<option value="11">11</option>\n<option value="12">12</option>\n<option value="13">13</option>\n<option value="14">14</option>\n<option value="15">15</option>\n<option value="16">16</option>\n<option value="17">17</option>\n<option value="18">18</option>\n<option value="19">19</option>\n<option value="20">20</option>\n<option value="21">21</option>\n<option value="22">22</option>\n<option value="23">23</option>\n</select>\n : <select id="post_updated_at_5i" name="post[updated_at(5i)]">\n<option selected="selected" value="00">00</option>\n</select>\n</div>),
datetime_select("post", "updated_at", :discard_year => true, :discard_month => true, :discard_day => true, :minute_step => 60)
)
end
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index 9e2f4ec347..f622097b57 100644
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -711,7 +711,7 @@ class DateHelperTest < ActionView::TestCase
# Since the order is incomplete nothing will be shown
expected = %(<input id="date_first_year" name="date[first][year]" type="hidden" value="2003" />\n)
expected << %(<input id="date_first_month" name="date[first][month]" type="hidden" value="8" />\n)
- expected << %(<input id="date_first_day" name="date[first][day]" type="hidden" value="16" />\n)
+ expected << %(<input id="date_first_day" name="date[first][day]" type="hidden" value="1" />\n)
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:day])
end
@@ -943,7 +943,7 @@ class DateHelperTest < ActionView::TestCase
expected << "</select>\n"
expected << %(<input type="hidden" id="date_first_month" name="date[first][month]" value="8" />\n)
- expected << %(<input type="hidden" id="date_first_day" name="date[first][day]" value="16" />\n)
+ expected << %(<input type="hidden" id="date_first_day" name="date[first][day]" value="1" />\n)
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), { :date_separator => " / ", :discard_month => true, :discard_day => true, :start_year => 2003, :end_year => 2005, :prefix => "date[first]"})
end
@@ -1396,6 +1396,20 @@ class DateHelperTest < ActionView::TestCase
assert_dom_equal expected, date_select("post", "written_on", :order => [ :month, :year ])
end
+ def test_date_select_without_day_and_month
+ @post = Post.new
+ @post.written_on = Date.new(2004, 2, 29)
+
+ expected = "<input type=\"hidden\" id=\"post_written_on_2i\" name=\"post[written_on(2i)]\" value=\"2\" />\n"
+ expected << "<input type=\"hidden\" id=\"post_written_on_3i\" name=\"post[written_on(3i)]\" value=\"1\" />\n"
+
+ expected << %{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
+ expected << %{<option value="1999">1999</option>\n<option value="2000">2000</option>\n<option value="2001">2001</option>\n<option value="2002">2002</option>\n<option value="2003">2003</option>\n<option value="2004" selected="selected">2004</option>\n<option value="2005">2005</option>\n<option value="2006">2006</option>\n<option value="2007">2007</option>\n<option value="2008">2008</option>\n<option value="2009">2009</option>\n}
+ expected << "</select>\n"
+
+ assert_dom_equal expected, date_select("post", "written_on", :order => [ :year ])
+ end
+
def test_date_select_without_day_with_separator
@post = Post.new
@post.written_on = Date.new(2004, 6, 15)
@@ -2427,7 +2441,7 @@ class DateHelperTest < ActionView::TestCase
1999.upto(2009) { |i| expected << %(<option value="#{i}"#{' selected="selected"' if i == 2004}>#{i}</option>\n) }
expected << "</select>\n"
expected << %{<input type="hidden" id="post_updated_at_2i" name="post[updated_at(2i)]" value="6" />\n}
- expected << %{<input type="hidden" id="post_updated_at_3i" name="post[updated_at(3i)]" value="15" />\n}
+ expected << %{<input type="hidden" id="post_updated_at_3i" name="post[updated_at(3i)]" value="1" />\n}
expected << " &mdash; "
@@ -2448,7 +2462,7 @@ class DateHelperTest < ActionView::TestCase
expected = %{<input type="hidden" id="post_updated_at_1i" name="post[updated_at(1i)]" value="2004" />\n}
expected << %{<input type="hidden" id="post_updated_at_2i" name="post[updated_at(2i)]" value="6" />\n}
- expected << %{<input type="hidden" id="post_updated_at_3i" name="post[updated_at(3i)]" value="15" />\n}
+ expected << %{<input type="hidden" id="post_updated_at_3i" name="post[updated_at(3i)]" value="1" />\n}
expected << %{<select id="post_updated_at_4i" name="post[updated_at(4i)]">\n}
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
@@ -2467,7 +2481,7 @@ class DateHelperTest < ActionView::TestCase
expected = %{<input type="hidden" id="post_updated_at_1i" disabled="disabled" name="post[updated_at(1i)]" value="2004" />\n}
expected << %{<input type="hidden" id="post_updated_at_2i" disabled="disabled" name="post[updated_at(2i)]" value="6" />\n}
- expected << %{<input type="hidden" id="post_updated_at_3i" disabled="disabled" name="post[updated_at(3i)]" value="15" />\n}
+ expected << %{<input type="hidden" id="post_updated_at_3i" disabled="disabled" name="post[updated_at(3i)]" value="1" />\n}
expected << %{<select id="post_updated_at_4i" disabled="disabled" name="post[updated_at(4i)]">\n}
0.upto(23) { |i| expected << %(<option value="#{sprintf("%02d", i)}"#{' selected="selected"' if i == 15}>#{sprintf("%02d", i)}</option>\n) }
@@ -2865,6 +2879,10 @@ class DateHelperTest < ActionView::TestCase
assert_match(/<time.*>Right now<\/time>/, time_tag(Time.now, 'Right now'))
end
+ def test_time_tag_with_given_block
+ assert_match(/<time.*><span>Right now<\/span><\/time>/, time_tag(Time.now){ '<span>Right now</span>'.html_safe })
+ end
+
def test_time_tag_with_different_format
time = Time.now
expected = "<time datetime=\"#{time.xmlschema}\">#{I18n.l(time, :format => :short)}</time>"
diff --git a/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb b/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb
index cfeb4aa7cd..4491e07a72 100644
--- a/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb
+++ b/activemodel/lib/active_model/mass_assignment_security/sanitizer.rb
@@ -3,18 +3,16 @@ module ActiveModel
class Sanitizer
# Returns all attributes not denied by the authorizer.
def sanitize(attributes, authorizer)
- sanitized_attributes = attributes.reject { |key, value| authorizer.deny?(key) }
- debug_protected_attribute_removal(attributes, sanitized_attributes)
+ rejected = []
+ sanitized_attributes = attributes.reject do |key, value|
+ rejected << key if authorizer.deny?(key)
+ end
+ process_removed_attributes(rejected) unless rejected.empty?
sanitized_attributes
end
protected
- def debug_protected_attribute_removal(attributes, sanitized_attributes)
- removed_keys = attributes.keys - sanitized_attributes.keys
- process_removed_attributes(removed_keys) if removed_keys.any?
- end
-
def process_removed_attributes(attrs)
raise NotImplementedError, "#process_removed_attributes(attrs) suppose to be overwritten"
end
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb
index fd0bc4e8e9..b22d9539b0 100644
--- a/activemodel/lib/active_model/naming.rb
+++ b/activemodel/lib/active_model/naming.rb
@@ -6,13 +6,11 @@ require 'active_support/core_ext/object/blank'
module ActiveModel
class Name < String
- attr_reader :singular, :plural, :element, :collection, :partial_path,
+ attr_reader :singular, :plural, :element, :collection,
:singular_route_key, :route_key, :param_key, :i18n_key
alias_method :cache_key, :collection
- deprecate :partial_path => "ActiveModel::Name#partial_path is deprecated. Call #to_partial_path on model instances directly instead."
-
def initialize(klass, namespace = nil, name = nil)
name ||= klass.name
@@ -27,7 +25,6 @@ module ActiveModel
@element = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self)).freeze
@human = ActiveSupport::Inflector.humanize(@element).freeze
@collection = ActiveSupport::Inflector.tableize(self).freeze
- @partial_path = "#{@collection}/#{@element}".freeze
@param_key = (namespace ? _singularize(@unnamespaced) : @singular).freeze
@i18n_key = self.underscore.to_sym
diff --git a/activemodel/test/cases/naming_test.rb b/activemodel/test/cases/naming_test.rb
index 1e14d83bcb..49d8706ac2 100644
--- a/activemodel/test/cases/naming_test.rb
+++ b/activemodel/test/cases/naming_test.rb
@@ -25,12 +25,6 @@ class NamingTest < ActiveModel::TestCase
assert_equal 'post/track_backs', @model_name.collection
end
- def test_partial_path
- assert_deprecated(/#partial_path.*#to_partial_path/) do
- assert_equal 'post/track_backs/track_back', @model_name.partial_path
- end
- end
-
def test_human
assert_equal 'Track back', @model_name.human
end
@@ -61,12 +55,6 @@ class NamingWithNamespacedModelInIsolatedNamespaceTest < ActiveModel::TestCase
assert_equal 'blog/posts', @model_name.collection
end
- def test_partial_path
- assert_deprecated(/#partial_path.*#to_partial_path/) do
- assert_equal 'blog/posts/post', @model_name.partial_path
- end
- end
-
def test_human
assert_equal 'Post', @model_name.human
end
@@ -105,12 +93,6 @@ class NamingWithNamespacedModelInSharedNamespaceTest < ActiveModel::TestCase
assert_equal 'blog/posts', @model_name.collection
end
- def test_partial_path
- assert_deprecated(/#partial_path.*#to_partial_path/) do
- assert_equal 'blog/posts/post', @model_name.partial_path
- end
- end
-
def test_human
assert_equal 'Post', @model_name.human
end
@@ -149,12 +131,6 @@ class NamingWithSuppliedModelNameTest < ActiveModel::TestCase
assert_equal 'articles', @model_name.collection
end
- def test_partial_path
- assert_deprecated(/#partial_path.*#to_partial_path/) do
- assert_equal 'articles/article', @model_name.partial_path
- end
- end
-
def test_human
assert_equal 'Article', @model_name.human
end
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 5a289a5aac..46031e7c13 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,5 +1,36 @@
## Rails 4.0.0 (unreleased) ##
+* Deprecate eager-evaluated scopes.
+
+ Don't use this:
+
+ scope :red, where(color: 'red')
+ default_scope where(color: 'red')
+
+ Use this:
+
+ scope :red, -> { where(color: 'red') }
+ default_scope { where(color: 'red') }
+
+ The former has numerous issues. It is a common newbie gotcha to do
+ the following:
+
+ scope :recent, where(published_at: Time.now - 2.weeks)
+
+ Or a more subtle variant:
+
+ scope :recent, -> { where(published_at: Time.now - 2.weeks) }
+ scope :recent_red, recent.where(color: 'red')
+
+ Eager scopes are also very complex to implement within Active
+ Record, and there are still bugs. For example, the following does
+ not do what you expect:
+
+ scope :remove_conditions, except(:where)
+ where(...).remove_conditions # => still has conditions
+
+ *Jon Leighton*
+
* Remove IdentityMap
IdentityMap has never graduated to be an "enabled-by-default" feature, due
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index be0af081d1..3005bef092 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -28,7 +28,7 @@ module ActiveRecord
# Association with autosave option defines several callbacks on your
# model (before_save, after_create, after_update). Please note that
# callbacks are executed in the order they were defined in
- # model. You should avoid modyfing the association content, before
+ # model. You should avoid modifying the association content, before
# autosave callbacks are executed. Placing your callbacks after
# associations is usually a good practice.
#
@@ -328,13 +328,14 @@ module ActiveRecord
autosave = reflection.options[:autosave]
if records = associated_records_to_validate_or_save(association, @new_record_before_save, autosave)
+ records_to_destroy = []
records.each do |record|
next if record.destroyed?
saved = true
if autosave && record.marked_for_destruction?
- association.proxy.destroy(record)
+ records_to_destroy << record
elsif autosave != false && (@new_record_before_save || record.new_record?)
if autosave
saved = association.insert_record(record, false)
@@ -347,6 +348,10 @@ module ActiveRecord
raise ActiveRecord::Rollback unless saved
end
+
+ records_to_destroy.each do |record|
+ association.proxy.destroy(record)
+ end
end
# reconstruct the scope now that we know the owner's id
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
index 767c99de4c..1d713e472b 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -284,26 +284,25 @@ module ActiveRecord
protected
- def log(sql, name = "SQL", binds = [])
- @instrumenter.instrument(
- "sql.active_record",
- :sql => sql,
- :name => name,
- :connection_id => object_id,
- :binds => binds) { yield }
- rescue Exception => e
- message = "#{e.class.name}: #{e.message}: #{sql}"
- @logger.debug message if @logger
- exception = translate_exception(e, message)
- exception.set_backtrace e.backtrace
- raise exception
- end
-
- def translate_exception(e, message)
- # override in derived class
- ActiveRecord::StatementInvalid.new(message)
- end
-
+ def log(sql, name = "SQL", binds = [])
+ @instrumenter.instrument(
+ "sql.active_record",
+ :sql => sql,
+ :name => name,
+ :connection_id => object_id,
+ :binds => binds) { yield }
+ rescue Exception => e
+ message = "#{e.class.name}: #{e.message}: #{sql}"
+ @logger.error message if @logger
+ exception = translate_exception(e, message)
+ exception.set_backtrace e.backtrace
+ raise exception
+ end
+
+ def translate_exception(e, message)
+ # override in derived class
+ ActiveRecord::StatementInvalid.new(message)
+ end
end
end
end
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 5b7fa029da..10a178e369 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -1006,7 +1006,7 @@ module ActiveRecord
# This should be not be called manually but set in database.yml.
def schema_search_path=(schema_csv)
if schema_csv
- execute "SET search_path TO #{schema_csv}"
+ execute("SET search_path TO #{schema_csv}", 'SCHEMA')
@schema_search_path = schema_csv
end
end
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 46aababfb6..9a2f859fc7 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -176,7 +176,7 @@ module ActiveRecord
assign_attributes(attributes, options) if attributes
yield self if block_given?
- run_callbacks :initialize
+ run_callbacks :initialize if _initialize_callbacks.any?
end
# Initialize an empty model object from +coder+. +coder+ must contain
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 5c42e8f719..9796b0a321 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -4,16 +4,12 @@ require 'zlib'
require 'active_support/dependencies'
require 'active_support/core_ext/object/blank'
require 'active_record/fixtures/file'
+require 'active_record/errors'
-if defined? ActiveRecord
+module ActiveRecord
class FixtureClassNotFound < ActiveRecord::ActiveRecordError #:nodoc:
end
-else
- class FixtureClassNotFound < StandardError #:nodoc:
- end
-end
-module ActiveRecord
# \Fixtures are a way of organizing data that you want to test against; in short, sample data.
#
# They are stored in YAML files, one file per model, which are placed in the directory
diff --git a/activerecord/lib/active_record/inheritance.rb b/activerecord/lib/active_record/inheritance.rb
index ebe244c6a6..46d253b0a7 100644
--- a/activerecord/lib/active_record/inheritance.rb
+++ b/activerecord/lib/active_record/inheritance.rb
@@ -48,6 +48,20 @@ module ActiveRecord
end
# Set this to true if this is an abstract class (see <tt>abstract_class?</tt>).
+ # If you are using inheritance with ActiveRecord and don't want child classes
+ # to utilize the implied STI table name of the parent class, this will need to be true.
+ # For example, given the following:
+ #
+ # class SuperClass < ActiveRecord::Base
+ # self.abstract_class = true
+ # end
+ # class Child < SuperClass
+ # self.table_name = 'the_table_i_really_want'
+ # end
+ #
+ #
+ # <tt>self.abstract_class = true</tt> is required to make <tt>Child<.find,.create, or any Arel method></tt> use <tt>the_table_i_really_want</tt> instead of a table called <tt>super_classes</tt>
+ #
attr_accessor :abstract_class
# Returns whether this class is an abstract class or not.
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb
index 99847ac161..c85d590ce1 100644
--- a/activerecord/lib/active_record/model_schema.rb
+++ b/activerecord/lib/active_record/model_schema.rb
@@ -160,6 +160,7 @@ module ActiveRecord
# Sets the value of inheritance_column
def inheritance_column=(value)
@inheritance_column = value.to_s
+ @explicit_inheritance_column = true
end
def sequence_name
@@ -303,7 +304,7 @@ module ActiveRecord
@column_types = nil
@content_columns = nil
@dynamic_methods_hash = nil
- @inheritance_column = nil
+ @inheritance_column = nil unless defined?(@explicit_inheritance_column) && @explicit_inheritance_column
@relation = nil
end
diff --git a/activerecord/lib/active_record/railties/databases.rake b/activerecord/lib/active_record/railties/databases.rake
index f26989ae57..f26e18b1e0 100644
--- a/activerecord/lib/active_record/railties/databases.rake
+++ b/activerecord/lib/active_record/railties/databases.rake
@@ -426,6 +426,7 @@ db_namespace = namespace :db do
if ActiveRecord::Base.connection.supports_migrations?
File.open(filename, "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
end
+ db_namespace['structure:dump'].reenable
end
# desc "Recreate the databases from the structure.sql file"
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 6f39708ec3..b125449127 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -256,7 +256,7 @@ module ActiveRecord
# # Update all books with 'Rails' in their title
# Book.update_all "author = 'David'", "title LIKE '%Rails%'"
#
- # # Update all avatars migrated more than a week ago
+ # # Update all avatars migrated more recently than a week ago
# Avatar.update_all ['migrated_at = ?', Time.now.utc], ['migrated_at > ?', 1.week.ago]
#
# # Update all books that match conditions, but limit it to 5 ordered by date
@@ -507,6 +507,10 @@ module ActiveRecord
end
end
+ def blank?
+ to_a.blank?
+ end
+
private
def references_eager_loaded_tables?
diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb
index 5f05d146f2..b0609a8c08 100644
--- a/activerecord/lib/active_record/scoping/default.rb
+++ b/activerecord/lib/active_record/scoping/default.rb
@@ -1,4 +1,5 @@
require 'active_support/concern'
+require 'active_support/deprecation'
module ActiveRecord
module Scoping
@@ -51,7 +52,7 @@ module ActiveRecord
# the model.
#
# class Article < ActiveRecord::Base
- # default_scope where(:published => true)
+ # default_scope { where(:published => true) }
# end
#
# Article.all # => SELECT * FROM articles WHERE published = true
@@ -62,12 +63,6 @@ module ActiveRecord
# Article.new.published # => true
# Article.create.published # => true
#
- # You can also use <tt>default_scope</tt> with a block, in order to have it lazily evaluated:
- #
- # class Article < ActiveRecord::Base
- # default_scope { where(:published_at => Time.now - 1.week) }
- # end
- #
# (You can also pass any object which responds to <tt>call</tt> to the <tt>default_scope</tt>
# macro, and it will be called when building the default scope.)
#
@@ -75,8 +70,8 @@ module ActiveRecord
# be merged together:
#
# class Article < ActiveRecord::Base
- # default_scope where(:published => true)
- # default_scope where(:rating => 'G')
+ # default_scope { where(:published => true) }
+ # default_scope { where(:rating => 'G') }
# end
#
# Article.all # => SELECT * FROM articles WHERE published = true AND rating = 'G'
@@ -94,6 +89,16 @@ module ActiveRecord
# end
def default_scope(scope = {})
scope = Proc.new if block_given?
+
+ if scope.is_a?(Relation) || !scope.respond_to?(:call)
+ ActiveSupport::Deprecation.warn(
+ "Calling #default_scope without a block is deprecated. For example instead " \
+ "of `default_scope where(color: 'red')`, please use " \
+ "`default_scope { where(color: 'red') }`. (Alternatively you can just redefine " \
+ "self.default_scope.)"
+ )
+ end
+
self.default_scopes = default_scopes + [scope]
end
@@ -106,7 +111,7 @@ module ActiveRecord
if scope.is_a?(Hash)
default_scope.apply_finder_options(scope)
elsif !scope.is_a?(Relation) && scope.respond_to?(:call)
- default_scope.merge(scope.call)
+ default_scope.merge(unscoped { scope.call })
else
default_scope.merge(scope)
end
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index 0edc3f1dcc..077e2d067e 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -3,6 +3,7 @@ require 'active_support/core_ext/hash/except'
require 'active_support/core_ext/kernel/singleton_class'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/class/attribute'
+require 'active_support/deprecation'
module ActiveRecord
# = Active Record Named \Scopes
@@ -171,30 +172,30 @@ module ActiveRecord
# Article.published.featured.latest_article
# Article.featured.titles
- def scope(name, scope_options = {})
- name = name.to_sym
- valid_scope_name?(name)
- extension = Module.new(&Proc.new) if block_given?
+ def scope(name, body = {}, &block)
+ extension = Module.new(&block) if block
- scope_proc = lambda do |*args|
- options = scope_options.respond_to?(:call) ? unscoped { scope_options.call(*args) } : scope_options
+ # Check body.is_a?(Relation) to prevent the relation actually being
+ # loaded by respond_to?
+ if body.is_a?(Relation) || !body.respond_to?(:call)
+ ActiveSupport::Deprecation.warn(
+ "Using #scope without passing a callable object is deprecated. For " \
+ "example `scope :red, where(color: 'red')` should be changed to " \
+ "`scope :red, -> { where(color: 'red') }`. There are numerous gotchas " \
+ "in the former usage and it makes the implementation more complicated " \
+ "and buggy. (If you prefer, you can just define a class method named " \
+ "`self.red`.)"
+ )
+ end
+
+ singleton_class.send(:define_method, name) do |*args|
+ options = body.respond_to?(:call) ? unscoped { body.call(*args) } : body
options = scoped.apply_finder_options(options) if options.is_a?(Hash)
relation = scoped.merge(options)
extension ? relation.extending(extension) : relation
end
-
- singleton_class.send(:redefine_method, name, &scope_proc)
- end
-
- protected
-
- def valid_scope_name?(name)
- if respond_to?(name, true)
- logger.warn "Creating scope :#{name}. " \
- "Overwriting existing method #{self.name}.#{name}."
- end
end
end
end
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb
index 9556878f63..db618f617f 100644
--- a/activerecord/lib/active_record/validations/uniqueness.rb
+++ b/activerecord/lib/active_record/validations/uniqueness.rb
@@ -35,8 +35,14 @@ module ActiveRecord
relation = relation.and(table[scope_item].eq(scope_value))
end
- if finder_class.unscoped.where(relation).exists?
- record.errors.add(attribute, :taken, options.except(:case_sensitive, :scope).merge(:value => value))
+ relation = finder_class.unscoped.where(relation)
+
+ if options[:conditions]
+ relation = relation.merge(options[:conditions])
+ end
+
+ if relation.exists?
+ record.errors.add(attribute, :taken, options.except(:case_sensitive, :scope, :conditions).merge(:value => value))
end
end
@@ -102,6 +108,14 @@ module ActiveRecord
# validates_uniqueness_of :teacher_id, :scope => [:semester_id, :class_id]
# end
#
+ # It is also possible to limit the uniqueness constraint to a set of records matching certain conditions.
+ # In this example archived articles are not being taken into consideration when validating uniqueness
+ # of the title attribute:
+ #
+ # class Article < ActiveRecord::Base
+ # validates_uniqueness_of :title, :conditions => where('status != ?', 'archived')
+ # end
+ #
# When the record is created, a check is performed to make sure that no record exists in the database
# with the given value for the specified attribute (that maps to a column). When the record is updated,
# the same check is made but disregarding the record itself.
@@ -109,6 +123,8 @@ module ActiveRecord
# Configuration options:
# * <tt>:message</tt> - Specifies a custom error message (default is: "has already been taken").
# * <tt>:scope</tt> - One or more columns by which to limit the scope of the uniqueness constraint.
+ # * <tt>:conditions</tt> - Specify the conditions to be included as a <tt>WHERE</tt> SQL fragment to limit
+ # the uniqueness constraint lookup. (e.g. <tt>:conditions => where('status = ?', 'active')</tt>)
# * <tt>:case_sensitive</tt> - Looks for an exact match. Ignored by non-text columns (+true+ by default).
# * <tt>:allow_nil</tt> - If set to true, skips this validation if the attribute is +nil+ (default is +false+).
# * <tt>:allow_blank</tt> - If set to true, skips this validation if the attribute is blank (default is +false+).
diff --git a/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb b/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
index d084a00ed7..9ca63a209e 100644
--- a/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
+++ b/activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
@@ -5,7 +5,7 @@ class <%= migration_class_name %> < ActiveRecord::Migration
add_column :<%= table_name %>, :<%= attribute.name %>, :<%= attribute.type %><%= attribute.inject_options %>
<%- if attribute.has_index? -%>
add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
- <%- end %>
+ <%- end -%>
<%- end -%>
end
<%- else -%>
@@ -24,6 +24,9 @@ class <%= migration_class_name %> < ActiveRecord::Migration
<% attributes.reverse.each do |attribute| -%>
<%- if migration_action -%>
<%= migration_action == 'add' ? 'remove' : 'add' %>_column :<%= table_name %>, :<%= attribute.name %><% if migration_action == 'remove' %>, :<%= attribute.type %><%= attribute.inject_options %><% end %>
+ <%- if attribute.has_index? && migration_action == 'remove' -%>
+ add_index :<%= table_name %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
+ <%- end -%>
<%- end -%>
<%- end -%>
end
diff --git a/activerecord/test/cases/adapters/postgresql/explain_test.rb b/activerecord/test/cases/adapters/postgresql/explain_test.rb
index 0b61f61572..619d581d5f 100644
--- a/activerecord/test/cases/adapters/postgresql/explain_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/explain_test.rb
@@ -22,6 +22,13 @@ module ActiveRecord
assert_match %(EXPLAIN for: SELECT "audit_logs".* FROM "audit_logs" WHERE "audit_logs"."developer_id" IN (1)), explain
assert_match %(Seq Scan on audit_logs), explain
end
+
+ def test_dont_explain_for_set_search_path
+ queries = Thread.current[:available_queries_for_explain] = []
+ ActiveRecord::Base.connection.schema_search_path = "public"
+ assert queries.empty?
+ end
+
end
end
end
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 67b65c51d5..d15487ab11 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -767,6 +767,16 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase
assert_equal before, @pirate.reload.birds
end
+ def test_when_new_record_a_child_marked_for_destruction_should_not_affect_other_records_from_saving
+ @pirate = @ship.build_pirate(:catchphrase => "Arr' now I shall keep me eye on you matey!") # new record
+
+ 3.times { |i| @pirate.birds.build(:name => "birds_#{i}") }
+ @pirate.birds[1].mark_for_destruction
+ @pirate.save!
+
+ assert_equal 2, @pirate.birds.reload.length
+ end
+
# Add and remove callbacks tests for association collections.
%w{ method proc }.each do |callback_type|
define_method("test_should_run_add_callback_#{callback_type}s_for_has_many") do
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 76b999efac..fb2f66c4f8 100644
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -163,7 +163,7 @@ class BasicsTest < ActiveRecord::TestCase
def test_select_symbol
topic_ids = Topic.select(:id).map(&:id).sort
- assert_equal Topic.all.map(&:id).sort, topic_ids
+ assert_equal Topic.pluck(:id).sort, topic_ids
end
def test_table_exists
@@ -1503,6 +1503,16 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal before_seq, after_seq unless before_seq.blank? && after_seq.blank?
end
+ def test_dont_clear_inheritnce_column_when_setting_explicitly
+ Joke.inheritance_column = "my_type"
+ before_inherit = Joke.inheritance_column
+
+ Joke.reset_column_information
+ after_inherit = Joke.inheritance_column
+
+ assert_equal before_inherit, after_inherit unless before_inherit.blank? && after_inherit.blank?
+ end
+
def test_set_table_name_symbol_converted_to_string
Joke.table_name = :cold_jokes
assert_equal 'cold_jokes', Joke.table_name
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index 562b370c97..e660b2ca35 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -514,7 +514,7 @@ class InvalidTableNameFixturesTest < ActiveRecord::TestCase
self.use_transactional_fixtures = false
def test_raises_error
- assert_raise FixtureClassNotFound do
+ assert_raise ActiveRecord::FixtureClassNotFound do
funny_jokes(:a_joke)
end
end
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index e17ba76437..0d3c0b20a4 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -123,16 +123,6 @@ class NamedScopeTest < ActiveRecord::TestCase
assert objects.all?(&:approved?), 'all objects should be approved'
end
- def test_extensions
- assert_equal 1, Topic.anonymous_extension.one
- assert_equal 2, Topic.named_extension.two
- end
-
- def test_multiple_extensions
- assert_equal 2, Topic.multiple_extensions.extension_two
- assert_equal 1, Topic.multiple_extensions.extension_one
- end
-
def test_has_many_associations_have_access_to_scopes
assert_not_equal Post.containing_the_letter_a, authors(:david).posts
assert !Post.containing_the_letter_a.empty?
@@ -393,25 +383,6 @@ class NamedScopeTest < ActiveRecord::TestCase
end
end
- def test_scopes_with_reserved_names
- class << Topic
- def public_method; end
- public :public_method
-
- def protected_method; end
- protected :protected_method
-
- def private_method; end
- private :private_method
- end
-
- [:public_method, :protected_method, :private_method].each do |reserved_method|
- assert Topic.respond_to?(reserved_method, true)
- ActiveRecord::Base.logger.expects(:warn)
- Topic.scope(reserved_method)
- end
- end
-
def test_scopes_on_relations
# Topic.replied
approved_topics = Topic.scoped.approved.order('id DESC')
@@ -483,6 +454,41 @@ class NamedScopeTest < ActiveRecord::TestCase
require "models/without_table"
end
end
+
+ def test_eager_scopes_are_deprecated
+ klass = Class.new(ActiveRecord::Base)
+ klass.table_name = 'posts'
+
+ assert_deprecated do
+ klass.scope :welcome, { :conditions => { :id => posts(:welcome).id } }
+ end
+ assert_equal [posts(:welcome).title], klass.welcome.map(&:title)
+
+ assert_deprecated do
+ klass.scope :welcome_2, klass.where(:id => posts(:welcome).id)
+ end
+ assert_equal [posts(:welcome).title], klass.welcome_2.map(&:title)
+ end
+
+ def test_eager_default_scope_hashes_are_deprecated
+ klass = Class.new(ActiveRecord::Base)
+ klass.table_name = 'posts'
+
+ assert_deprecated do
+ klass.send(:default_scope, :conditions => { :id => posts(:welcome).id })
+ end
+ assert_equal [posts(:welcome).title], klass.all.map(&:title)
+ end
+
+ def test_eager_default_scope_relations_are_deprecated
+ klass = Class.new(ActiveRecord::Base)
+ klass.table_name = 'posts'
+
+ assert_deprecated do
+ klass.send(:default_scope, klass.where(:id => posts(:welcome).id))
+ end
+ assert_equal [posts(:welcome).title], klass.all.map(&:title)
+ end
end
class DynamicScopeMatchTest < ActiveRecord::TestCase
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 91bc407d42..3edc237c44 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -1234,4 +1234,26 @@ class RelationTest < ActiveRecord::TestCase
scope = Post.order('foo(comments.body)')
assert_equal [], scope.references_values
end
+
+ def test_presence
+ topics = Topic.scoped
+
+ # the first query is triggered because there are no topics yet.
+ assert_queries(1) { assert topics.present? }
+
+ # checking if there are topics is used before you actually display them,
+ # thus it shouldn't invoke an extra count query.
+ assert_no_queries { assert topics.present? }
+ assert_no_queries { assert !topics.blank? }
+
+ # shows count of topics and loops after loading the query should not trigger extra queries either.
+ assert_no_queries { topics.size }
+ assert_no_queries { topics.length }
+ assert_no_queries { topics.each }
+
+ # count always trigger the COUNT query.
+ assert_queries(1) { topics.count }
+
+ assert topics.loaded?
+ end
end
diff --git a/activerecord/test/cases/schema_dumper_test.rb b/activerecord/test/cases/schema_dumper_test.rb
index 3314013cd4..15ceaa1fcc 100644
--- a/activerecord/test/cases/schema_dumper_test.rb
+++ b/activerecord/test/cases/schema_dumper_test.rb
@@ -239,7 +239,7 @@ class SchemaDumperTest < ActiveRecord::TestCase
def test_schema_dump_includes_hstores_shorthand_definition
output = standard_dump
if %r{create_table "postgresql_hstores"} =~ output
- assert_match %r{t.hstore "hash_store", default => ""}, output
+ assert_match %r[t.hstore "hash_store", :default => {}], output
end
end
diff --git a/activerecord/test/cases/validations/uniqueness_validation_test.rb b/activerecord/test/cases/validations/uniqueness_validation_test.rb
index 79442d68b0..376c0000c7 100644
--- a/activerecord/test/cases/validations/uniqueness_validation_test.rb
+++ b/activerecord/test/cases/validations/uniqueness_validation_test.rb
@@ -325,4 +325,16 @@ class UniquenessValidationTest < ActiveRecord::TestCase
assert w6.errors[:city].any?, "Should have errors for city"
assert_equal ["has already been taken"], w6.errors[:city], "Should have uniqueness message for city"
end
+
+ def test_validate_uniqueness_with_conditions
+ Topic.validates_uniqueness_of(:title, :conditions => Topic.where('approved = ?', true))
+ t1 = Topic.create("title" => "I'm a topic", "approved" => true)
+ t2 = Topic.create("title" => "I'm an unapproved topic", "approved" => false)
+
+ t3 = Topic.new("title" => "I'm a topic", "approved" => true)
+ assert !t3.valid?, "t3 shouldn't be valid"
+
+ t4 = Topic.new("title" => "I'm an unapproved topic", "approved" => false)
+ assert t4.valid?, "t4 should be valid"
+ end
end
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb
index d50e11d6c9..14444a0092 100644
--- a/activerecord/test/models/author.rb
+++ b/activerecord/test/models/author.rb
@@ -140,8 +140,8 @@ class Author < ActiveRecord::Base
has_many :posts_with_default_include, :class_name => 'PostWithDefaultInclude'
has_many :comments_on_posts_with_default_include, :through => :posts_with_default_include, :source => :comments
- scope :relation_include_posts, includes(:posts)
- scope :relation_include_tags, includes(:tags)
+ scope :relation_include_posts, -> { includes(:posts) }
+ scope :relation_include_tags, -> { includes(:tags) }
attr_accessor :post_log
after_initialize :set_post_log
diff --git a/activerecord/test/models/bulb.rb b/activerecord/test/models/bulb.rb
index 888afc7604..640e57555d 100644
--- a/activerecord/test/models/bulb.rb
+++ b/activerecord/test/models/bulb.rb
@@ -1,5 +1,5 @@
class Bulb < ActiveRecord::Base
- default_scope where(:name => 'defaulty')
+ default_scope { where(:name => 'defaulty') }
belongs_to :car
attr_protected :car_id, :frickinawesome
diff --git a/activerecord/test/models/car.rb b/activerecord/test/models/car.rb
index 6ff1329d8e..42ac81690f 100644
--- a/activerecord/test/models/car.rb
+++ b/activerecord/test/models/car.rb
@@ -11,18 +11,18 @@ class Car < ActiveRecord::Base
has_many :engines, :dependent => :destroy
has_many :wheels, :as => :wheelable, :dependent => :destroy
- scope :incl_tyres, includes(:tyres)
- scope :incl_engines, includes(:engines)
+ scope :incl_tyres, -> { includes(:tyres) }
+ scope :incl_engines, -> { includes(:engines) }
- scope :order_using_new_style, order('name asc')
- scope :order_using_old_style, :order => 'name asc'
+ scope :order_using_new_style, -> { order('name asc') }
+ scope :order_using_old_style, -> { { :order => 'name asc' } }
end
class CoolCar < Car
- default_scope :order => 'name desc'
+ default_scope { order('name desc') }
end
class FastCar < Car
- default_scope :order => 'name desc'
+ default_scope { order('name desc') }
end
diff --git a/activerecord/test/models/categorization.rb b/activerecord/test/models/categorization.rb
index 4bd980e606..6588531de6 100644
--- a/activerecord/test/models/categorization.rb
+++ b/activerecord/test/models/categorization.rb
@@ -12,7 +12,7 @@ end
class SpecialCategorization < ActiveRecord::Base
self.table_name = 'categorizations'
- default_scope where(:special => true)
+ default_scope { where(:special => true) }
belongs_to :author
belongs_to :category
diff --git a/activerecord/test/models/category.rb b/activerecord/test/models/category.rb
index 02b85fd38a..ab3139680c 100644
--- a/activerecord/test/models/category.rb
+++ b/activerecord/test/models/category.rb
@@ -27,7 +27,7 @@ class Category < ActiveRecord::Base
has_many :authors, :through => :categorizations
has_many :authors_with_select, :through => :categorizations, :source => :author, :select => 'authors.*, categorizations.post_id'
- scope :general, :conditions => { :name => 'General' }
+ scope :general, -> { where(:name => 'General') }
end
class SpecialCategory < Category
diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb
index 88b139d931..00f5a74070 100644
--- a/activerecord/test/models/comment.rb
+++ b/activerecord/test/models/comment.rb
@@ -1,12 +1,10 @@
class Comment < ActiveRecord::Base
scope :limit_by, lambda {|l| limit(l) }
- scope :containing_the_letter_e, :conditions => "comments.body LIKE '%e%'"
- scope :not_again, where("comments.body NOT LIKE '%again%'")
- scope :for_first_post, :conditions => { :post_id => 1 }
- scope :for_first_author,
- :joins => :post,
- :conditions => { "posts.author_id" => 1 }
- scope :created
+ scope :containing_the_letter_e, -> { where("comments.body LIKE '%e%'") }
+ scope :not_again, -> { where("comments.body NOT LIKE '%again%'") }
+ scope :for_first_post, -> { where(:post_id => 1) }
+ scope :for_first_author, -> { joins(:post).where("posts.author_id" => 1) }
+ scope :created, -> { scoped }
belongs_to :post, :counter_cache => true
has_many :ratings
@@ -25,7 +23,7 @@ class Comment < ActiveRecord::Base
def self.all_as_method
all
end
- scope :all_as_scope, {}
+ scope :all_as_scope, -> { scoped }
end
class SpecialComment < Comment
diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb
index 4dc9fff9fd..4cc4947e3b 100644
--- a/activerecord/test/models/developer.rb
+++ b/activerecord/test/models/developer.rb
@@ -45,7 +45,7 @@ class Developer < ActiveRecord::Base
has_many :audit_logs
- scope :jamises, :conditions => {:name => 'Jamis'}
+ scope :jamises, -> { where(:name => 'Jamis') }
validates_inclusion_of :salary, :in => 50000..200000
validates_length_of :name, :within => 3..20
@@ -88,20 +88,20 @@ end
class DeveloperWithSelect < ActiveRecord::Base
self.table_name = 'developers'
- default_scope select('name')
+ default_scope { select('name') }
end
class DeveloperWithIncludes < ActiveRecord::Base
self.table_name = 'developers'
has_many :audit_logs, :foreign_key => :developer_id
- default_scope includes(:audit_logs)
+ default_scope { includes(:audit_logs) }
end
class DeveloperOrderedBySalary < ActiveRecord::Base
self.table_name = 'developers'
- default_scope :order => 'salary DESC'
+ default_scope { order('salary DESC') }
- scope :by_name, order('name DESC')
+ scope :by_name, -> { order('name DESC') }
def self.all_ordered_by_name
with_scope(:find => { :order => 'name DESC' }) do
@@ -112,7 +112,7 @@ end
class DeveloperCalledDavid < ActiveRecord::Base
self.table_name = 'developers'
- default_scope where("name = 'David'")
+ default_scope { where("name = 'David'") }
end
class LazyLambdaDeveloperCalledDavid < ActiveRecord::Base
@@ -140,7 +140,7 @@ end
class ClassMethodReferencingScopeDeveloperCalledDavid < ActiveRecord::Base
self.table_name = 'developers'
- scope :david, where(:name => 'David')
+ scope :david, -> { where(:name => 'David') }
def self.default_scope
david
@@ -149,40 +149,40 @@ end
class LazyBlockReferencingScopeDeveloperCalledDavid < ActiveRecord::Base
self.table_name = 'developers'
- scope :david, where(:name => 'David')
+ scope :david, -> { where(:name => 'David') }
default_scope { david }
end
class DeveloperCalledJamis < ActiveRecord::Base
self.table_name = 'developers'
- default_scope where(:name => 'Jamis')
- scope :poor, where('salary < 150000')
+ default_scope { where(:name => 'Jamis') }
+ scope :poor, -> { where('salary < 150000') }
end
class PoorDeveloperCalledJamis < ActiveRecord::Base
self.table_name = 'developers'
- default_scope where(:name => 'Jamis', :salary => 50000)
+ default_scope -> { where(:name => 'Jamis', :salary => 50000) }
end
class InheritedPoorDeveloperCalledJamis < DeveloperCalledJamis
self.table_name = 'developers'
- default_scope where(:salary => 50000)
+ default_scope -> { where(:salary => 50000) }
end
class MultiplePoorDeveloperCalledJamis < ActiveRecord::Base
self.table_name = 'developers'
- default_scope where(:name => 'Jamis')
- default_scope where(:salary => 50000)
+ default_scope -> { where(:name => 'Jamis') }
+ default_scope -> { where(:salary => 50000) }
end
module SalaryDefaultScope
extend ActiveSupport::Concern
- included { default_scope where(:salary => 50000) }
+ included { default_scope { where(:salary => 50000) } }
end
class ModuleIncludedPoorDeveloperCalledJamis < DeveloperCalledJamis
@@ -195,7 +195,7 @@ class EagerDeveloperWithDefaultScope < ActiveRecord::Base
self.table_name = 'developers'
has_and_belongs_to_many :projects, :foreign_key => 'developer_id', :join_table => 'developers_projects', :order => 'projects.id'
- default_scope includes(:projects)
+ default_scope { includes(:projects) }
end
class EagerDeveloperWithClassMethodDefaultScope < ActiveRecord::Base
diff --git a/activerecord/test/models/organization.rb b/activerecord/test/models/organization.rb
index 4a4111833f..72e7bade68 100644
--- a/activerecord/test/models/organization.rb
+++ b/activerecord/test/models/organization.rb
@@ -8,5 +8,5 @@ class Organization < ActiveRecord::Base
has_one :author, :primary_key => :name
has_one :author_owned_essay_category, :through => :author, :source => :owned_essay_category
- scope :clubs, { :from => 'clubs' }
+ scope :clubs, -> { from('clubs') }
end
diff --git a/activerecord/test/models/person.rb b/activerecord/test/models/person.rb
index 84bc901b5e..b7d5dabc4f 100644
--- a/activerecord/test/models/person.rb
+++ b/activerecord/test/models/person.rb
@@ -27,8 +27,8 @@ class Person < ActiveRecord::Base
has_many :agents_posts, :through => :agents, :source => :posts
has_many :agents_posts_authors, :through => :agents_posts, :source => :author
- scope :males, :conditions => { :gender => 'M' }
- scope :females, :conditions => { :gender => 'F' }
+ scope :males, -> { where(:gender => 'M') }
+ scope :females, -> { where(:gender => 'F') }
end
class PersonWithDependentDestroyJobs < ActiveRecord::Base
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index 0fc22ac6a3..5002ab9ff8 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -5,8 +5,8 @@ class Post < ActiveRecord::Base
end
end
- scope :containing_the_letter_a, where("body LIKE '%a%'")
- scope :ranked_by_comments, order("comments_count DESC")
+ scope :containing_the_letter_a, -> { where("body LIKE '%a%'") }
+ scope :ranked_by_comments, -> { order("comments_count DESC") }
scope :limit_by, lambda {|l| limit(l) }
scope :with_authors_at_address, lambda { |address| {
@@ -30,8 +30,8 @@ class Post < ActiveRecord::Base
has_one :first_comment, :class_name => 'Comment', :order => 'id ASC'
has_one :last_comment, :class_name => 'Comment', :order => 'id desc'
- scope :with_special_comments, :joins => :comments, :conditions => {:comments => {:type => 'SpecialComment'} }
- scope :with_very_special_comments, joins(:comments).where(:comments => {:type => 'VerySpecialComment'})
+ scope :with_special_comments, -> { joins(:comments).where(:comments => {:type => 'SpecialComment'}) }
+ scope :with_very_special_comments, -> { joins(:comments).where(:comments => {:type => 'VerySpecialComment'}) }
scope :with_post, lambda {|post_id|
{ :joins => :comments, :conditions => {:comments => {:post_id => post_id} } }
}
@@ -171,7 +171,7 @@ end
class FirstPost < ActiveRecord::Base
self.table_name = 'posts'
- default_scope where(:id => 1)
+ default_scope { where(:id => 1) }
has_many :comments, :foreign_key => :post_id
has_one :comment, :foreign_key => :post_id
@@ -179,16 +179,16 @@ end
class PostWithDefaultInclude < ActiveRecord::Base
self.table_name = 'posts'
- default_scope includes(:comments)
+ default_scope { includes(:comments) }
has_many :comments, :foreign_key => :post_id
end
class PostWithDefaultScope < ActiveRecord::Base
self.table_name = 'posts'
- default_scope :order => :title
+ default_scope { order(:title) }
end
class SpecialPostWithDefaultScope < ActiveRecord::Base
self.table_name = 'posts'
- default_scope where(:id => [1, 5,6])
+ default_scope { where(:id => [1, 5,6]) }
end
diff --git a/activerecord/test/models/project.rb b/activerecord/test/models/project.rb
index efe1ce67da..32ce164995 100644
--- a/activerecord/test/models/project.rb
+++ b/activerecord/test/models/project.rb
@@ -32,7 +32,7 @@ class Project < ActiveRecord::Base
def self.all_as_method
all
end
- scope :all_as_scope, {}
+ scope :all_as_scope, -> { scoped }
end
class SpecialProject < Project
diff --git a/activerecord/test/models/reference.rb b/activerecord/test/models/reference.rb
index c5af0b5d5f..561b431766 100644
--- a/activerecord/test/models/reference.rb
+++ b/activerecord/test/models/reference.rb
@@ -19,5 +19,5 @@ end
class BadReference < ActiveRecord::Base
self.table_name = 'references'
- default_scope where(:favourite => false)
+ default_scope { where(:favourite => false) }
end
diff --git a/activerecord/test/models/reply.rb b/activerecord/test/models/reply.rb
index 6adfe0ae3c..53bc95e5f2 100644
--- a/activerecord/test/models/reply.rb
+++ b/activerecord/test/models/reply.rb
@@ -1,7 +1,7 @@
require 'models/topic'
class Reply < Topic
- scope :base
+ scope :base, -> { scoped }
belongs_to :topic, :foreign_key => "parent_id", :counter_cache => true
belongs_to :topic_with_primary_key, :class_name => "Topic", :primary_key => "title", :foreign_key => "parent_title", :counter_cache => "replies_count"
diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb
index 8bcb9df8a8..785839be75 100644
--- a/activerecord/test/models/topic.rb
+++ b/activerecord/test/models/topic.rb
@@ -1,21 +1,24 @@
class Topic < ActiveRecord::Base
- scope :base
+ scope :base, -> { scoped }
scope :written_before, lambda { |time|
if time
{ :conditions => ['written_on < ?', time] }
end
}
- scope :approved, :conditions => {:approved => true}
- scope :rejected, :conditions => {:approved => false}
+ scope :approved, -> { where(:approved => true) }
+ scope :rejected, -> { where(:approved => false) }
scope :scope_with_lambda, lambda { scoped }
- scope :by_lifo, :conditions => {:author_name => 'lifo'}
+ scope :by_lifo, -> { where(:author_name => 'lifo') }
- scope :approved_as_hash_condition, :conditions => {:topics => {:approved => true}}
- scope 'approved_as_string', :conditions => {:approved => true}
- scope :replied, :conditions => ['replies_count > 0']
- scope :anonymous_extension do
+ ActiveSupport::Deprecation.silence do
+ scope :approved_as_hash_condition, :conditions => {:topics => {:approved => true}}
+ scope :replied, :conditions => ['replies_count > 0']
+ end
+
+ scope 'approved_as_string', -> { where(:approved => true) }
+ scope :anonymous_extension, -> { scoped } do
def one
1
end
@@ -42,8 +45,8 @@ class Topic < ActiveRecord::Base
2
end
end
- scope :named_extension, :extend => NamedExtension
- scope :multiple_extensions, :extend => [MultipleExtensionTwo, MultipleExtensionOne]
+ scope :named_extension, -> { { :extend => NamedExtension } }
+ scope :multiple_extensions, -> { { :extend => [MultipleExtensionTwo, MultipleExtensionOne] } }
has_many :replies, :dependent => :destroy, :foreign_key => "parent_id"
has_many :replies_with_primary_key, :class_name => "Reply", :dependent => :destroy, :primary_key => "title", :foreign_key => "parent_title"
diff --git a/activerecord/test/models/toy.rb b/activerecord/test/models/toy.rb
index 0377e50011..ddc7048a56 100644
--- a/activerecord/test/models/toy.rb
+++ b/activerecord/test/models/toy.rb
@@ -2,5 +2,5 @@ class Toy < ActiveRecord::Base
self.primary_key = :toy_id
belongs_to :pet
- scope :with_pet, joins(:pet)
+ scope :with_pet, -> { joins(:pet) }
end
diff --git a/activerecord/test/models/without_table.rb b/activerecord/test/models/without_table.rb
index 184ab1649e..50c824e4ac 100644
--- a/activerecord/test/models/without_table.rb
+++ b/activerecord/test/models/without_table.rb
@@ -1,3 +1,3 @@
class WithoutTable < ActiveRecord::Base
- default_scope where(:published => true)
+ default_scope -> { where(:published => true) }
end
diff --git a/activesupport/lib/active_support/basic_object.rb b/activesupport/lib/active_support/basic_object.rb
index c3c7ab0112..6ccb0cd525 100644
--- a/activesupport/lib/active_support/basic_object.rb
+++ b/activesupport/lib/active_support/basic_object.rb
@@ -10,5 +10,4 @@ module ActiveSupport
::Object.send(:raise, *args)
end
end
-
end
diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb
index fbc6e538d5..45181f0e16 100644
--- a/activesupport/lib/active_support/core_ext/hash/slice.rb
+++ b/activesupport/lib/active_support/core_ext/hash/slice.rb
@@ -13,7 +13,7 @@ class Hash
# valid_keys = [:mass, :velocity, :time]
# search(options.slice(*valid_keys))
def slice(*keys)
- keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
+ keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
keys.each_with_object(self.class.new) { |k, hash| hash[k] = self[k] if has_key?(k) }
end
@@ -21,7 +21,7 @@ class Hash
# Returns a hash contained the removed key/value pairs
# {:a => 1, :b => 2, :c => 3, :d => 4}.slice!(:a, :b) # => {:c => 3, :d => 4}
def slice!(*keys)
- keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
+ keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
omit = slice(*self.keys - keys)
hash = slice(*keys)
replace(hash)
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb
index ac2a63d3a1..af92b869fd 100644
--- a/activesupport/lib/active_support/core_ext/module/delegation.rb
+++ b/activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -106,9 +106,11 @@ class Module
unless options.is_a?(Hash) && to = options[:to]
raise ArgumentError, "Delegation needs a target. Supply an options hash with a :to key as the last argument (e.g. delegate :hello, :to => :greeter)."
end
- prefix, to, allow_nil = options[:prefix], options[:to], options[:allow_nil]
- if prefix == true && to.to_s =~ /^[^a-z_]/
+ to = to.to_s
+ prefix, allow_nil = options.values_at(:prefix, :allow_nil)
+
+ if prefix == true && to =~ /^[^a-z_]/
raise ArgumentError, "Can only automatically set the delegation prefix when delegating to a method."
end
@@ -122,10 +124,8 @@ class Module
file, line = caller.first.split(':', 2)
line = line.to_i
- methods.each do |method|
- method = method.to_s
-
- if allow_nil
+ if allow_nil
+ methods.each do |method|
module_eval(<<-EOS, file, line - 2)
def #{method_prefix}#{method}(*args, &block) # def customer_name(*args, &block)
if #{to} || #{to}.respond_to?(:#{method}) # if client || client.respond_to?(:name)
@@ -133,7 +133,9 @@ class Module
end # end
end # end
EOS
- else
+ end
+ else
+ methods.each do |method|
exception = %(raise "#{self}##{method_prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
module_eval(<<-EOS, file, line - 1)
diff --git a/activesupport/lib/active_support/core_ext/object/duplicable.rb b/activesupport/lib/active_support/core_ext/object/duplicable.rb
index 9d044eba71..9d1630bb7c 100644
--- a/activesupport/lib/active_support/core_ext/object/duplicable.rb
+++ b/activesupport/lib/active_support/core_ext/object/duplicable.rb
@@ -104,3 +104,16 @@ class Module
false
end
end
+
+require 'bigdecimal'
+class BigDecimal
+ begin
+ BigDecimal.new('4.56').dup
+
+ def duplicable?
+ true
+ end
+ rescue TypeError
+ # can't dup, so use superclass implementation
+ end
+end
diff --git a/activesupport/lib/active_support/core_ext/proc.rb b/activesupport/lib/active_support/core_ext/proc.rb
index 94bb5fb0cb..cd63740940 100644
--- a/activesupport/lib/active_support/core_ext/proc.rb
+++ b/activesupport/lib/active_support/core_ext/proc.rb
@@ -1,7 +1,10 @@
require "active_support/core_ext/kernel/singleton_class"
+require "active_support/deprecation"
class Proc #:nodoc:
def bind(object)
+ ActiveSupport::Deprecation.warn 'Proc#bind is deprecated and will be removed in future versions', caller
+
block, time = self, Time.now
object.class_eval do
method_name = "__bind_#{time.to_i}_#{time.usec}"
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 2c5950edf5..745a131524 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -129,16 +129,14 @@ module ActiveSupport #:nodoc:
# Add a set of modules to the watch stack, remembering the initial constants
def watch_namespaces(namespaces)
- watching = []
- namespaces.map do |namespace|
+ @watching << namespaces.map do |namespace|
module_name = Dependencies.to_constant_name(namespace)
original_constants = Dependencies.qualified_const_defined?(module_name) ?
Inflector.constantize(module_name).local_constants : []
- watching << module_name
@stack[module_name] << original_constants
+ module_name
end
- @watching << watching
end
private
@@ -365,7 +363,7 @@ module ActiveSupport #:nodoc:
# Record history *after* loading so first load gets warnings.
history << expanded
- return result
+ result
end
# Is the provided constant path defined?
@@ -434,7 +432,7 @@ module ActiveSupport #:nodoc:
mod = Module.new
into.const_set const_name, mod
autoloaded_constants << qualified_name unless autoload_once_paths.include?(base_path)
- return mod
+ mod
end
# Load the file at the provided path. +const_paths+ is a set of qualified
@@ -458,7 +456,7 @@ module ActiveSupport #:nodoc:
autoloaded_constants.concat newly_defined_paths unless load_once_path?(path)
autoloaded_constants.uniq!
log "loading #{path} defined #{newly_defined_paths * ', '}" unless newly_defined_paths.empty?
- return result
+ result
end
# Return the constant path for the provided parent and constant name.
@@ -505,7 +503,7 @@ module ActiveSupport #:nodoc:
raise NameError,
"uninitialized constant #{qualified_name}",
- caller.reject {|l| l.starts_with? __FILE__ }
+ caller.reject { |l| l.starts_with? __FILE__ }
end
# Remove the constants that have been autoloaded, and those that have been
@@ -543,10 +541,7 @@ module ActiveSupport #:nodoc:
def safe_get(key)
key = key.name if key.respond_to?(:name)
- @store[key] || begin
- klass = Inflector.safe_constantize(key)
- @store[key] = klass
- end
+ @store[key] ||= Inflector.safe_constantize(key)
end
def store(klass)
@@ -600,10 +595,10 @@ module ActiveSupport #:nodoc:
def mark_for_unload(const_desc)
name = to_constant_name const_desc
if explicitly_unloadable_constants.include? name
- return false
+ false
else
explicitly_unloadable_constants << name
- return true
+ true
end
end
@@ -631,10 +626,10 @@ module ActiveSupport #:nodoc:
return new_constants unless aborting
log "Error during loading, removing partially loaded constants "
- new_constants.each {|c| remove_constant(c) }.clear
+ new_constants.each { |c| remove_constant(c) }.clear
end
- return []
+ []
end
# Convert the provided const desc to a qualified constant name (as a string).
@@ -663,7 +658,7 @@ module ActiveSupport #:nodoc:
constantized.before_remove_const if constantized.respond_to?(:before_remove_const)
parent.instance_eval { remove_const to_remove }
- return true
+ true
end
protected
diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb
index 2ede084e95..fe22b9515b 100644
--- a/activesupport/lib/active_support/file_update_checker.rb
+++ b/activesupport/lib/active_support/file_update_checker.rb
@@ -1,5 +1,3 @@
-require "active_support/core_ext/array/extract_options"
-
module ActiveSupport
# \FileUpdateChecker specifies the API used by Rails to watch files
# and control reloading. The API depends on four methods:
@@ -93,10 +91,10 @@ module ActiveSupport
def updated_at #:nodoc:
@updated_at || begin
- all = []
- all.concat @files.select { |f| File.exists?(f) }
+ all = @files.select { |f| File.exists?(f) }
all.concat Dir[@glob] if @glob
- all.map { |path| File.mtime(path) }.max || Time.at(0)
+ all.map! { |path| File.mtime(path) }
+ all.max || Time.at(0)
end
end
@@ -104,13 +102,16 @@ module ActiveSupport
hash.freeze # Freeze so changes aren't accidently pushed
return if hash.empty?
- globs = []
- hash.each do |key, value|
- globs << "#{key}/**/*#{compile_ext(value)}"
+ globs = hash.map do |key, value|
+ "#{escape(key)}/**/*#{compile_ext(value)}"
end
"{#{globs.join(",")}}"
end
+ def escape(key)
+ key.gsub(',','\,')
+ end
+
def compile_ext(array) #:nodoc:
array = Array(array)
return if array.empty?
diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb
index e4a13870d7..91459f3e5b 100644
--- a/activesupport/lib/active_support/hash_with_indifferent_access.rb
+++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -5,7 +5,7 @@ module ActiveSupport
# people can write <tt>params[:key]</tt> instead of <tt>params['key']</tt>
# and they get the same value for both keys.
class HashWithIndifferentAccess < Hash
-
+
# Always returns true, so that <tt>Array#extract_options!</tt> finds members of this class.
def extractable_options?
true
@@ -42,6 +42,10 @@ module ActiveSupport
end
end
+ def self.[](*args)
+ new.merge(Hash[*args])
+ end
+
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
alias_method :regular_update, :update unless method_defined?(:regular_update)
diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb
index 58938cdc3d..d2a6e1bd82 100644
--- a/activesupport/lib/active_support/log_subscriber.rb
+++ b/activesupport/lib/active_support/log_subscriber.rb
@@ -3,7 +3,7 @@ require 'active_support/core_ext/class/attribute'
module ActiveSupport
# ActiveSupport::LogSubscriber is an object set to consume ActiveSupport::Notifications
- # with the sole purpose of logging them. The log subscriber dispatches notifications to
+ # with the sole purpose of logging them. The log subscriber dispatches notifications to
# a registered object based on its given namespace.
#
# An example would be Active Record log subscriber responsible for logging queries:
@@ -75,7 +75,8 @@ module ActiveSupport
@@flushable_loggers ||= begin
loggers = log_subscribers.map(&:logger)
loggers.uniq!
- loggers.select { |l| l.respond_to?(:flush) }
+ loggers.select! { |l| l.respond_to?(:flush) }
+ loggers
end
end
@@ -101,8 +102,7 @@ module ActiveSupport
%w(info debug warn error fatal unknown).each do |level|
class_eval <<-METHOD, __FILE__, __LINE__ + 1
def #{level}(progname = nil, &block)
- return unless logger
- logger.#{level}(progname, &block)
+ logger.#{level}(progname, &block) if logger
end
METHOD
end
diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb
index 13f675c654..8cf7bdafda 100644
--- a/activesupport/lib/active_support/notifications.rb
+++ b/activesupport/lib/active_support/notifications.rb
@@ -1,3 +1,6 @@
+require 'active_support/notifications/instrumenter'
+require 'active_support/notifications/fanout'
+
module ActiveSupport
# = Notifications
#
@@ -105,10 +108,6 @@ module ActiveSupport
# to log subscribers in a thread. You can use any queue implementation you want.
#
module Notifications
- autoload :Instrumenter, 'active_support/notifications/instrumenter'
- autoload :Event, 'active_support/notifications/instrumenter'
- autoload :Fanout, 'active_support/notifications/fanout'
-
@instrumenters = Hash.new { |h,k| h[k] = notifier.listening?(k) }
class << self
diff --git a/activesupport/lib/active_support/notifications/fanout.rb b/activesupport/lib/active_support/notifications/fanout.rb
index a9aa5464e9..17c99089c1 100644
--- a/activesupport/lib/active_support/notifications/fanout.rb
+++ b/activesupport/lib/active_support/notifications/fanout.rb
@@ -9,18 +9,25 @@ module ActiveSupport
end
def subscribe(pattern = nil, block = Proc.new)
- subscriber = Subscriber.new(pattern, block).tap do |s|
- @subscribers << s
- end
+ subscriber = Subscribers.new pattern, block
+ @subscribers << subscriber
@listeners_for.clear
subscriber
end
def unsubscribe(subscriber)
- @subscribers.reject! {|s| s.matches?(subscriber)}
+ @subscribers.reject! { |s| s.matches?(subscriber) }
@listeners_for.clear
end
+ def start(name, id, payload)
+ listeners_for(name).each { |s| s.start(name, id, payload) }
+ end
+
+ def finish(name, id, payload)
+ listeners_for(name).each { |s| s.finish(name, id, payload) }
+ end
+
def publish(name, *args)
listeners_for(name).each { |s| s.publish(name, *args) }
end
@@ -37,23 +44,89 @@ module ActiveSupport
def wait
end
- class Subscriber #:nodoc:
- def initialize(pattern, delegate)
- @pattern = pattern
- @delegate = delegate
+ module Subscribers # :nodoc:
+ def self.new(pattern, listener)
+ if listener.respond_to?(:call)
+ subscriber = Timed.new pattern, listener
+ else
+ subscriber = Evented.new pattern, listener
+ end
+
+ unless pattern
+ AllMessages.new(subscriber)
+ else
+ subscriber
+ end
end
- def publish(message, *args)
- @delegate.call(message, *args)
+ class Evented #:nodoc:
+ def initialize(pattern, delegate)
+ @pattern = pattern
+ @delegate = delegate
+ end
+
+ def start(name, id, payload)
+ @delegate.start name, id, payload
+ end
+
+ def finish(name, id, payload)
+ @delegate.finish name, id, payload
+ end
+
+ def subscribed_to?(name)
+ @pattern === name.to_s
+ end
+
+ def matches?(subscriber_or_name)
+ self === subscriber_or_name ||
+ @pattern && @pattern === subscriber_or_name
+ end
end
- def subscribed_to?(name)
- !@pattern || @pattern === name.to_s
+ class Timed < Evented
+ def initialize(pattern, delegate)
+ @timestack = Hash.new { |h,id|
+ h[id] = Hash.new { |ids,name| ids[name] = [] }
+ }
+ super
+ end
+
+ def publish(name, *args)
+ @delegate.call name, *args
+ end
+
+ def start(name, id, payload)
+ @timestack[id][name].push Time.now
+ end
+
+ def finish(name, id, payload)
+ started = @timestack[id][name].pop
+ @delegate.call(name, started, Time.now, id, payload)
+ end
end
- def matches?(subscriber_or_name)
- self === subscriber_or_name ||
- @pattern && @pattern === subscriber_or_name
+ class AllMessages # :nodoc:
+ def initialize(delegate)
+ @delegate = delegate
+ end
+
+ def start(name, id, payload)
+ @delegate.start name, id, payload
+ end
+
+ def finish(name, id, payload)
+ @delegate.finish name, id, payload
+ end
+
+ def publish(name, *args)
+ @delegate.publish name, *args
+ end
+
+ def subscribed_to?(name)
+ true
+ end
+
+ alias :matches? :===
end
end
end
diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb
index 3941c285a2..58e292c658 100644
--- a/activesupport/lib/active_support/notifications/instrumenter.rb
+++ b/activesupport/lib/active_support/notifications/instrumenter.rb
@@ -1,7 +1,6 @@
-require 'active_support/core_ext/module/delegation'
-
module ActiveSupport
module Notifications
+ # Instrumentors are stored in a thread local.
class Instrumenter
attr_reader :id
@@ -14,15 +13,14 @@ module ActiveSupport
# and publish it. Notice that events get sent even if an error occurs
# in the passed-in block
def instrument(name, payload={})
- started = Time.now
-
+ @notifier.start(name, @id, payload)
begin
yield
rescue Exception => e
payload[:exception] = [e.class.name, e.message]
raise e
ensure
- @notifier.publish(name, started, Time.now, @id, payload)
+ @notifier.finish(name, @id, payload)
end
end
diff --git a/activesupport/lib/active_support/railtie.rb b/activesupport/lib/active_support/railtie.rb
index f696716cc8..d1c62c5087 100644
--- a/activesupport/lib/active_support/railtie.rb
+++ b/activesupport/lib/active_support/railtie.rb
@@ -8,30 +8,6 @@ module ActiveSupport
initializer "active_support.deprecation_behavior" do |app|
if deprecation = app.config.active_support.deprecation
ActiveSupport::Deprecation.behavior = deprecation
- else
- defaults = {"development" => :log,
- "production" => :notify,
- "test" => :stderr}
-
- env = Rails.env
-
- if defaults.key?(env)
- msg = "You did not specify how you would like Rails to report " \
- "deprecation notices for your #{env} environment, please " \
- "set config.active_support.deprecation to :#{defaults[env]} " \
- "at config/environments/#{env}.rb"
-
- warn msg
- ActiveSupport::Deprecation.behavior = defaults[env]
- else
- msg = "You did not specify how you would like Rails to report " \
- "deprecation notices for your #{env} environment, please " \
- "set config.active_support.deprecation to :log, :notify or " \
- ":stderr at config/environments/#{env}.rb"
-
- warn msg
- ActiveSupport::Deprecation.behavior = :stderr
- end
end
end
@@ -42,8 +18,7 @@ module ActiveSupport
zone_default = Time.find_zone!(app.config.time_zone)
unless zone_default
- raise \
- 'Value assigned to config.time_zone not recognized.' +
+ raise 'Value assigned to config.time_zone not recognized. ' \
'Run "rake -D time" for a list of tasks for finding appropriate time zone names.'
end
diff --git a/activesupport/lib/active_support/rescuable.rb b/activesupport/lib/active_support/rescuable.rb
index 0f4a06468a..85e84bc203 100644
--- a/activesupport/lib/active_support/rescuable.rb
+++ b/activesupport/lib/active_support/rescuable.rb
@@ -108,7 +108,11 @@ module ActiveSupport
when Symbol
method(rescuer)
when Proc
- rescuer.bind(self)
+ if rescuer.arity == 0
+ Proc.new { instance_exec(&rescuer) }
+ else
+ Proc.new { |_exception| instance_exec(_exception, &rescuer) }
+ end
end
end
end
diff --git a/activesupport/lib/active_support/tagged_logging.rb b/activesupport/lib/active_support/tagged_logging.rb
index 88fd438448..538a36f6d9 100644
--- a/activesupport/lib/active_support/tagged_logging.rb
+++ b/activesupport/lib/active_support/tagged_logging.rb
@@ -45,7 +45,7 @@ module ActiveSupport
tags = formatter.current_tags
new_tags = new_tags.flatten.reject(&:blank?)
tags.concat new_tags
- yield
+ yield self
ensure
tags.pop(new_tags.size)
end
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index bfbb838ea7..ce46c46092 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -168,8 +168,7 @@ module ActiveSupport
"Auckland" => "Pacific/Auckland",
"Wellington" => "Pacific/Auckland",
"Nuku'alofa" => "Pacific/Tongatapu"
- }.each { |name, zone| name.freeze; zone.freeze }
- MAPPING.freeze
+ }
UTC_OFFSET_WITH_COLON = '%s%02d:%02d'
UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.sub(':', '')
@@ -267,7 +266,7 @@ module ActiveSupport
# Time.zone.parse('22:30:00') # => Fri, 31 Dec 1999 22:30:00 HST -10:00
def parse(str, now=now)
date_parts = Date._parse(str)
- return if date_parts.blank?
+ return if date_parts.empty?
time = Time.parse(str, now) rescue DateTime.parse(str)
if date_parts[:offset].nil?
ActiveSupport::TimeWithZone.new(nil, self, time)
@@ -282,7 +281,7 @@ module ActiveSupport
# Time.zone = 'Hawaii' # => "Hawaii"
# Time.zone.now # => Wed, 23 Jan 2008 20:24:27 HST -10:00
def now
- Time.now.utc.in_time_zone(self)
+ time_now.utc.in_time_zone(self)
end
# Return the current date in this time zone.
@@ -391,5 +390,11 @@ module ActiveSupport
end
end
end
+
+ private
+
+ def time_now
+ Time.now
+ end
end
end
diff --git a/activesupport/test/core_ext/duplicable_test.rb b/activesupport/test/core_ext/duplicable_test.rb
index 3e54266051..1105353e45 100644
--- a/activesupport/test/core_ext/duplicable_test.rb
+++ b/activesupport/test/core_ext/duplicable_test.rb
@@ -4,17 +4,25 @@ require 'active_support/core_ext/object/duplicable'
require 'active_support/core_ext/numeric/time'
class DuplicableTest < ActiveSupport::TestCase
- RAISE_DUP = [nil, false, true, :symbol, 1, 2.3, BigDecimal.new('4.56'), 5.seconds]
+ RAISE_DUP = [nil, false, true, :symbol, 1, 2.3, 5.seconds]
YES = ['1', Object.new, /foo/, [], {}, Time.now]
NO = [Class.new, Module.new]
+ begin
+ bd = BigDecimal.new('4.56')
+ YES << bd.dup
+ rescue TypeError
+ RAISE_DUP << bd
+ end
+
+
def test_duplicable
(RAISE_DUP + NO).each do |v|
assert !v.duplicable?
end
YES.each do |v|
- assert v.duplicable?
+ assert v.duplicable?, "#{v.class} should be duplicable"
end
(YES + NO).each do |v|
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index 4544edf0dd..80b3c16328 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -388,6 +388,15 @@ class HashExtTest < ActiveSupport::TestCase
assert_equal expected, hash
end
+ def test_constructor_on_indifferent_access
+ hash = HashWithIndifferentAccess[:foo, 1]
+ assert_equal 1, hash[:foo]
+ assert_equal 1, hash['foo']
+ hash[:foo] = 3
+ assert_equal 3, hash[:foo]
+ assert_equal 3, hash['foo']
+ end
+
def test_reverse_merge
defaults = { :a => "x", :b => "y", :c => 10 }.freeze
options = { :a => 1, :b => 2 }
diff --git a/activesupport/test/core_ext/proc_test.rb b/activesupport/test/core_ext/proc_test.rb
index 690bfd3bf8..c4d5592196 100644
--- a/activesupport/test/core_ext/proc_test.rb
+++ b/activesupport/test/core_ext/proc_test.rb
@@ -3,10 +3,12 @@ require 'active_support/core_ext/proc'
class ProcTests < ActiveSupport::TestCase
def test_bind_returns_method_with_changed_self
- block = Proc.new { self }
- assert_equal self, block.call
- bound_block = block.bind("hello")
- assert_not_equal block, bound_block
- assert_equal "hello", bound_block.call
+ assert_deprecated do
+ block = Proc.new { self }
+ assert_equal self, block.call
+ bound_block = block.bind("hello")
+ assert_not_equal block, bound_block
+ assert_equal "hello", bound_block.call
+ end
end
end
diff --git a/activesupport/test/file_update_checker_test.rb b/activesupport/test/file_update_checker_test.rb
index dd2483287b..066db7c0f9 100644
--- a/activesupport/test/file_update_checker_test.rb
+++ b/activesupport/test/file_update_checker_test.rb
@@ -1,5 +1,6 @@
require 'abstract_unit'
require 'fileutils'
+require 'thread'
MTIME_FIXTURES_PATH = File.expand_path("../fixtures", __FILE__)
@@ -79,4 +80,18 @@ class FileUpdateCheckerWithEnumerableTest < ActiveSupport::TestCase
assert !checker.execute_if_updated
assert_equal 0, i
end
+
+ def test_should_not_block_if_a_strange_filename_used
+ FileUtils.mkdir_p("tmp_watcher/valid,yetstrange,path,")
+ FileUtils.touch(FILES.map { |file_name| "tmp_watcher/valid,yetstrange,path,/#{file_name}" })
+
+ test = Thread.new do
+ ActiveSupport::FileUpdateChecker.new([],"tmp_watcher/valid,yetstrange,path," => :txt) { i += 1 }
+ Thread.exit
+ end
+ test.priority = -1
+ test.join(5)
+
+ assert !test.alive?
+ end
end
diff --git a/activesupport/test/notifications/evented_notification_test.rb b/activesupport/test/notifications/evented_notification_test.rb
new file mode 100644
index 0000000000..f77a0eb3fa
--- /dev/null
+++ b/activesupport/test/notifications/evented_notification_test.rb
@@ -0,0 +1,67 @@
+require 'abstract_unit'
+
+module ActiveSupport
+ module Notifications
+ class EventedTest < ActiveSupport::TestCase
+ class Listener
+ attr_reader :events
+
+ def initialize
+ @events = []
+ end
+
+ def start(name, id, payload)
+ @events << [:start, name, id, payload]
+ end
+
+ def finish(name, id, payload)
+ @events << [:finish, name, id, payload]
+ end
+ end
+
+ def test_evented_listener
+ notifier = Fanout.new
+ listener = Listener.new
+ notifier.subscribe 'hi', listener
+ notifier.start 'hi', 1, {}
+ notifier.start 'hi', 2, {}
+ notifier.finish 'hi', 2, {}
+ notifier.finish 'hi', 1, {}
+
+ assert_equal 4, listener.events.length
+ assert_equal [
+ [:start, 'hi', 1, {}],
+ [:start, 'hi', 2, {}],
+ [:finish, 'hi', 2, {}],
+ [:finish, 'hi', 1, {}],
+ ], listener.events
+ end
+
+ def test_evented_listener_no_events
+ notifier = Fanout.new
+ listener = Listener.new
+ notifier.subscribe 'hi', listener
+ notifier.start 'world', 1, {}
+ assert_equal 0, listener.events.length
+ end
+
+ def test_listen_to_everything
+ notifier = Fanout.new
+ listener = Listener.new
+ notifier.subscribe nil, listener
+ notifier.start 'hello', 1, {}
+ notifier.start 'world', 1, {}
+ notifier.finish 'world', 1, {}
+ notifier.finish 'hello', 1, {}
+
+ assert_equal 4, listener.events.length
+ assert_equal [
+ [:start, 'hello', 1, {}],
+ [:start, 'world', 1, {}],
+ [:finish, 'world', 1, {}],
+ [:finish, 'hello', 1, {}],
+ ], listener.events
+ end
+ end
+ end
+end
diff --git a/activesupport/test/ordered_options_test.rb b/activesupport/test/ordered_options_test.rb
index 0eee991e20..3526c7a366 100644
--- a/activesupport/test/ordered_options_test.rb
+++ b/activesupport/test/ordered_options_test.rb
@@ -1,4 +1,5 @@
require 'abstract_unit'
+require 'active_support/ordered_options'
class OrderedOptionsTest < ActiveSupport::TestCase
def test_usage
diff --git a/activesupport/test/tagged_logging_test.rb b/activesupport/test/tagged_logging_test.rb
index dd4ae319e5..0751c2469e 100644
--- a/activesupport/test/tagged_logging_test.rb
+++ b/activesupport/test/tagged_logging_test.rb
@@ -18,7 +18,7 @@ class TaggedLoggingTest < ActiveSupport::TestCase
@logger.tagged("BCX") { @logger.info "Funky time" }
assert_equal "[BCX] Funky time\n", @output.string
end
-
+
test "tagged twice" do
@logger.tagged("BCX") { @logger.tagged("Jason") { @logger.info "Funky time" } }
assert_equal "[BCX] [Jason] Funky time\n", @output.string
@@ -29,6 +29,11 @@ class TaggedLoggingTest < ActiveSupport::TestCase
assert_equal "[BCX] [Jason] [New] Funky time\n", @output.string
end
+ test "provides access to the logger instance" do
+ @logger.tagged("BCX") { |logger| logger.info "Funky time" }
+ assert_equal "[BCX] Funky time\n", @output.string
+ end
+
test "tagged once with blank and nil" do
@logger.tagged(nil, "", "New") { @logger.info "Funky time" }
assert_equal "[New] Funky time\n", @output.string
diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb
index e26256f9c6..d14d01dc30 100644
--- a/activesupport/test/time_zone_test.rb
+++ b/activesupport/test/time_zone_test.rb
@@ -48,8 +48,8 @@ class TimeZoneTest < ActiveSupport::TestCase
def test_now
with_env_tz 'US/Eastern' do
- Time.stubs(:now).returns(Time.local(2000))
- zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']
+ zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)'].dup
+ def zone.time_now; Time.local(2000); end
assert_instance_of ActiveSupport::TimeWithZone, zone.now
assert_equal Time.utc(2000,1,1,5), zone.now.utc
assert_equal Time.utc(2000), zone.now.time
@@ -59,8 +59,11 @@ class TimeZoneTest < ActiveSupport::TestCase
def test_now_enforces_spring_dst_rules
with_env_tz 'US/Eastern' do
- Time.stubs(:now).returns(Time.local(2006,4,2,2)) # 2AM springs forward to 3AM
- zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']
+ zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)'].dup
+ def zone.time_now
+ Time.local(2006,4,2,2) # 2AM springs forward to 3AM
+ end
+
assert_equal Time.utc(2006,4,2,3), zone.now.time
assert_equal true, zone.now.dst?
end
@@ -68,8 +71,10 @@ class TimeZoneTest < ActiveSupport::TestCase
def test_now_enforces_fall_dst_rules
with_env_tz 'US/Eastern' do
- Time.stubs(:now).returns(Time.at(1162098000)) # equivalent to 1AM DST
- zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']
+ zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)'].dup
+ def zone.time_now
+ Time.at(1162098000) # equivalent to 1AM DST
+ end
assert_equal Time.utc(2006,10,29,1), zone.now.time
assert_equal true, zone.now.dst?
end
diff --git a/guides/Rakefile b/guides/Rakefile
new file mode 100644
index 0000000000..ad4ff91fe6
--- /dev/null
+++ b/guides/Rakefile
@@ -0,0 +1,11 @@
+desc 'Generate guides (for authors), use ONLY=foo to process just "foo.textile"'
+task :generate_guides do
+ ENV["WARN_BROKEN_LINKS"] = "1" # authors can't disable this
+ ruby "rails_guides.rb"
+end
+
+# Validate guides -------------------------------------------------------------------------
+desc 'Validate guides, use ONLY=foo to process just "foo.html"'
+task :validate_guides do
+ ruby "w3c_validator.rb"
+end
diff --git a/railties/guides/assets/images/belongs_to.png b/guides/assets/images/belongs_to.png
index 44243edbca..44243edbca 100644
--- a/railties/guides/assets/images/belongs_to.png
+++ b/guides/assets/images/belongs_to.png
Binary files differ
diff --git a/railties/guides/assets/images/book_icon.gif b/guides/assets/images/book_icon.gif
index c81d5db520..c81d5db520 100644
--- a/railties/guides/assets/images/book_icon.gif
+++ b/guides/assets/images/book_icon.gif
Binary files differ
diff --git a/railties/guides/assets/images/bullet.gif b/guides/assets/images/bullet.gif
index 95a26364a4..95a26364a4 100644
--- a/railties/guides/assets/images/bullet.gif
+++ b/guides/assets/images/bullet.gif
Binary files differ
diff --git a/railties/guides/assets/images/challenge.png b/guides/assets/images/challenge.png
index d163748640..d163748640 100644
--- a/railties/guides/assets/images/challenge.png
+++ b/guides/assets/images/challenge.png
Binary files differ
diff --git a/railties/guides/assets/images/chapters_icon.gif b/guides/assets/images/chapters_icon.gif
index 06fb415f4a..06fb415f4a 100644
--- a/railties/guides/assets/images/chapters_icon.gif
+++ b/guides/assets/images/chapters_icon.gif
Binary files differ
diff --git a/railties/guides/assets/images/check_bullet.gif b/guides/assets/images/check_bullet.gif
index 1fcfeba250..1fcfeba250 100644
--- a/railties/guides/assets/images/check_bullet.gif
+++ b/guides/assets/images/check_bullet.gif
Binary files differ
diff --git a/railties/guides/assets/images/credits_pic_blank.gif b/guides/assets/images/credits_pic_blank.gif
index f6f654fc65..f6f654fc65 100644
--- a/railties/guides/assets/images/credits_pic_blank.gif
+++ b/guides/assets/images/credits_pic_blank.gif
Binary files differ
diff --git a/railties/guides/assets/images/csrf.png b/guides/assets/images/csrf.png
index ab73baafe8..ab73baafe8 100644
--- a/railties/guides/assets/images/csrf.png
+++ b/guides/assets/images/csrf.png
Binary files differ
diff --git a/railties/guides/assets/images/customized_error_messages.png b/guides/assets/images/customized_error_messages.png
index fa676991e3..fa676991e3 100644
--- a/railties/guides/assets/images/customized_error_messages.png
+++ b/guides/assets/images/customized_error_messages.png
Binary files differ
diff --git a/railties/guides/assets/images/edge_badge.png b/guides/assets/images/edge_badge.png
index cddd46c4b8..cddd46c4b8 100644
--- a/railties/guides/assets/images/edge_badge.png
+++ b/guides/assets/images/edge_badge.png
Binary files differ
diff --git a/railties/guides/assets/images/error_messages.png b/guides/assets/images/error_messages.png
index 428892194a..428892194a 100644
--- a/railties/guides/assets/images/error_messages.png
+++ b/guides/assets/images/error_messages.png
Binary files differ
diff --git a/railties/guides/assets/images/feature_tile.gif b/guides/assets/images/feature_tile.gif
index 75469361db..75469361db 100644
--- a/railties/guides/assets/images/feature_tile.gif
+++ b/guides/assets/images/feature_tile.gif
Binary files differ
diff --git a/railties/guides/assets/images/footer_tile.gif b/guides/assets/images/footer_tile.gif
index bb33fc1ff0..bb33fc1ff0 100644
--- a/railties/guides/assets/images/footer_tile.gif
+++ b/guides/assets/images/footer_tile.gif
Binary files differ
diff --git a/railties/guides/assets/images/fxn.png b/guides/assets/images/fxn.png
index 9b531ee584..9b531ee584 100644
--- a/railties/guides/assets/images/fxn.png
+++ b/guides/assets/images/fxn.png
Binary files differ
diff --git a/guides/assets/images/getting_started/new_post.png b/guides/assets/images/getting_started/new_post.png
new file mode 100644
index 0000000000..dc9459032a
--- /dev/null
+++ b/guides/assets/images/getting_started/new_post.png
Binary files differ
diff --git a/guides/assets/images/getting_started/routing_error_no_controller.png b/guides/assets/images/getting_started/routing_error_no_controller.png
new file mode 100644
index 0000000000..92a39efd78
--- /dev/null
+++ b/guides/assets/images/getting_started/routing_error_no_controller.png
Binary files differ
diff --git a/guides/assets/images/getting_started/routing_error_no_route_matches.png b/guides/assets/images/getting_started/routing_error_no_route_matches.png
new file mode 100644
index 0000000000..bc768a94a2
--- /dev/null
+++ b/guides/assets/images/getting_started/routing_error_no_route_matches.png
Binary files differ
diff --git a/guides/assets/images/getting_started/template_is_missing_posts_new.png b/guides/assets/images/getting_started/template_is_missing_posts_new.png
new file mode 100644
index 0000000000..9f070d59db
--- /dev/null
+++ b/guides/assets/images/getting_started/template_is_missing_posts_new.png
Binary files differ
diff --git a/guides/assets/images/getting_started/unknown_action_create_for_posts.png b/guides/assets/images/getting_started/unknown_action_create_for_posts.png
new file mode 100644
index 0000000000..03d92dfb7d
--- /dev/null
+++ b/guides/assets/images/getting_started/unknown_action_create_for_posts.png
Binary files differ
diff --git a/guides/assets/images/getting_started/unknown_action_new_for_posts.png b/guides/assets/images/getting_started/unknown_action_new_for_posts.png
new file mode 100644
index 0000000000..b63883d922
--- /dev/null
+++ b/guides/assets/images/getting_started/unknown_action_new_for_posts.png
Binary files differ
diff --git a/railties/guides/assets/images/grey_bullet.gif b/guides/assets/images/grey_bullet.gif
index e75e8e93a1..e75e8e93a1 100644
--- a/railties/guides/assets/images/grey_bullet.gif
+++ b/guides/assets/images/grey_bullet.gif
Binary files differ
diff --git a/railties/guides/assets/images/habtm.png b/guides/assets/images/habtm.png
index fea78b0b5c..fea78b0b5c 100644
--- a/railties/guides/assets/images/habtm.png
+++ b/guides/assets/images/habtm.png
Binary files differ
diff --git a/railties/guides/assets/images/has_many.png b/guides/assets/images/has_many.png
index 6cff58460d..6cff58460d 100644
--- a/railties/guides/assets/images/has_many.png
+++ b/guides/assets/images/has_many.png
Binary files differ
diff --git a/railties/guides/assets/images/has_many_through.png b/guides/assets/images/has_many_through.png
index 85d7599925..85d7599925 100644
--- a/railties/guides/assets/images/has_many_through.png
+++ b/guides/assets/images/has_many_through.png
Binary files differ
diff --git a/railties/guides/assets/images/has_one.png b/guides/assets/images/has_one.png
index a70ddaaa86..a70ddaaa86 100644
--- a/railties/guides/assets/images/has_one.png
+++ b/guides/assets/images/has_one.png
Binary files differ
diff --git a/railties/guides/assets/images/has_one_through.png b/guides/assets/images/has_one_through.png
index 89a7617a30..89a7617a30 100644
--- a/railties/guides/assets/images/has_one_through.png
+++ b/guides/assets/images/has_one_through.png
Binary files differ
diff --git a/railties/guides/assets/images/header_backdrop.png b/guides/assets/images/header_backdrop.png
index ff2982175e..ff2982175e 100644
--- a/railties/guides/assets/images/header_backdrop.png
+++ b/guides/assets/images/header_backdrop.png
Binary files differ
diff --git a/railties/guides/assets/images/header_tile.gif b/guides/assets/images/header_tile.gif
index e2c878d492..e2c878d492 100644
--- a/railties/guides/assets/images/header_tile.gif
+++ b/guides/assets/images/header_tile.gif
Binary files differ
diff --git a/railties/guides/assets/images/i18n/demo_html_safe.png b/guides/assets/images/i18n/demo_html_safe.png
index f881f60dac..f881f60dac 100644
--- a/railties/guides/assets/images/i18n/demo_html_safe.png
+++ b/guides/assets/images/i18n/demo_html_safe.png
Binary files differ
diff --git a/railties/guides/assets/images/i18n/demo_localized_pirate.png b/guides/assets/images/i18n/demo_localized_pirate.png
index 9134709573..9134709573 100644
--- a/railties/guides/assets/images/i18n/demo_localized_pirate.png
+++ b/guides/assets/images/i18n/demo_localized_pirate.png
Binary files differ
diff --git a/railties/guides/assets/images/i18n/demo_translated_en.png b/guides/assets/images/i18n/demo_translated_en.png
index ecdd878d38..ecdd878d38 100644
--- a/railties/guides/assets/images/i18n/demo_translated_en.png
+++ b/guides/assets/images/i18n/demo_translated_en.png
Binary files differ
diff --git a/railties/guides/assets/images/i18n/demo_translated_pirate.png b/guides/assets/images/i18n/demo_translated_pirate.png
index 41c580923a..41c580923a 100644
--- a/railties/guides/assets/images/i18n/demo_translated_pirate.png
+++ b/guides/assets/images/i18n/demo_translated_pirate.png
Binary files differ
diff --git a/railties/guides/assets/images/i18n/demo_translation_missing.png b/guides/assets/images/i18n/demo_translation_missing.png
index af9e2d0427..af9e2d0427 100644
--- a/railties/guides/assets/images/i18n/demo_translation_missing.png
+++ b/guides/assets/images/i18n/demo_translation_missing.png
Binary files differ
diff --git a/railties/guides/assets/images/i18n/demo_untranslated.png b/guides/assets/images/i18n/demo_untranslated.png
index 3603f43463..3603f43463 100644
--- a/railties/guides/assets/images/i18n/demo_untranslated.png
+++ b/guides/assets/images/i18n/demo_untranslated.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/README b/guides/assets/images/icons/README
index f12b2a730c..f12b2a730c 100644
--- a/railties/guides/assets/images/icons/README
+++ b/guides/assets/images/icons/README
diff --git a/railties/guides/assets/images/icons/callouts/1.png b/guides/assets/images/icons/callouts/1.png
index 7d473430b7..7d473430b7 100644
--- a/railties/guides/assets/images/icons/callouts/1.png
+++ b/guides/assets/images/icons/callouts/1.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/10.png b/guides/assets/images/icons/callouts/10.png
index 997bbc8246..997bbc8246 100644
--- a/railties/guides/assets/images/icons/callouts/10.png
+++ b/guides/assets/images/icons/callouts/10.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/11.png b/guides/assets/images/icons/callouts/11.png
index ce47dac3f5..ce47dac3f5 100644
--- a/railties/guides/assets/images/icons/callouts/11.png
+++ b/guides/assets/images/icons/callouts/11.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/12.png b/guides/assets/images/icons/callouts/12.png
index 31daf4e2f2..31daf4e2f2 100644
--- a/railties/guides/assets/images/icons/callouts/12.png
+++ b/guides/assets/images/icons/callouts/12.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/13.png b/guides/assets/images/icons/callouts/13.png
index 14021a89c2..14021a89c2 100644
--- a/railties/guides/assets/images/icons/callouts/13.png
+++ b/guides/assets/images/icons/callouts/13.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/14.png b/guides/assets/images/icons/callouts/14.png
index 64014b75fe..64014b75fe 100644
--- a/railties/guides/assets/images/icons/callouts/14.png
+++ b/guides/assets/images/icons/callouts/14.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/15.png b/guides/assets/images/icons/callouts/15.png
index 0d65765fcf..0d65765fcf 100644
--- a/railties/guides/assets/images/icons/callouts/15.png
+++ b/guides/assets/images/icons/callouts/15.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/2.png b/guides/assets/images/icons/callouts/2.png
index 5d09341b2f..5d09341b2f 100644
--- a/railties/guides/assets/images/icons/callouts/2.png
+++ b/guides/assets/images/icons/callouts/2.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/3.png b/guides/assets/images/icons/callouts/3.png
index ef7b700471..ef7b700471 100644
--- a/railties/guides/assets/images/icons/callouts/3.png
+++ b/guides/assets/images/icons/callouts/3.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/4.png b/guides/assets/images/icons/callouts/4.png
index adb8364eb5..adb8364eb5 100644
--- a/railties/guides/assets/images/icons/callouts/4.png
+++ b/guides/assets/images/icons/callouts/4.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/5.png b/guides/assets/images/icons/callouts/5.png
index 4d7eb46002..4d7eb46002 100644
--- a/railties/guides/assets/images/icons/callouts/5.png
+++ b/guides/assets/images/icons/callouts/5.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/6.png b/guides/assets/images/icons/callouts/6.png
index 0ba694af6c..0ba694af6c 100644
--- a/railties/guides/assets/images/icons/callouts/6.png
+++ b/guides/assets/images/icons/callouts/6.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/7.png b/guides/assets/images/icons/callouts/7.png
index 472e96f8ac..472e96f8ac 100644
--- a/railties/guides/assets/images/icons/callouts/7.png
+++ b/guides/assets/images/icons/callouts/7.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/8.png b/guides/assets/images/icons/callouts/8.png
index 5e60973c21..5e60973c21 100644
--- a/railties/guides/assets/images/icons/callouts/8.png
+++ b/guides/assets/images/icons/callouts/8.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/callouts/9.png b/guides/assets/images/icons/callouts/9.png
index a0676d26cc..a0676d26cc 100644
--- a/railties/guides/assets/images/icons/callouts/9.png
+++ b/guides/assets/images/icons/callouts/9.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/caution.png b/guides/assets/images/icons/caution.png
index cb9d5ea0df..cb9d5ea0df 100644
--- a/railties/guides/assets/images/icons/caution.png
+++ b/guides/assets/images/icons/caution.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/example.png b/guides/assets/images/icons/example.png
index bba1c0010d..bba1c0010d 100644
--- a/railties/guides/assets/images/icons/example.png
+++ b/guides/assets/images/icons/example.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/home.png b/guides/assets/images/icons/home.png
index 37a5231bac..37a5231bac 100644
--- a/railties/guides/assets/images/icons/home.png
+++ b/guides/assets/images/icons/home.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/important.png b/guides/assets/images/icons/important.png
index 1096c23295..1096c23295 100644
--- a/railties/guides/assets/images/icons/important.png
+++ b/guides/assets/images/icons/important.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/next.png b/guides/assets/images/icons/next.png
index 64e126bdda..64e126bdda 100644
--- a/railties/guides/assets/images/icons/next.png
+++ b/guides/assets/images/icons/next.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/note.png b/guides/assets/images/icons/note.png
index 841820f7c4..841820f7c4 100644
--- a/railties/guides/assets/images/icons/note.png
+++ b/guides/assets/images/icons/note.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/prev.png b/guides/assets/images/icons/prev.png
index 3e8f12fe24..3e8f12fe24 100644
--- a/railties/guides/assets/images/icons/prev.png
+++ b/guides/assets/images/icons/prev.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/tip.png b/guides/assets/images/icons/tip.png
index a3a029d898..a3a029d898 100644
--- a/railties/guides/assets/images/icons/tip.png
+++ b/guides/assets/images/icons/tip.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/up.png b/guides/assets/images/icons/up.png
index 2db1ce62fa..2db1ce62fa 100644
--- a/railties/guides/assets/images/icons/up.png
+++ b/guides/assets/images/icons/up.png
Binary files differ
diff --git a/railties/guides/assets/images/icons/warning.png b/guides/assets/images/icons/warning.png
index 0b0c419df2..0b0c419df2 100644
--- a/railties/guides/assets/images/icons/warning.png
+++ b/guides/assets/images/icons/warning.png
Binary files differ
diff --git a/railties/guides/assets/images/jaimeiniesta.jpg b/guides/assets/images/jaimeiniesta.jpg
index 445f048d92..445f048d92 100644
--- a/railties/guides/assets/images/jaimeiniesta.jpg
+++ b/guides/assets/images/jaimeiniesta.jpg
Binary files differ
diff --git a/railties/guides/assets/images/nav_arrow.gif b/guides/assets/images/nav_arrow.gif
index c4f57658d7..c4f57658d7 100644
--- a/railties/guides/assets/images/nav_arrow.gif
+++ b/guides/assets/images/nav_arrow.gif
Binary files differ
diff --git a/railties/guides/assets/images/polymorphic.png b/guides/assets/images/polymorphic.png
index ff2fd9f76d..ff2fd9f76d 100644
--- a/railties/guides/assets/images/polymorphic.png
+++ b/guides/assets/images/polymorphic.png
Binary files differ
diff --git a/railties/guides/assets/images/posts_index.png b/guides/assets/images/posts_index.png
index f6cd2f9b80..f6cd2f9b80 100644
--- a/railties/guides/assets/images/posts_index.png
+++ b/guides/assets/images/posts_index.png
Binary files differ
diff --git a/railties/guides/assets/images/radar.png b/guides/assets/images/radar.png
index f61e08763f..f61e08763f 100644
--- a/railties/guides/assets/images/radar.png
+++ b/guides/assets/images/radar.png
Binary files differ
diff --git a/railties/guides/assets/images/rails_guides_kindle_cover.jpg b/guides/assets/images/rails_guides_kindle_cover.jpg
index 9eb16720a9..9eb16720a9 100644
--- a/railties/guides/assets/images/rails_guides_kindle_cover.jpg
+++ b/guides/assets/images/rails_guides_kindle_cover.jpg
Binary files differ
diff --git a/railties/guides/assets/images/rails_guides_logo.gif b/guides/assets/images/rails_guides_logo.gif
index a24683a34e..a24683a34e 100644
--- a/railties/guides/assets/images/rails_guides_logo.gif
+++ b/guides/assets/images/rails_guides_logo.gif
Binary files differ
diff --git a/railties/guides/assets/images/rails_logo_remix.gif b/guides/assets/images/rails_logo_remix.gif
index 58960ee4f9..58960ee4f9 100644
--- a/railties/guides/assets/images/rails_logo_remix.gif
+++ b/guides/assets/images/rails_logo_remix.gif
Binary files differ
diff --git a/railties/guides/assets/images/rails_welcome.png b/guides/assets/images/rails_welcome.png
index f2aa210d19..f2aa210d19 100644
--- a/railties/guides/assets/images/rails_welcome.png
+++ b/guides/assets/images/rails_welcome.png
Binary files differ
diff --git a/railties/guides/assets/images/session_fixation.png b/guides/assets/images/session_fixation.png
index 6b084508db..6b084508db 100644
--- a/railties/guides/assets/images/session_fixation.png
+++ b/guides/assets/images/session_fixation.png
Binary files differ
diff --git a/railties/guides/assets/images/tab_grey.gif b/guides/assets/images/tab_grey.gif
index e9680b7136..e9680b7136 100644
--- a/railties/guides/assets/images/tab_grey.gif
+++ b/guides/assets/images/tab_grey.gif
Binary files differ
diff --git a/railties/guides/assets/images/tab_info.gif b/guides/assets/images/tab_info.gif
index 458fea9a61..458fea9a61 100644
--- a/railties/guides/assets/images/tab_info.gif
+++ b/guides/assets/images/tab_info.gif
Binary files differ
diff --git a/railties/guides/assets/images/tab_note.gif b/guides/assets/images/tab_note.gif
index 1d5c171ed6..1d5c171ed6 100644
--- a/railties/guides/assets/images/tab_note.gif
+++ b/guides/assets/images/tab_note.gif
Binary files differ
diff --git a/railties/guides/assets/images/tab_red.gif b/guides/assets/images/tab_red.gif
index daf140b5a8..daf140b5a8 100644
--- a/railties/guides/assets/images/tab_red.gif
+++ b/guides/assets/images/tab_red.gif
Binary files differ
diff --git a/railties/guides/assets/images/tab_yellow.gif b/guides/assets/images/tab_yellow.gif
index dc961c99dd..dc961c99dd 100644
--- a/railties/guides/assets/images/tab_yellow.gif
+++ b/guides/assets/images/tab_yellow.gif
Binary files differ
diff --git a/railties/guides/assets/images/tab_yellow.png b/guides/assets/images/tab_yellow.png
index cceea6581f..cceea6581f 100644
--- a/railties/guides/assets/images/tab_yellow.png
+++ b/guides/assets/images/tab_yellow.png
Binary files differ
diff --git a/railties/guides/assets/images/validation_error_messages.png b/guides/assets/images/validation_error_messages.png
index 622d35da5d..622d35da5d 100644
--- a/railties/guides/assets/images/validation_error_messages.png
+++ b/guides/assets/images/validation_error_messages.png
Binary files differ
diff --git a/railties/guides/assets/images/vijaydev.jpg b/guides/assets/images/vijaydev.jpg
index e21d3cabfc..e21d3cabfc 100644
--- a/railties/guides/assets/images/vijaydev.jpg
+++ b/guides/assets/images/vijaydev.jpg
Binary files differ
diff --git a/railties/guides/assets/javascripts/guides.js b/guides/assets/javascripts/guides.js
index c4e4d459ea..c4e4d459ea 100644
--- a/railties/guides/assets/javascripts/guides.js
+++ b/guides/assets/javascripts/guides.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js b/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js
index 8aa3ed2732..8aa3ed2732 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js b/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js
index d40bbd7dd2..d40bbd7dd2 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js b/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js
index 8c296969ff..8c296969ff 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js b/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js
index 079214efe1..079214efe1 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js b/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js
index 627dbb9b76..627dbb9b76 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js b/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js
index 9f70d3aed6..9f70d3aed6 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js b/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js
index 4297a9a648..4297a9a648 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js b/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js
index e1060d4468..e1060d4468 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js b/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js
index e9b14fc580..e9b14fc580 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js b/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js
index 6ba7d9da87..6ba7d9da87 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js b/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js
index 6ec5c18521..6ec5c18521 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js b/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js
index ff98daba16..ff98daba16 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js b/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js
index d692fd6382..d692fd6382 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js b/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js
index 1a150a6ad3..1a150a6ad3 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js b/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js
index d94a2e0ec5..d94a2e0ec5 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js b/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js
index 95e6e4325b..95e6e4325b 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js b/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js
index 9f7d9e90c3..9f7d9e90c3 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js b/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js
index 0be1752968..0be1752968 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js b/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js
index ce77462975..ce77462975 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js b/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js
index ff82130a7a..ff82130a7a 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js b/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js
index aa04da0996..aa04da0996 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js b/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js
index 4b0b6f04d2..4b0b6f04d2 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js b/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js
index 5c2cd8806f..5c2cd8806f 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js b/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js
index be845dc0b3..be845dc0b3 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js b/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js
index 69d9fd0b1f..69d9fd0b1f 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js
diff --git a/railties/guides/assets/javascripts/syntaxhighlighter/shCore.js b/guides/assets/javascripts/syntaxhighlighter/shCore.js
index b47b645472..b47b645472 100644
--- a/railties/guides/assets/javascripts/syntaxhighlighter/shCore.js
+++ b/guides/assets/javascripts/syntaxhighlighter/shCore.js
diff --git a/railties/guides/assets/stylesheets/fixes.css b/guides/assets/stylesheets/fixes.css
index bf86b29efa..bf86b29efa 100644
--- a/railties/guides/assets/stylesheets/fixes.css
+++ b/guides/assets/stylesheets/fixes.css
diff --git a/railties/guides/assets/stylesheets/kindle.css b/guides/assets/stylesheets/kindle.css
index b26cd1786a..b26cd1786a 100644
--- a/railties/guides/assets/stylesheets/kindle.css
+++ b/guides/assets/stylesheets/kindle.css
diff --git a/railties/guides/assets/stylesheets/main.css b/guides/assets/stylesheets/main.css
index 90723cc8e1..90723cc8e1 100644
--- a/railties/guides/assets/stylesheets/main.css
+++ b/guides/assets/stylesheets/main.css
diff --git a/railties/guides/assets/stylesheets/print.css b/guides/assets/stylesheets/print.css
index 628da105d4..628da105d4 100644
--- a/railties/guides/assets/stylesheets/print.css
+++ b/guides/assets/stylesheets/print.css
diff --git a/railties/guides/assets/stylesheets/reset.css b/guides/assets/stylesheets/reset.css
index cb14fbcc55..cb14fbcc55 100644
--- a/railties/guides/assets/stylesheets/reset.css
+++ b/guides/assets/stylesheets/reset.css
diff --git a/railties/guides/assets/stylesheets/style.css b/guides/assets/stylesheets/style.css
index 89b2ab885a..89b2ab885a 100644
--- a/railties/guides/assets/stylesheets/style.css
+++ b/guides/assets/stylesheets/style.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shCore.css b/guides/assets/stylesheets/syntaxhighlighter/shCore.css
index 34f6864a15..34f6864a15 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shCore.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shCore.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css b/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css
index 08f9e10e4e..08f9e10e4e 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css b/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css
index 1db1f70cb0..1db1f70cb0 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css b/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css
index a45de9fd8e..a45de9fd8e 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css b/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css
index 706c77a0a8..706c77a0a8 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css b/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css
index 6101eba51f..6101eba51f 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css b/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css
index 2923ce7367..2923ce7367 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css b/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css
index e3733eed56..e3733eed56 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css b/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css
index d09368384d..d09368384d 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css b/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css
index 136541172d..136541172d 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css b/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css
index d8b4313433..d8b4313433 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css b/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css
index 77377d9533..77377d9533 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css b/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css
index dae5053fea..dae5053fea 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css b/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css
index 8fbd871fb5..8fbd871fb5 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css b/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css
index f4db39cd83..f4db39cd83 100755
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css b/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css
index c49563cc9d..c49563cc9d 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css b/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css
index 6305a10e4e..6305a10e4e 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css
diff --git a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css b/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css
index 6d2edb2eb8..6d2edb2eb8 100644
--- a/railties/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css
+++ b/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css
diff --git a/railties/guides/code/getting_started/Gemfile b/guides/code/getting_started/Gemfile
index 768985070c..768985070c 100644
--- a/railties/guides/code/getting_started/Gemfile
+++ b/guides/code/getting_started/Gemfile
diff --git a/railties/guides/code/getting_started/README.rdoc b/guides/code/getting_started/README.rdoc
index d2014bd35f..d2014bd35f 100644
--- a/railties/guides/code/getting_started/README.rdoc
+++ b/guides/code/getting_started/README.rdoc
diff --git a/railties/guides/code/getting_started/Rakefile b/guides/code/getting_started/Rakefile
index e1d1ec8615..e1d1ec8615 100644
--- a/railties/guides/code/getting_started/Rakefile
+++ b/guides/code/getting_started/Rakefile
diff --git a/railties/guides/code/getting_started/app/assets/images/rails.png b/guides/code/getting_started/app/assets/images/rails.png
index d5edc04e65..d5edc04e65 100644
--- a/railties/guides/code/getting_started/app/assets/images/rails.png
+++ b/guides/code/getting_started/app/assets/images/rails.png
Binary files differ
diff --git a/railties/guides/code/getting_started/app/assets/javascripts/application.js b/guides/code/getting_started/app/assets/javascripts/application.js
index 9097d830e2..9097d830e2 100644
--- a/railties/guides/code/getting_started/app/assets/javascripts/application.js
+++ b/guides/code/getting_started/app/assets/javascripts/application.js
diff --git a/railties/guides/code/getting_started/app/assets/javascripts/comments.js.coffee b/guides/code/getting_started/app/assets/javascripts/comments.js.coffee
index 761567942f..761567942f 100644
--- a/railties/guides/code/getting_started/app/assets/javascripts/comments.js.coffee
+++ b/guides/code/getting_started/app/assets/javascripts/comments.js.coffee
diff --git a/railties/guides/code/getting_started/app/assets/javascripts/home.js.coffee b/guides/code/getting_started/app/assets/javascripts/home.js.coffee
index 761567942f..761567942f 100644
--- a/railties/guides/code/getting_started/app/assets/javascripts/home.js.coffee
+++ b/guides/code/getting_started/app/assets/javascripts/home.js.coffee
diff --git a/railties/guides/code/getting_started/app/assets/javascripts/posts.js.coffee b/guides/code/getting_started/app/assets/javascripts/posts.js.coffee
index 761567942f..761567942f 100644
--- a/railties/guides/code/getting_started/app/assets/javascripts/posts.js.coffee
+++ b/guides/code/getting_started/app/assets/javascripts/posts.js.coffee
diff --git a/railties/guides/code/getting_started/app/assets/stylesheets/application.css b/guides/code/getting_started/app/assets/stylesheets/application.css
index 3b5cc6648e..3b5cc6648e 100644
--- a/railties/guides/code/getting_started/app/assets/stylesheets/application.css
+++ b/guides/code/getting_started/app/assets/stylesheets/application.css
diff --git a/railties/guides/code/getting_started/app/assets/stylesheets/comments.css.scss b/guides/code/getting_started/app/assets/stylesheets/comments.css.scss
index e730912783..e730912783 100644
--- a/railties/guides/code/getting_started/app/assets/stylesheets/comments.css.scss
+++ b/guides/code/getting_started/app/assets/stylesheets/comments.css.scss
diff --git a/railties/guides/code/getting_started/app/assets/stylesheets/home.css.scss b/guides/code/getting_started/app/assets/stylesheets/home.css.scss
index f0ddc6846a..f0ddc6846a 100644
--- a/railties/guides/code/getting_started/app/assets/stylesheets/home.css.scss
+++ b/guides/code/getting_started/app/assets/stylesheets/home.css.scss
diff --git a/railties/guides/code/getting_started/app/assets/stylesheets/posts.css.scss b/guides/code/getting_started/app/assets/stylesheets/posts.css.scss
index ed4dfd10f2..ed4dfd10f2 100644
--- a/railties/guides/code/getting_started/app/assets/stylesheets/posts.css.scss
+++ b/guides/code/getting_started/app/assets/stylesheets/posts.css.scss
diff --git a/railties/guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss b/guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss
index 05188f08ed..05188f08ed 100644
--- a/railties/guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss
+++ b/guides/code/getting_started/app/assets/stylesheets/scaffolds.css.scss
diff --git a/railties/guides/code/getting_started/app/controllers/application_controller.rb b/guides/code/getting_started/app/controllers/application_controller.rb
index e8065d9505..e8065d9505 100644
--- a/railties/guides/code/getting_started/app/controllers/application_controller.rb
+++ b/guides/code/getting_started/app/controllers/application_controller.rb
diff --git a/railties/guides/code/getting_started/app/controllers/comments_controller.rb b/guides/code/getting_started/app/controllers/comments_controller.rb
index 7447fd078b..7447fd078b 100644
--- a/railties/guides/code/getting_started/app/controllers/comments_controller.rb
+++ b/guides/code/getting_started/app/controllers/comments_controller.rb
diff --git a/railties/guides/code/getting_started/app/controllers/home_controller.rb b/guides/code/getting_started/app/controllers/home_controller.rb
index 6cc31c1ca3..6cc31c1ca3 100644
--- a/railties/guides/code/getting_started/app/controllers/home_controller.rb
+++ b/guides/code/getting_started/app/controllers/home_controller.rb
diff --git a/railties/guides/code/getting_started/app/controllers/posts_controller.rb b/guides/code/getting_started/app/controllers/posts_controller.rb
index 1581d4eb16..1581d4eb16 100644
--- a/railties/guides/code/getting_started/app/controllers/posts_controller.rb
+++ b/guides/code/getting_started/app/controllers/posts_controller.rb
diff --git a/railties/guides/code/getting_started/app/helpers/application_helper.rb b/guides/code/getting_started/app/helpers/application_helper.rb
index de6be7945c..de6be7945c 100644
--- a/railties/guides/code/getting_started/app/helpers/application_helper.rb
+++ b/guides/code/getting_started/app/helpers/application_helper.rb
diff --git a/railties/guides/code/getting_started/app/helpers/comments_helper.rb b/guides/code/getting_started/app/helpers/comments_helper.rb
index 0ec9ca5f2d..0ec9ca5f2d 100644
--- a/railties/guides/code/getting_started/app/helpers/comments_helper.rb
+++ b/guides/code/getting_started/app/helpers/comments_helper.rb
diff --git a/railties/guides/code/getting_started/app/helpers/home_helper.rb b/guides/code/getting_started/app/helpers/home_helper.rb
index 23de56ac60..23de56ac60 100644
--- a/railties/guides/code/getting_started/app/helpers/home_helper.rb
+++ b/guides/code/getting_started/app/helpers/home_helper.rb
diff --git a/railties/guides/code/getting_started/app/helpers/posts_helper.rb b/guides/code/getting_started/app/helpers/posts_helper.rb
index b6e8e67894..b6e8e67894 100644
--- a/railties/guides/code/getting_started/app/helpers/posts_helper.rb
+++ b/guides/code/getting_started/app/helpers/posts_helper.rb
diff --git a/railties/guides/code/getting_started/app/mailers/.gitkeep b/guides/code/getting_started/app/mailers/.gitkeep
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/app/mailers/.gitkeep
+++ b/guides/code/getting_started/app/mailers/.gitkeep
diff --git a/railties/guides/code/getting_started/app/models/.gitkeep b/guides/code/getting_started/app/models/.gitkeep
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/app/models/.gitkeep
+++ b/guides/code/getting_started/app/models/.gitkeep
diff --git a/railties/guides/code/getting_started/app/models/comment.rb b/guides/code/getting_started/app/models/comment.rb
index 4e76c5b5b0..4e76c5b5b0 100644
--- a/railties/guides/code/getting_started/app/models/comment.rb
+++ b/guides/code/getting_started/app/models/comment.rb
diff --git a/railties/guides/code/getting_started/app/models/post.rb b/guides/code/getting_started/app/models/post.rb
index 61c2b5ae44..61c2b5ae44 100644
--- a/railties/guides/code/getting_started/app/models/post.rb
+++ b/guides/code/getting_started/app/models/post.rb
diff --git a/railties/guides/code/getting_started/app/models/tag.rb b/guides/code/getting_started/app/models/tag.rb
index 30992e8ba9..30992e8ba9 100644
--- a/railties/guides/code/getting_started/app/models/tag.rb
+++ b/guides/code/getting_started/app/models/tag.rb
diff --git a/railties/guides/code/getting_started/app/views/comments/_comment.html.erb b/guides/code/getting_started/app/views/comments/_comment.html.erb
index 4c3fbf26cd..4c3fbf26cd 100644
--- a/railties/guides/code/getting_started/app/views/comments/_comment.html.erb
+++ b/guides/code/getting_started/app/views/comments/_comment.html.erb
diff --git a/railties/guides/code/getting_started/app/views/comments/_form.html.erb b/guides/code/getting_started/app/views/comments/_form.html.erb
index d15bdd6b59..d15bdd6b59 100644
--- a/railties/guides/code/getting_started/app/views/comments/_form.html.erb
+++ b/guides/code/getting_started/app/views/comments/_form.html.erb
diff --git a/railties/guides/code/getting_started/app/views/home/index.html.erb b/guides/code/getting_started/app/views/home/index.html.erb
index bb4f3dcd1f..bb4f3dcd1f 100644
--- a/railties/guides/code/getting_started/app/views/home/index.html.erb
+++ b/guides/code/getting_started/app/views/home/index.html.erb
diff --git a/railties/guides/code/getting_started/app/views/layouts/application.html.erb b/guides/code/getting_started/app/views/layouts/application.html.erb
index 6578a41da2..6578a41da2 100644
--- a/railties/guides/code/getting_started/app/views/layouts/application.html.erb
+++ b/guides/code/getting_started/app/views/layouts/application.html.erb
diff --git a/railties/guides/code/getting_started/app/views/posts/_form.html.erb b/guides/code/getting_started/app/views/posts/_form.html.erb
index e27da7f413..e27da7f413 100644
--- a/railties/guides/code/getting_started/app/views/posts/_form.html.erb
+++ b/guides/code/getting_started/app/views/posts/_form.html.erb
diff --git a/railties/guides/code/getting_started/app/views/posts/edit.html.erb b/guides/code/getting_started/app/views/posts/edit.html.erb
index 720580236b..720580236b 100644
--- a/railties/guides/code/getting_started/app/views/posts/edit.html.erb
+++ b/guides/code/getting_started/app/views/posts/edit.html.erb
diff --git a/railties/guides/code/getting_started/app/views/posts/index.html.erb b/guides/code/getting_started/app/views/posts/index.html.erb
index 45dee1b25f..45dee1b25f 100644
--- a/railties/guides/code/getting_started/app/views/posts/index.html.erb
+++ b/guides/code/getting_started/app/views/posts/index.html.erb
diff --git a/railties/guides/code/getting_started/app/views/posts/new.html.erb b/guides/code/getting_started/app/views/posts/new.html.erb
index 36ad7421f9..36ad7421f9 100644
--- a/railties/guides/code/getting_started/app/views/posts/new.html.erb
+++ b/guides/code/getting_started/app/views/posts/new.html.erb
diff --git a/railties/guides/code/getting_started/app/views/posts/show.html.erb b/guides/code/getting_started/app/views/posts/show.html.erb
index da78a9527b..da78a9527b 100644
--- a/railties/guides/code/getting_started/app/views/posts/show.html.erb
+++ b/guides/code/getting_started/app/views/posts/show.html.erb
diff --git a/railties/guides/code/getting_started/app/views/tags/_form.html.erb b/guides/code/getting_started/app/views/tags/_form.html.erb
index 7e424b0e20..7e424b0e20 100644
--- a/railties/guides/code/getting_started/app/views/tags/_form.html.erb
+++ b/guides/code/getting_started/app/views/tags/_form.html.erb
diff --git a/railties/guides/code/getting_started/config.ru b/guides/code/getting_started/config.ru
index ddf869e921..ddf869e921 100644
--- a/railties/guides/code/getting_started/config.ru
+++ b/guides/code/getting_started/config.ru
diff --git a/railties/guides/code/getting_started/config/application.rb b/guides/code/getting_started/config/application.rb
index d2cd5c028b..d2cd5c028b 100644
--- a/railties/guides/code/getting_started/config/application.rb
+++ b/guides/code/getting_started/config/application.rb
diff --git a/railties/guides/code/getting_started/config/boot.rb b/guides/code/getting_started/config/boot.rb
index 4489e58688..4489e58688 100644
--- a/railties/guides/code/getting_started/config/boot.rb
+++ b/guides/code/getting_started/config/boot.rb
diff --git a/railties/guides/code/getting_started/config/database.yml b/guides/code/getting_started/config/database.yml
index 51a4dd459d..51a4dd459d 100644
--- a/railties/guides/code/getting_started/config/database.yml
+++ b/guides/code/getting_started/config/database.yml
diff --git a/railties/guides/code/getting_started/config/environment.rb b/guides/code/getting_started/config/environment.rb
index 8f728b7ce7..8f728b7ce7 100644
--- a/railties/guides/code/getting_started/config/environment.rb
+++ b/guides/code/getting_started/config/environment.rb
diff --git a/railties/guides/code/getting_started/config/environments/development.rb b/guides/code/getting_started/config/environments/development.rb
index cec2b20c0b..cec2b20c0b 100644
--- a/railties/guides/code/getting_started/config/environments/development.rb
+++ b/guides/code/getting_started/config/environments/development.rb
diff --git a/railties/guides/code/getting_started/config/environments/production.rb b/guides/code/getting_started/config/environments/production.rb
index cfb8c960d6..cfb8c960d6 100644
--- a/railties/guides/code/getting_started/config/environments/production.rb
+++ b/guides/code/getting_started/config/environments/production.rb
diff --git a/railties/guides/code/getting_started/config/environments/test.rb b/guides/code/getting_started/config/environments/test.rb
index f2bc932fb3..f2bc932fb3 100644
--- a/railties/guides/code/getting_started/config/environments/test.rb
+++ b/guides/code/getting_started/config/environments/test.rb
diff --git a/railties/guides/code/getting_started/config/initializers/backtrace_silencers.rb b/guides/code/getting_started/config/initializers/backtrace_silencers.rb
index 59385cdf37..59385cdf37 100644
--- a/railties/guides/code/getting_started/config/initializers/backtrace_silencers.rb
+++ b/guides/code/getting_started/config/initializers/backtrace_silencers.rb
diff --git a/railties/guides/code/getting_started/config/initializers/inflections.rb b/guides/code/getting_started/config/initializers/inflections.rb
index 5d8d9be237..5d8d9be237 100644
--- a/railties/guides/code/getting_started/config/initializers/inflections.rb
+++ b/guides/code/getting_started/config/initializers/inflections.rb
diff --git a/railties/guides/code/getting_started/config/initializers/mime_types.rb b/guides/code/getting_started/config/initializers/mime_types.rb
index 72aca7e441..72aca7e441 100644
--- a/railties/guides/code/getting_started/config/initializers/mime_types.rb
+++ b/guides/code/getting_started/config/initializers/mime_types.rb
diff --git a/railties/guides/code/getting_started/config/initializers/secret_token.rb b/guides/code/getting_started/config/initializers/secret_token.rb
index f36ebdda18..f36ebdda18 100644
--- a/railties/guides/code/getting_started/config/initializers/secret_token.rb
+++ b/guides/code/getting_started/config/initializers/secret_token.rb
diff --git a/railties/guides/code/getting_started/config/initializers/session_store.rb b/guides/code/getting_started/config/initializers/session_store.rb
index 1a67af58b5..1a67af58b5 100644
--- a/railties/guides/code/getting_started/config/initializers/session_store.rb
+++ b/guides/code/getting_started/config/initializers/session_store.rb
diff --git a/railties/guides/code/getting_started/config/initializers/wrap_parameters.rb b/guides/code/getting_started/config/initializers/wrap_parameters.rb
index 999df20181..999df20181 100644
--- a/railties/guides/code/getting_started/config/initializers/wrap_parameters.rb
+++ b/guides/code/getting_started/config/initializers/wrap_parameters.rb
diff --git a/railties/guides/code/getting_started/config/locales/en.yml b/guides/code/getting_started/config/locales/en.yml
index 179c14ca52..179c14ca52 100644
--- a/railties/guides/code/getting_started/config/locales/en.yml
+++ b/guides/code/getting_started/config/locales/en.yml
diff --git a/railties/guides/code/getting_started/config/routes.rb b/guides/code/getting_started/config/routes.rb
index b048ac68f1..b048ac68f1 100644
--- a/railties/guides/code/getting_started/config/routes.rb
+++ b/guides/code/getting_started/config/routes.rb
diff --git a/railties/guides/code/getting_started/db/migrate/20110901012504_create_posts.rb b/guides/code/getting_started/db/migrate/20110901012504_create_posts.rb
index d45a961523..d45a961523 100644
--- a/railties/guides/code/getting_started/db/migrate/20110901012504_create_posts.rb
+++ b/guides/code/getting_started/db/migrate/20110901012504_create_posts.rb
diff --git a/railties/guides/code/getting_started/db/migrate/20110901012815_create_comments.rb b/guides/code/getting_started/db/migrate/20110901012815_create_comments.rb
index adda8078c1..adda8078c1 100644
--- a/railties/guides/code/getting_started/db/migrate/20110901012815_create_comments.rb
+++ b/guides/code/getting_started/db/migrate/20110901012815_create_comments.rb
diff --git a/railties/guides/code/getting_started/db/migrate/20110901013701_create_tags.rb b/guides/code/getting_started/db/migrate/20110901013701_create_tags.rb
index cf95b1c3d0..cf95b1c3d0 100644
--- a/railties/guides/code/getting_started/db/migrate/20110901013701_create_tags.rb
+++ b/guides/code/getting_started/db/migrate/20110901013701_create_tags.rb
diff --git a/railties/guides/code/getting_started/db/schema.rb b/guides/code/getting_started/db/schema.rb
index 9db4fbe4b6..9db4fbe4b6 100644
--- a/railties/guides/code/getting_started/db/schema.rb
+++ b/guides/code/getting_started/db/schema.rb
diff --git a/railties/guides/code/getting_started/db/seeds.rb b/guides/code/getting_started/db/seeds.rb
index 4edb1e857e..4edb1e857e 100644
--- a/railties/guides/code/getting_started/db/seeds.rb
+++ b/guides/code/getting_started/db/seeds.rb
diff --git a/railties/guides/code/getting_started/doc/README_FOR_APP b/guides/code/getting_started/doc/README_FOR_APP
index fe41f5cc24..fe41f5cc24 100644
--- a/railties/guides/code/getting_started/doc/README_FOR_APP
+++ b/guides/code/getting_started/doc/README_FOR_APP
diff --git a/railties/guides/code/getting_started/lib/assets/.gitkeep b/guides/code/getting_started/lib/assets/.gitkeep
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/lib/assets/.gitkeep
+++ b/guides/code/getting_started/lib/assets/.gitkeep
diff --git a/railties/guides/code/getting_started/lib/tasks/.gitkeep b/guides/code/getting_started/lib/tasks/.gitkeep
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/lib/tasks/.gitkeep
+++ b/guides/code/getting_started/lib/tasks/.gitkeep
diff --git a/railties/guides/code/getting_started/public/404.html b/guides/code/getting_started/public/404.html
index 9a48320a5f..9a48320a5f 100644
--- a/railties/guides/code/getting_started/public/404.html
+++ b/guides/code/getting_started/public/404.html
diff --git a/railties/guides/code/getting_started/public/422.html b/guides/code/getting_started/public/422.html
index 83660ab187..83660ab187 100644
--- a/railties/guides/code/getting_started/public/422.html
+++ b/guides/code/getting_started/public/422.html
diff --git a/railties/guides/code/getting_started/public/500.html b/guides/code/getting_started/public/500.html
index f3648a0dbc..f3648a0dbc 100644
--- a/railties/guides/code/getting_started/public/500.html
+++ b/guides/code/getting_started/public/500.html
diff --git a/railties/guides/code/getting_started/public/favicon.ico b/guides/code/getting_started/public/favicon.ico
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/public/favicon.ico
+++ b/guides/code/getting_started/public/favicon.ico
diff --git a/railties/guides/code/getting_started/public/robots.txt b/guides/code/getting_started/public/robots.txt
index 085187fa58..085187fa58 100644
--- a/railties/guides/code/getting_started/public/robots.txt
+++ b/guides/code/getting_started/public/robots.txt
diff --git a/railties/guides/code/getting_started/script/rails b/guides/code/getting_started/script/rails
index f8da2cffd4..f8da2cffd4 100755
--- a/railties/guides/code/getting_started/script/rails
+++ b/guides/code/getting_started/script/rails
diff --git a/railties/guides/code/getting_started/test/fixtures/.gitkeep b/guides/code/getting_started/test/fixtures/.gitkeep
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/test/fixtures/.gitkeep
+++ b/guides/code/getting_started/test/fixtures/.gitkeep
diff --git a/railties/guides/code/getting_started/test/fixtures/comments.yml b/guides/code/getting_started/test/fixtures/comments.yml
index d33da386bf..d33da386bf 100644
--- a/railties/guides/code/getting_started/test/fixtures/comments.yml
+++ b/guides/code/getting_started/test/fixtures/comments.yml
diff --git a/railties/guides/code/getting_started/test/fixtures/posts.yml b/guides/code/getting_started/test/fixtures/posts.yml
index 8b0f75a33d..8b0f75a33d 100644
--- a/railties/guides/code/getting_started/test/fixtures/posts.yml
+++ b/guides/code/getting_started/test/fixtures/posts.yml
diff --git a/railties/guides/code/getting_started/test/fixtures/tags.yml b/guides/code/getting_started/test/fixtures/tags.yml
index 8485668908..8485668908 100644
--- a/railties/guides/code/getting_started/test/fixtures/tags.yml
+++ b/guides/code/getting_started/test/fixtures/tags.yml
diff --git a/railties/guides/code/getting_started/test/functional/.gitkeep b/guides/code/getting_started/test/functional/.gitkeep
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/test/functional/.gitkeep
+++ b/guides/code/getting_started/test/functional/.gitkeep
diff --git a/railties/guides/code/getting_started/test/functional/comments_controller_test.rb b/guides/code/getting_started/test/functional/comments_controller_test.rb
index 2ec71b4ec5..2ec71b4ec5 100644
--- a/railties/guides/code/getting_started/test/functional/comments_controller_test.rb
+++ b/guides/code/getting_started/test/functional/comments_controller_test.rb
diff --git a/railties/guides/code/getting_started/test/functional/home_controller_test.rb b/guides/code/getting_started/test/functional/home_controller_test.rb
index 0d9bb47c3e..0d9bb47c3e 100644
--- a/railties/guides/code/getting_started/test/functional/home_controller_test.rb
+++ b/guides/code/getting_started/test/functional/home_controller_test.rb
diff --git a/railties/guides/code/getting_started/test/functional/posts_controller_test.rb b/guides/code/getting_started/test/functional/posts_controller_test.rb
index b8f7b07820..b8f7b07820 100644
--- a/railties/guides/code/getting_started/test/functional/posts_controller_test.rb
+++ b/guides/code/getting_started/test/functional/posts_controller_test.rb
diff --git a/railties/guides/code/getting_started/test/integration/.gitkeep b/guides/code/getting_started/test/integration/.gitkeep
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/test/integration/.gitkeep
+++ b/guides/code/getting_started/test/integration/.gitkeep
diff --git a/railties/guides/code/getting_started/test/performance/browsing_test.rb b/guides/code/getting_started/test/performance/browsing_test.rb
index 3fea27b916..3fea27b916 100644
--- a/railties/guides/code/getting_started/test/performance/browsing_test.rb
+++ b/guides/code/getting_started/test/performance/browsing_test.rb
diff --git a/railties/guides/code/getting_started/test/test_helper.rb b/guides/code/getting_started/test/test_helper.rb
index 8bf1192ffe..8bf1192ffe 100644
--- a/railties/guides/code/getting_started/test/test_helper.rb
+++ b/guides/code/getting_started/test/test_helper.rb
diff --git a/railties/guides/code/getting_started/test/unit/.gitkeep b/guides/code/getting_started/test/unit/.gitkeep
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/test/unit/.gitkeep
+++ b/guides/code/getting_started/test/unit/.gitkeep
diff --git a/railties/guides/code/getting_started/test/unit/comment_test.rb b/guides/code/getting_started/test/unit/comment_test.rb
index b6d6131a96..b6d6131a96 100644
--- a/railties/guides/code/getting_started/test/unit/comment_test.rb
+++ b/guides/code/getting_started/test/unit/comment_test.rb
diff --git a/railties/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb b/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb
index 2518c16bd5..2518c16bd5 100644
--- a/railties/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb
+++ b/guides/code/getting_started/test/unit/helpers/comments_helper_test.rb
diff --git a/railties/guides/code/getting_started/test/unit/helpers/home_helper_test.rb b/guides/code/getting_started/test/unit/helpers/home_helper_test.rb
index 4740a18dac..4740a18dac 100644
--- a/railties/guides/code/getting_started/test/unit/helpers/home_helper_test.rb
+++ b/guides/code/getting_started/test/unit/helpers/home_helper_test.rb
diff --git a/railties/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb b/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb
index 48549c2ea1..48549c2ea1 100644
--- a/railties/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb
+++ b/guides/code/getting_started/test/unit/helpers/posts_helper_test.rb
diff --git a/railties/guides/code/getting_started/test/unit/post_test.rb b/guides/code/getting_started/test/unit/post_test.rb
index 6d9d463a71..6d9d463a71 100644
--- a/railties/guides/code/getting_started/test/unit/post_test.rb
+++ b/guides/code/getting_started/test/unit/post_test.rb
diff --git a/railties/guides/code/getting_started/test/unit/tag_test.rb b/guides/code/getting_started/test/unit/tag_test.rb
index b8498a117c..b8498a117c 100644
--- a/railties/guides/code/getting_started/test/unit/tag_test.rb
+++ b/guides/code/getting_started/test/unit/tag_test.rb
diff --git a/railties/guides/code/getting_started/vendor/assets/stylesheets/.gitkeep b/guides/code/getting_started/vendor/assets/stylesheets/.gitkeep
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/vendor/assets/stylesheets/.gitkeep
+++ b/guides/code/getting_started/vendor/assets/stylesheets/.gitkeep
diff --git a/railties/guides/code/getting_started/vendor/plugins/.gitkeep b/guides/code/getting_started/vendor/plugins/.gitkeep
index e69de29bb2..e69de29bb2 100644
--- a/railties/guides/code/getting_started/vendor/plugins/.gitkeep
+++ b/guides/code/getting_started/vendor/plugins/.gitkeep
diff --git a/railties/guides/rails_guides.rb b/guides/rails_guides.rb
index feb5fe3937..e662ad2ed9 100644
--- a/railties/guides/rails_guides.rb
+++ b/guides/rails_guides.rb
@@ -13,8 +13,8 @@ require 'rubygems'
begin
# Guides generation in the Rails repo.
- as_lib = File.join(pwd, "../../activesupport/lib")
- ap_lib = File.join(pwd, "../../actionpack/lib")
+ as_lib = File.join(pwd, "../activesupport/lib")
+ ap_lib = File.join(pwd, "../actionpack/lib")
$:.unshift as_lib if File.directory?(as_lib)
$:.unshift ap_lib if File.directory?(ap_lib)
diff --git a/railties/guides/rails_guides/generator.rb b/guides/rails_guides/generator.rb
index d6a98f9ac4..d6a98f9ac4 100644
--- a/railties/guides/rails_guides/generator.rb
+++ b/guides/rails_guides/generator.rb
diff --git a/railties/guides/rails_guides/helpers.rb b/guides/rails_guides/helpers.rb
index e6ef656474..e6ef656474 100644
--- a/railties/guides/rails_guides/helpers.rb
+++ b/guides/rails_guides/helpers.rb
diff --git a/railties/guides/rails_guides/indexer.rb b/guides/rails_guides/indexer.rb
index 89fbccbb1d..89fbccbb1d 100644
--- a/railties/guides/rails_guides/indexer.rb
+++ b/guides/rails_guides/indexer.rb
diff --git a/railties/guides/rails_guides/levenshtein.rb b/guides/rails_guides/levenshtein.rb
index 489aa3ea7a..489aa3ea7a 100644
--- a/railties/guides/rails_guides/levenshtein.rb
+++ b/guides/rails_guides/levenshtein.rb
diff --git a/railties/guides/rails_guides/textile_extensions.rb b/guides/rails_guides/textile_extensions.rb
index 4677fae504..4677fae504 100644
--- a/railties/guides/rails_guides/textile_extensions.rb
+++ b/guides/rails_guides/textile_extensions.rb
diff --git a/railties/guides/source/2_2_release_notes.textile b/guides/source/2_2_release_notes.textile
index 3a0f2efbaf..3a0f2efbaf 100644
--- a/railties/guides/source/2_2_release_notes.textile
+++ b/guides/source/2_2_release_notes.textile
diff --git a/railties/guides/source/2_3_release_notes.textile b/guides/source/2_3_release_notes.textile
index 15abba66ab..15abba66ab 100644
--- a/railties/guides/source/2_3_release_notes.textile
+++ b/guides/source/2_3_release_notes.textile
diff --git a/railties/guides/source/3_0_release_notes.textile b/guides/source/3_0_release_notes.textile
index d22c76dd81..d22c76dd81 100644
--- a/railties/guides/source/3_0_release_notes.textile
+++ b/guides/source/3_0_release_notes.textile
diff --git a/railties/guides/source/3_1_release_notes.textile b/guides/source/3_1_release_notes.textile
index f88d8624ba..f88d8624ba 100644
--- a/railties/guides/source/3_1_release_notes.textile
+++ b/guides/source/3_1_release_notes.textile
diff --git a/railties/guides/source/3_2_release_notes.textile b/guides/source/3_2_release_notes.textile
index 0f8fea2bf6..0f8fea2bf6 100644
--- a/railties/guides/source/3_2_release_notes.textile
+++ b/guides/source/3_2_release_notes.textile
diff --git a/railties/guides/source/_license.html.erb b/guides/source/_license.html.erb
index 00b4466f50..00b4466f50 100644
--- a/railties/guides/source/_license.html.erb
+++ b/guides/source/_license.html.erb
diff --git a/railties/guides/source/_welcome.html.erb b/guides/source/_welcome.html.erb
index 9d2e9c1d68..9d2e9c1d68 100644
--- a/railties/guides/source/_welcome.html.erb
+++ b/guides/source/_welcome.html.erb
diff --git a/railties/guides/source/action_controller_overview.textile b/guides/source/action_controller_overview.textile
index 52d134ace5..52d134ace5 100644
--- a/railties/guides/source/action_controller_overview.textile
+++ b/guides/source/action_controller_overview.textile
diff --git a/railties/guides/source/action_mailer_basics.textile b/guides/source/action_mailer_basics.textile
index 2760e03be1..c277f764e7 100644
--- a/railties/guides/source/action_mailer_basics.textile
+++ b/guides/source/action_mailer_basics.textile
@@ -244,7 +244,7 @@ It is possible to send email to one or more recipients in one email (for e.g. in
<ruby>
class AdminMailer < ActionMailer::Base
- default :to => Proc.new { Admin.all.map(&:email) },
+ default :to => Proc.new { Admin.pluck(:email) },
:from => "notification@example.com"
def new_registration(user)
diff --git a/railties/guides/source/action_view_overview.textile b/guides/source/action_view_overview.textile
index 42120e9bad..42120e9bad 100644
--- a/railties/guides/source/action_view_overview.textile
+++ b/guides/source/action_view_overview.textile
diff --git a/railties/guides/source/active_model_basics.textile b/guides/source/active_model_basics.textile
index 98b3533000..98b3533000 100644
--- a/railties/guides/source/active_model_basics.textile
+++ b/guides/source/active_model_basics.textile
diff --git a/railties/guides/source/active_record_basics.textile b/guides/source/active_record_basics.textile
index 487f8b70f9..487f8b70f9 100644
--- a/railties/guides/source/active_record_basics.textile
+++ b/guides/source/active_record_basics.textile
diff --git a/railties/guides/source/active_record_querying.textile b/guides/source/active_record_querying.textile
index 8e23a577e2..8e23a577e2 100644
--- a/railties/guides/source/active_record_querying.textile
+++ b/guides/source/active_record_querying.textile
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/guides/source/active_record_validations_callbacks.textile
index 88c4481e5e..88c4481e5e 100644
--- a/railties/guides/source/active_record_validations_callbacks.textile
+++ b/guides/source/active_record_validations_callbacks.textile
diff --git a/railties/guides/source/active_support_core_extensions.textile b/guides/source/active_support_core_extensions.textile
index 5d0a3f82e8..5d0a3f82e8 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/guides/source/active_support_core_extensions.textile
diff --git a/guides/source/active_support_instrumentation.textile b/guides/source/active_support_instrumentation.textile
new file mode 100644
index 0000000000..430549fba4
--- /dev/null
+++ b/guides/source/active_support_instrumentation.textile
@@ -0,0 +1,448 @@
+h2. Active Support Instrumentation
+
+Active Support is a part of core Rails that provides Ruby language extensions, utilities and other things. One of the things it includes is an instrumentation API that can be used inside an application to measure certain actions that occur within Ruby code, such as that inside a Rails application or the framework itself. It is not limited to Rails, however. It can be used independently in other Ruby scripts if it is so desired.
+
+In this guide, you will learn how to use the instrumentation API inside of ActiveSupport to measure events inside of Rails and other Ruby code. We cover:
+
+* What instrumentation can provide
+* The hooks inside the Rails framework for instrumentation
+* Adding a subscriber to a hook
+* Building a custom instrumentation implementation
+
+endprologue.
+
+h3. Introduction to instrumentation
+
+The instrumentation API provided by ActiveSupport allows developers to provide hooks which other developers may hook into. There are several of these within the Rails framework, as described below in <TODO: link to section detailing each hook point>. With this API, developers can choose to be notified when certain events occur inside their application or another piece of Ruby code.
+
+For example, there is a hook provided within Active Record that is called every time Active Record uses a SQL query on a database. This hook could be *subscribed* to, and used to track the number of queries during a certain action. There's another hook around the processing of an action of a controller. This could be used, for instance, to track how long a specific action has taken.
+
+You are even able to create your own events inside your application which you can later subscribe to.
+
+h3. Rails framework hooks
+
+Within the Ruby on Rails framework, there are a number of hooks provided for common events. These are detailed below.
+
+h3. ActionController
+
+h4. write_fragment.action_controller
+
+|_.Key |_.Value|
+|+:key+ |The complete key|
+
+<ruby>
+{
+ :key => 'posts/1-dasboard-view'
+}
+</ruby>
+
+h4. read_fragment.action_controller
+
+|_.Key |_.Value|
+|+:key+ |The complete key|
+
+<ruby>
+{
+ :key => 'posts/1-dasboard-view'
+}
+</ruby>
+
+h4. expire_fragment.action_controller
+
+|_.Key |_.Value|
+|+:key+ |The complete key|
+
+<ruby>
+{
+ :key => 'posts/1-dasboard-view'
+}
+</ruby>
+
+h4. exist_fragment?.action_controller
+
+|_.Key |_.Value|
+|+:key+ |The complete key|
+
+<ruby>
+{
+ :key => 'posts/1-dasboard-view'
+}
+</ruby>
+
+h4. write_page.action_controller
+
+|_.Key |_.Value|
+|+:path+ |The complete path|
+
+<ruby>
+{
+ :path => '/users/1'
+}
+</ruby>
+
+h4. expire_page.action_controller
+
+|_.Key |_.Value|
+|+:path+ |The complete path|
+
+<ruby>
+{
+ :path => '/users/1'
+}
+</ruby>
+
+h4. start_processing.action_controller
+
+|_.Key |_.Value |
+|+:controller+ |The controller name|
+|+:action+ |The action|
+|+:params+ |Hash of request parameters without any filtered parameter|
+|+:format+ |html/js/json/xml etc|
+|+:method+ |HTTP request verb|
+|+:path+ |Request path|
+
+<ruby>
+{
+ :controller => "PostsController",
+ :action => "new",
+ :params => { "action" => "new", "controller" => "posts" },
+ :format => :html,
+ :method => "GET",
+ :path => "/posts/new"
+}
+</ruby>
+
+h4. process_action.action_controller
+
+|_.Key |_.Value |
+|+:controller+ |The controller name|
+|+:action+ |The action|
+|+:params+ |Hash of request parameters without any filtered parameter|
+|+:format+ |html/js/json/xml etc|
+|+:method+ |HTTP request verb|
+|+:path+ |Request path|
+|+:view_runtime+ |Amount spent in view in ms|
+
+<ruby>
+{
+ :controller => "PostsController",
+ :action => "index",
+ :params => {"action" => "index", "controller" => "posts"},
+ :format => :html,
+ :method => "GET",
+ :path => "/posts",
+ :status => 200,
+ :view_runtime => 46.848,
+ :db_runtime => 0.157
+}
+</ruby>
+
+h4. send_file.action_controller
+
+|_.Key |_.Value |
+|+:path+ |Complete path to the file|
+
+INFO. Additional keys may be added by the caller.
+
+h4. send_data.action_controller
+
++ActionController+ does not had any specific information to the payload. All options are passed through to the payload.
+
+h4. redirect_to.action_controller
+
+|_.Key |_.Value |
+|+:status+ |HTTP response code|
+|+:location+ |URL to redirect to|
+
+<ruby>
+{
+ :status => 302,
+ :location => "http://localhost:3000/posts/new"
+}
+</ruby>
+
+h4. halted_callback.action_controller
+
+|_.Key |_.Value |
+|+:filter+ |Filter that halted the action|
+
+<ruby>
+{
+ :filter => ":halting_filter"
+}
+</ruby>
+
+h3. ActionView
+
+h4. render_template.action_view
+
+|_.Key |_.Value |
+|+:identifier+ |Full path to template|
+|+:layout+ |Applicable layout|
+
+<ruby>
+{
+ :identifier => "/Users/adam/projects/notifications/app/views/posts/index.html.erb",
+ :layout => "layouts/application"
+}
+</ruby>
+
+h4. render_partial.action_view
+
+|_.Key |_.Value |
+|+:identifier+ |Full path to template|
+
+<ruby>
+{
+ :identifier => "/Users/adam/projects/notifications/app/views/posts/_form.html.erb",
+}
+</ruby>
+
+h3. ActiveRecord
+
+h4. sql.active_record
+
+|_.Key |_.Value |
+|+:sql+ |SQL statement|
+|+:name+ |Name of the operation|
+|+:object_id+ |+self.object_id+|
+
+INFO. The adapters will add their own data as well.
+
+<ruby>
+{
+ :sql => "SELECT \"posts\".* FROM \"posts\" ",
+ :name => "Post Load",
+ :connection_id => 70307250813140,
+ :binds => []
+}
+</ruby>
+
+h4. identity.active_record
+
+|_.Key |_.Value |
+|+:line+ |Primary Key of object in the identity map|
+|+:name+ |Record's class|
+|+:connection_id+ |+self.object_id+|
+
+h3. ActionMailer
+
+h4. receive.action_mailer
+
+|_.Key |_.Value|
+|+:mailer+ |Name of the mailer class|
+|+:message_id+ |ID of the message, generated by the Mail gem|
+|+:subject+ |Subject of the mail|
+|+:to+ |To address(es) of the mail|
+|+:from+ |From address of the mail|
+|+:bcc+ |BCC addresses of the mail|
+|+:cc+ |CC addresses of the mail|
+|+:date+ |Date of the mail|
+|+:mail+ |The encoded form of the mail|
+
+<ruby>
+{
+ :mailer => "Notification",
+ :message_id => "4f5b5491f1774_181b23fc3d4434d38138e5@mba.local.mail",
+ :subject => "Rails Guides",
+ :to => ["users@rails.com", "ddh@rails.com"],
+ :from => ["me@rails.com"],
+ :date => Sat, 10 Mar 2012 14:18:09 +0100,
+ :mail=> "..." # ommitted for beverity
+}
+</ruby>
+
+h4. deliver.action_mailer
+
+|_.Key |_.Value|
+|+:mailer+ |Name of the mailer class|
+|+:message_id+ |ID of the message, generated by the Mail gem|
+|+:subject+ |Subject of the mail|
+|+:to+ |To address(es) of the mail|
+|+:from+ |From address of the mail|
+|+:bcc+ |BCC addresses of the mail|
+|+:cc+ |CC addresses of the mail|
+|+:date+ |Date of the mail|
+|+:mail+ |The encoded form of the mail|
+
+<ruby>
+{
+ :mailer => "Notification",
+ :message_id => "4f5b5491f1774_181b23fc3d4434d38138e5@mba.local.mail",
+ :subject => "Rails Guides",
+ :to => ["users@rails.com", "ddh@rails.com"],
+ :from => ["me@rails.com"],
+ :date => Sat, 10 Mar 2012 14:18:09 +0100,
+ :mail=> "..." # ommitted for beverity
+}
+</ruby>
+
+h3. ActiveResource
+
+h4. request.active_resource
+
+|_.Key |_.Value|
+|+:method+ |HTTP method|
+|+:request_uri+ |Complete URI|
+|+:result+ |HTTP response object|
+
+h3. ActiveSupport
+
+h4. cache_read.active_support
+
+|_.Key |_.Value|
+|+:key+ |Key used in the store|
+|+:hit+ |If this read is a hit|
+|+:super_operation+ |:fetch is added when a read is used with +#fetch+|
+
+h4. cache_generate.active_support
+
+This event is only used when +#fetch+ is called with a block.
+
+|_.Key |_.Value|
+|+:key+ |Key used in the store|
+
+INFO. Options passed to fetch will be merged with the payload when writing to the store
+
+<ruby>
+{
+ :key => 'name-of-complicated-computation'
+}
+</ruby>
+
+
+h4. cache_fetch_hit.active_support
+
+This event is only used when +#fetch+ is called with a block.
+
+|_.Key |_.Value|
+|+:key+ |Key used in the store|
+
+INFO. Options passed to fetch will be merged with the payload.
+
+<ruby>
+{
+ :key => 'name-of-complicated-computation'
+}
+</ruby>
+
+h4. cache_write.active_support
+
+|_.Key |_.Value|
+|+:key+ |Key used in the store|
+
+INFO. Cache stores my add their own keys
+
+<ruby>
+{
+ :key => 'name-of-complicated-computation'
+}
+</ruby>
+
+h4. cache_delete.active_support
+
+|_.Key |_.Value|
+|+:key+ |Key used in the store|
+
+<ruby>
+{
+ :key => 'name-of-complicated-computation'
+}
+</ruby>
+
+h4. cache_exist?.active_support
+
+|_.Key |_.Value|
+|+:key+ |Key used in the store|
+
+<ruby>
+{
+ :key => 'name-of-complicated-computation'
+}
+</ruby>
+
+h3. Rails
+
+h4. deprecation.rails
+
+|_.Key |_.Value|
+|+:message+ |The deprecation warning|
+|+:callstack+ |Where the deprecation came from|
+
+h3. Subscribing to an event
+
+Subscribing to an event is easy. Use +ActiveSupport::Notifications.subscribe+ with a block to
+listen to any notification.
+
+The block receives the following arguments:
+
+# The name of the event
+# Time when is started
+# Time when it finished
+# An unique ID for this event
+# The payload (described in previous sections)
+
+<ruby>
+ActiveSupport::Notifications.subscribe "process_action.action_controller" do |name, started, finished, unique_id, data|
+ # your own custom stuff
+ Rails.logger.info "#{name} Received!"
+end
+</ruby>
+
+Defining all those block arguments each time can be tedious. You can easily create an +ActiveSupport::Notifications::Event+
+from block args like this:
+
+<ruby>
+ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
+ event = ActiveSupport::Notification::Event.new args
+
+ event.name # => "process_action.action_controller"
+ event.duration # => 10 (in milliseconds)
+ event.payload # => { :extra => :information }
+
+ Rails.logger.info "#{event} Received!"
+end
+</ruby>
+
+Most times you only care about the data itself. Here is a shortuct to just get the data.
+
+<ruby>
+ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
+ data = args.extract_options!
+ data # { :extra => :information }
+</ruby>
+
+You may also subscribe to events matching a regular expresssion. This enables you to subscribe to
+multiple events at once. Here's you could subscribe to everything from +ActionController+.
+
+<ruby>
+ActiveSupport::Notifications.subscribe /action_controller/ do |*args|
+ # inspect all ActionController events
+end
+</ruby>
+
+h3. Creating custom events
+
+Adding your own events is easy as well. +ActiveSupport::Notifications+ will take care of
+all the heavy lifting for you. Simply call +instrument+ with a +name+, +payload+ and a block.
+The notification will be sent after the block returns. +ActiveSupport+ will generate the start and end times
+as well as the unique ID. All data passed into the +insturment+ call will make it into the payload.
+
+Here's an example:
+
+<ruby>
+ActiveSupport::Notifications.instrument "my.custom.event", :this => :data do
+ # do your custom stuff here
+end
+</ruby>
+
+Now you can listen to this event with:
+
+<ruby>
+ActiveSupport::Notifications.subscribe "my.custom.event" do |name, started, finished, unique_id, data|
+ puts data.inspect # { :this => :data }
+end
+</ruby>
+
+You should follow Rails conventions when defining your own events. The format is: +event.library+.
+If you application is sending Tweets, you should create an event named +tweet.twitter+.
diff --git a/railties/guides/source/ajax_on_rails.textile b/guides/source/ajax_on_rails.textile
index cda9c64460..cda9c64460 100644
--- a/railties/guides/source/ajax_on_rails.textile
+++ b/guides/source/ajax_on_rails.textile
diff --git a/railties/guides/source/api_documentation_guidelines.textile b/guides/source/api_documentation_guidelines.textile
index 93120c15a7..c6aa1f0a2b 100644
--- a/railties/guides/source/api_documentation_guidelines.textile
+++ b/guides/source/api_documentation_guidelines.textile
@@ -6,7 +6,7 @@ endprologue.
h3. RDoc
-The Rails API documentation is generated with RDoc 2.5. Please consult the documentation for help with the "markup":http://rdoc.rubyforge.org/RDoc/Markup.html, and take into account also these "additional directives":http://rdoc.rubyforge.org/RDoc/Parser/Ruby.html.
+The Rails API documentation is generated with RDoc. Please consult the documentation for help with the "markup":http://rdoc.rubyforge.org/RDoc/Markup.html, and also take into account these "additional directives":http://rdoc.rubyforge.org/RDoc/Parser/Ruby.html.
h3. Wording
@@ -14,7 +14,7 @@ Write simple, declarative sentences. Brevity is a plus: get to the point.
Write in present tense: "Returns a hash that...", rather than "Returned a hash that..." or "Will return a hash that...".
-Start comments in upper case, follow regular punctuation rules:
+Start comments in upper case. Follow regular punctuation rules:
<ruby>
# Declares an attribute reader backed by an internally-named instance variable.
@@ -23,7 +23,7 @@ def attr_internal_reader(*attrs)
end
</ruby>
-Communicate to the reader the current way of doing things, both explicitly and implicitly. Use the recommended idioms in edge, reorder sections to emphasize favored approaches if needed, etc. The documentation should be a model for best practices and canonical, modern Rails usage.
+Communicate to the reader the current way of doing things, both explicitly and implicitly. Use the idioms recommended in edge. Reorder sections to emphasize favored approaches if needed, etc. The documentation should be a model for best practices and canonical, modern Rails usage.
Documentation has to be concise but comprehensive. Explore and document edge cases. What happens if a module is anonymous? What if a collection is empty? What if an argument is nil?
@@ -41,10 +41,9 @@ h3. Example Code
Choose meaningful examples that depict and cover the basics as well as interesting points or gotchas.
-Use two spaces to indent chunks of code--that is two spaces with respect to the left margin; the examples
-themselves should use "Rails coding conventions":contributing_to_ruby_on_rails.html#follow-the-coding-conventions.
+Use two spaces to indent chunks of code--that is, for markup purposes, two spaces with respect to the left margin. The examples themselves should use "Rails coding conventions":contributing_to_ruby_on_rails.html#follow-the-coding-conventions.
-Short docs do not need an explicit "Examples" label to introduce snippets, they just follow paragraphs:
+Short docs do not need an explicit "Examples" label to introduce snippets; they just follow paragraphs:
<ruby>
# Converts a collection of elements into a formatted string by calling
@@ -64,7 +63,7 @@ On the other hand, big chunks of structured documentation may have a separate "E
# Person.exists?(['name LIKE ?', "%#{query}%"])
</ruby>
-The result of expressions follow them and are introduced by "# => ", vertically aligned:
+The results of expressions follow them and are introduced by "# => ", vertically aligned:
<ruby>
# For checking if a fixnum is even or odd.
@@ -98,7 +97,7 @@ On the other hand, regular comments do not use an arrow:
h3. Filenames
-As a rule of thumb use filenames relative to the application root:
+As a rule of thumb, use filenames relative to the application root:
<plain>
config/routes.rb # YES
@@ -111,12 +110,12 @@ h3. Fonts
h4. Fixed-width Font
Use fixed-width fonts for:
-* constants, in particular class and module names
-* method names
-* literals like +nil+, +false+, +true+, +self+
-* symbols
-* method parameters
-* file names
+* Constants, in particular class and module names.
+* Method names.
+* Literals like +nil+, +false+, +true+, +self+.
+* Symbols.
+* Method parameters.
+* File names.
<ruby>
class Array
@@ -134,6 +133,20 @@ h4. Regular Font
When "true" and "false" are English words rather than Ruby keywords use a regular font:
+<ruby>
+# Runs all the validations within the specified context. Returns true if no errors are found,
+# false otherwise.
+#
+# If the argument is false (default is +nil+), the context is set to <tt>:create</tt> if
+# <tt>new_record?</tt> is true, and to <tt>:update</tt> if it is not.
+#
+# Validations with no <tt>:on</tt> option will run no matter the context. Validations with
+# some <tt>:on</tt> option will only run in the specified context.
+def valid?(context = nil)
+ ...
+end
+</ruby>
+
h3. Description Lists
In lists of options, parameters, etc. use a hyphen between the item and its description (reads better than a colon because normally options are symbols):
@@ -146,7 +159,7 @@ The description starts in upper case and ends with a full stop—it's standard E
h3. Dynamically Generated Methods
-Methods created with +(module|class)_eval(STRING)+ have a comment by their side with an instance of the generated code. That comment is 2 spaces apart from the template:
+Methods created with +(module|class)_eval(STRING)+ have a comment by their side with an instance of the generated code. That comment is 2 spaces away from the template:
<ruby>
for severity in Severity.constants
@@ -162,7 +175,7 @@ for severity in Severity.constants
end
</ruby>
-If the resulting lines are too wide, say 200 columns or more, we put the comment above the call:
+If the resulting lines are too wide, say 200 columns or more, put the comment above the call:
<ruby>
# def self.find_by_login_and_activated(*args)
diff --git a/railties/guides/source/asset_pipeline.textile b/guides/source/asset_pipeline.textile
index b1b1d21c2d..a1b7a42d66 100644
--- a/railties/guides/source/asset_pipeline.textile
+++ b/guides/source/asset_pipeline.textile
@@ -409,7 +409,9 @@ cannot see application objects or methods. *Heroku requires this to be false.*
WARNING: If you set +config.assets.initialize_on_precompile+ to false, be sure to
test +rake assets:precompile+ locally before deploying. It may expose bugs where
your assets reference application objects or methods, since those are still
-in scope in development mode regardless of the value of this flag.
+in scope in development mode regardless of the value of this flag. Changing this flag also effects
+engines. Engines can define assets for precompilation as well. Since the complete environment is not loaded,
+engines (or other gems) will not be loaded which can cause missing assets.
Capistrano (v2.8.0 and above) includes a recipe to handle this in deployment. Add the following line to +Capfile+:
diff --git a/railties/guides/source/association_basics.textile b/guides/source/association_basics.textile
index 493b7c30be..8ddc56bef1 100644
--- a/railties/guides/source/association_basics.textile
+++ b/guides/source/association_basics.textile
@@ -342,9 +342,9 @@ In designing a data model, you will sometimes find a model that should have a re
<ruby>
class Employee < ActiveRecord::Base
- has_many :subordinates, :class_name => "Employee"
- belongs_to :manager, :class_name => "Employee",
+ has_many :subordinates, :class_name => "Employee",
:foreign_key => "manager_id"
+ belongs_to :manager, :class_name => "Employee"
end
</ruby>
diff --git a/railties/guides/source/caching_with_rails.textile b/guides/source/caching_with_rails.textile
index e2c6c7a2a4..0e811a2527 100644
--- a/railties/guides/source/caching_with_rails.textile
+++ b/guides/source/caching_with_rails.textile
@@ -257,7 +257,9 @@ However, it's important to note that query caches are created at the start of an
h3. Cache Stores
-Rails provides different stores for the cached data created by action and fragment caches. Page caches are always stored on disk.
+Rails provides different stores for the cached data created by <b>action</b> and <b>fragment</b> caches.
+
+TIP: Page caches are always stored on disk.
h4. Configuration
@@ -267,7 +269,7 @@ You can set up your application's default cache store by calling +config.cache_s
config.cache_store = :memory_store
</ruby>
-Alternatively, you can call +ActionController::Base.cache_store+ outside of a configuration block.
+NOTE: Alternatively, you can call +ActionController::Base.cache_store+ outside of a configuration block.
You can access the cache by calling +Rails.cache+.
@@ -294,7 +296,7 @@ h4. ActiveSupport::Cache::MemoryStore
This cache store keeps entries in memory in the same Ruby process. The cache store has a bounded size specified by the +:size+ options to the initializer (default is 32Mb). When the cache exceeds the allotted size, a cleanup will occur and the least recently used entries will be removed.
<ruby>
-ActionController::Base.cache_store = :memory_store, :size => 64.megabytes
+config.cache_store = :memory_store, :size => 64.megabytes
</ruby>
If you're running multiple Ruby on Rails server processes (which is the case if you're using mongrel_cluster or Phusion Passenger), then your Rails server process instances won't be able to share cache data with each other. This cache store is not appropriate for large application deployments, but can work well for small, low traffic sites with only a couple of server processes or for development and test environments.
@@ -306,7 +308,7 @@ h4. ActiveSupport::Cache::FileStore
This cache store uses the file system to store entries. The path to the directory where the store files will be stored must be specified when initializing the cache.
<ruby>
-ActionController::Base.cache_store = :file_store, "/path/to/cache/directory"
+config.cache_store = :file_store, "/path/to/cache/directory"
</ruby>
With this cache store, multiple server processes on the same host can share a cache. Servers processes running on different hosts could share a cache by using a shared file system, but that set up would not be ideal and is not recommended. The cache store is appropriate for low to medium traffic sites that are served off one or two hosts.
@@ -322,7 +324,7 @@ When initializing the cache, you need to specify the addresses for all memcached
The +write+ and +fetch+ methods on this cache accept two additional options that take advantage of features specific to memcached. You can specify +:raw+ to send a value directly to the server with no serialization. The value must be a string or number. You can use memcached direct operation like +increment+ and +decrement+ only on raw values. You can also specify +:unless_exist+ if you don't want memcached to overwrite an existing entry.
<ruby>
-ActionController::Base.cache_store = :mem_cache_store, "cache-1.example.com", "cache-2.example.com"
+config.cache_store = :mem_cache_store, "cache-1.example.com", "cache-2.example.com"
</ruby>
h4. ActiveSupport::Cache::EhcacheStore
@@ -330,7 +332,7 @@ h4. ActiveSupport::Cache::EhcacheStore
If you are using JRuby you can use Terracotta's Ehcache as the cache store for your application. Ehcache is an open source Java cache that also offers an enterprise version with increased scalability, management, and commercial support. You must first install the jruby-ehcache-rails3 gem (version 1.1.0 or later) to use this cache store.
<ruby>
-ActionController::Base.cache_store = :ehcache_store
+config.cache_store = :ehcache_store
</ruby>
When initializing the cache, you may use the +:ehcache_config+ option to specify the Ehcache config file to use (where the default is "ehcache.xml" in your Rails config directory), and the :cache_name option to provide a custom name for your cache (the default is rails_cache).
@@ -359,7 +361,7 @@ h4. ActiveSupport::Cache::NullStore
This cache store implementation is meant to be used only in development or test environments and it never stores anything. This can be very useful in development when you have code that interacts directly with +Rails.cache+, but caching may interfere with being able to see the results of code changes. With this cache store, all +fetch+ and +read+ operations will result in a miss.
<ruby>
-ActionController::Base.cache_store = :null_store
+config.cache_store = :null_store
</ruby>
h4. Custom Cache Stores
@@ -369,7 +371,7 @@ You can create your own custom cache store by simply extending +ActiveSupport::C
To use a custom cache store, simple set the cache store to a new instance of the class.
<ruby>
-ActionController::Base.cache_store = MyCacheStore.new
+config.cache_store = MyCacheStore.new
</ruby>
h4. Cache Keys
diff --git a/railties/guides/source/command_line.textile b/guides/source/command_line.textile
index 463c2b172b..463c2b172b 100644
--- a/railties/guides/source/command_line.textile
+++ b/guides/source/command_line.textile
diff --git a/railties/guides/source/configuring.textile b/guides/source/configuring.textile
index 79980be5ef..cf0d8f1a43 100644
--- a/railties/guides/source/configuring.textile
+++ b/guides/source/configuring.textile
@@ -88,7 +88,7 @@ NOTE. The +config.asset_path+ configuration is ignored if the asset pipeline is
* +config.filter_parameters+ used for filtering out the parameters that you don't want shown in the logs, such as passwords or credit card numbers.
-* +config.force_ssl+ forces all requests to be under HTTPS protocol by using +Rack::SSL+ middleware.
+* +config.force_ssl+ forces all requests to be under HTTPS protocol by using +ActionDispatch::SSL+ middleware.
* +config.log_level+ defines the verbosity of the Rails logger. This option defaults to +:debug+ for all modes except production, where it defaults to +:info+.
@@ -197,7 +197,7 @@ h4. Configuring Middleware
Every Rails application comes with a standard set of middleware which it uses in this order in the development environment:
-* +Rack::SSL+ forces every request to be under HTTPS protocol. Will be available if +config.force_ssl+ is set to +true+. Options passed to this can be configured by using +config.ssl_options+.
+* +ActionDispatch::SSL+ forces every request to be under HTTPS protocol. Will be available if +config.force_ssl+ is set to +true+. Options passed to this can be configured by using +config.ssl_options+.
* +ActionDispatch::Static+ is used to serve static assets. Disabled if +config.serve_static_assets+ is +true+.
* +Rack::Lock+ wraps the app in mutex so it can only be called by a single thread at a time. Only enabled if +config.action_controller.allow_concurrency+ is set to +false+, which it is by default.
* +ActiveSupport::Cache::Strategy::LocalCache+ serves as a basic memory backed cache. This cache is not thread safe and is intended only for serving as a temporary memory cache for a single thread.
@@ -459,6 +459,99 @@ There are a few configuration options available in Active Support:
* +ActiveSupport::Logger.silencer+ is set to +false+ to disable the ability to silence logging in a block. The default is +true+.
+h4. Configuring a Database
+
+Just about every Rails application will interact with a database. The database to use is specified in a configuration file called +config/database.yml+. If you open this file in a new Rails application, you'll see a default database configured to use SQLite3. The file contains sections for three different environments in which Rails can run by default:
+
+* The +development+ environment is used on your development/local computer as you interact manually with the application.
+* The +test+ environment is used when running automated tests.
+* The +production+ environment is used when you deploy your application for the world to use.
+
+TIP: You don't have to update the database configurations manually. If you look at the options of the application generator, you will see that one of the options is named <tt>--database</tt>. This option allows you to choose an adapter from a list of the most used relational databases. You can even run the generator repeatedly: <tt>cd .. && rails new blog --database=mysql</tt>. When you confirm the overwriting of the +config/database.yml+ file, your application will be configured for MySQL instead of SQLite. Detailed examples of the common database connections are below.
+
+h5. Configuring an SQLite3 Database
+
+Rails comes with built-in support for "SQLite3":http://www.sqlite.org, which is a lightweight serverless database application. While a busy production environment may overload SQLite, it works well for development and testing. Rails defaults to using an SQLite database when creating a new project, but you can always change it later.
+
+Here's the section of the default configuration file (<tt>config/database.yml</tt>) with connection information for the development environment:
+
+<yaml>
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
+</yaml>
+
+NOTE: Rails uses an SQLite3 database for data storage by default because it is a zero configuration database that just works. Rails also supports MySQL and PostgreSQL "out of the box", and has plugins for many database systems. If you are using a database in a production environment Rails most likely has an adapter for it.
+
+h5. Configuring a MySQL Database
+
+If you choose to use MySQL instead of the shipped SQLite3 database, your +config/database.yml+ will look a little different. Here's the development section:
+
+<yaml>
+development:
+ adapter: mysql2
+ encoding: utf8
+ database: blog_development
+ pool: 5
+ username: root
+ password:
+ socket: /tmp/mysql.sock
+</yaml>
+
+If your development computer's MySQL installation includes a root user with an empty password, this configuration should work for you. Otherwise, change the username and password in the +development+ section as appropriate.
+
+h5. Configuring a PostgreSQL Database
+
+If you choose to use PostgreSQL, your +config/database.yml+ will be customized to use PostgreSQL databases:
+
+<yaml>
+development:
+ adapter: postgresql
+ encoding: unicode
+ database: blog_development
+ pool: 5
+ username: blog
+ password:
+</yaml>
+
+h5. Configuring an SQLite3 Database for JRuby Platform
+
+If you choose to use SQLite3 and are using JRuby, your +config/database.yml+ will look a little different. Here's the development section:
+
+<yaml>
+development:
+ adapter: jdbcsqlite3
+ database: db/development.sqlite3
+</yaml>
+
+h5. Configuring a MySQL Database for JRuby Platform
+
+If you choose to use MySQL and are using JRuby, your +config/database.yml+ will look a little different. Here's the development section:
+
+<yaml>
+development:
+ adapter: jdbcmysql
+ database: blog_development
+ username: root
+ password:
+</yaml>
+
+h5. Configuring a PostgreSQL Database for JRuby Platform
+
+If you choose to use PostgreSQL and are using JRuby, your +config/database.yml+ will look a little different. Here's the development section:
+
+<yaml>
+development:
+ adapter: jdbcpostgresql
+ encoding: unicode
+ database: blog_development
+ username: blog
+ password:
+</yaml>
+
+Change the username and password in the +development+ section as appropriate.
h3. Rails Environment Settings
diff --git a/railties/guides/source/contributing_to_ruby_on_rails.textile b/guides/source/contributing_to_ruby_on_rails.textile
index df8b16eb9e..d0dbb1555a 100644
--- a/railties/guides/source/contributing_to_ruby_on_rails.textile
+++ b/guides/source/contributing_to_ruby_on_rails.textile
@@ -8,29 +8,29 @@ This guide covers ways in which _you_ can become a part of the ongoing developme
* Contributing to the Ruby on Rails documentation
* Contributing to the Ruby on Rails code
-Ruby on Rails is not "someone else's framework." Over the years, hundreds of people have contributed to Ruby on Rails ranging from a single character to massive architectural changes or significant documentation. All with the goal of making Ruby on Rails better for everyone. Even if you don't feel up to writing code or documentation yet, there are a variety of other ways that you can contribute, from reporting issues to testing patches.
+Ruby on Rails is not "someone else's framework." Over the years, hundreds of people have contributed to Ruby on Rails ranging from a single character to massive architectural changes or significant documentation -- all with the goal of making Ruby on Rails better for everyone. Even if you don't feel up to writing code or documentation yet, there are a variety of other ways that you can contribute, from reporting issues to testing patches.
endprologue.
h3. Reporting an Issue
-Ruby on Rails uses "GitHub Issue Tracking":https://github.com/rails/rails/issues to track issues (primarily bugs and contributions of new code). If you've found a bug in Ruby on Rails, this is the place to start. You'll need to create a (free) GitHub account in order to either submit an issue, comment on them or create pull requests.
+Ruby on Rails uses "GitHub Issue Tracking":https://github.com/rails/rails/issues to track issues (primarily bugs and contributions of new code). If you've found a bug in Ruby on Rails, this is the place to start. You'll need to create a (free) GitHub account in order to submit an issue, to comment on them or to create pull requests.
NOTE: Bugs in the most recent released version of Ruby on Rails are likely to get the most attention. Also, the Rails core team is always interested in feedback from those who can take the time to test _edge Rails_ (the code for the version of Rails that is currently under development). Later in this guide you'll find out how to get edge Rails for testing.
h4. Creating a Bug Report
-If you've found a problem in Ruby on Rails which is not a security risk do a search in GitHub Issues in case it was already reported. If you find no issue addressing it you can "add a new one":https://github.com/rails/rails/issues/new. (See the next section for reporting security issues.)
+If you've found a problem in Ruby on Rails which is not a security risk, do a search in GitHub under "Issues":https://github.com/rails/rails/issues in case it was already reported. If you find no issue addressing it you can "add a new one":https://github.com/rails/rails/issues/new. (See the next section for reporting security issues.)
-At the minimum, your issue report needs a title and descriptive text. But that's only a minimum. You should include as much relevant information as possible. You need to at least post the code sample that has the issue. Even better is to include a unit test that shows how the expected behavior is not occurring. Your goal should be to make it easy for yourself - and others - to replicate the bug and figure out a fix.
+At the minimum, your issue report needs a title and descriptive text. But that's only a minimum. You should include as much relevant information as possible. You need at least to post the code sample that has the issue. Even better is to include a unit test that shows how the expected behavior is not occurring. Your goal should be to make it easy for yourself -- and others -- to replicate the bug and figure out a fix.
-Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kind of bug, you're creating this issue report in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the issue report will automatically see any activity or that others will jump to fix it. Creating an issue like this is mostly to help yourself start on the path of fixing the problem and for others to confirm it with a "I'm having this problem too" comment.
+Then, don't get your hopes up! Unless you have a "Code Red, Mission Critical, the World is Coming to an End" kind of bug, you're creating this issue report in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the issue report will automatically see any activity or that others will jump to fix it. Creating an issue like this is mostly to help yourself start on the path of fixing the problem and for others to confirm it with an "I'm having this problem too" comment.
h4. Special Treatment for Security Issues
WARNING: Please do not report security vulnerabilities with public GitHub issue reports. The "Rails security policy page":http://rubyonrails.org/security details the procedure to follow for security issues.
-h4. What About Feature Requests?
+h4. What about Feature Requests?
Please don't put "feature request" items into GitHub Issues. If there's a new feature that you want to see added to Ruby on Rails, you'll need to write the code yourself - or convince someone else to partner with you to write the code. Later in this guide you'll find detailed instructions for proposing a patch to Ruby on Rails. If you enter a wishlist item in GitHub Issues with no code, you can expect it to be marked "invalid" as soon as it's reviewed.
@@ -38,7 +38,7 @@ h3. Running the Test Suite
To move on from submitting bugs to helping resolve existing issues or contributing your own code to Ruby on Rails, you _must_ be able to run its test suite. In this section of the guide you'll learn how to set up the tests on your own computer.
-h4. Install git
+h4. Install Git
Ruby on Rails uses git for source code control. The "git homepage":http://git-scm.com/ has installation instructions. There are a variety of resources on the net that will help you get familiar with git:
@@ -66,7 +66,7 @@ Install first libxml2 and libxslt together with their development files for Noko
$ sudo apt-get install libxml2 libxml2-dev libxslt1-dev
</shell>
-Also, SQLite3 and its development files for the +sqlite3-ruby+ gem, in Ubuntu you're done with
+Also, SQLite3 and its development files for the +sqlite3-ruby+ gem -- in Ubuntu you're done with just
<shell>
$ sudo apt-get install sqlite3 libsqlite3-dev
@@ -76,6 +76,7 @@ Get a recent version of "Bundler":http://gembundler.com/:
<shell>
$ gem install bundler
+$ gem update bundler
</shell>
and run:
@@ -84,20 +85,20 @@ and run:
$ bundle install --without db
</shell>
-This command will install all dependencies except the MySQL and PostgreSQL Ruby drivers. We will come back at these soon. With dependencies installed, you can run the test suite with:
+This command will install all dependencies except the MySQL and PostgreSQL Ruby drivers. We will come back to these soon. With dependencies installed, you can run the test suite with:
<shell>
$ bundle exec rake test
</shell>
-You can also run tests for a specific framework, like Action Pack, by going into its directory and executing the same command:
+You can also run tests for a specific component, like Action Pack, by going into its directory and executing the same command:
<shell>
$ cd actionpack
$ bundle exec rake test
</shell>
-If you want to run tests from the specific directory use the +TEST_DIR+ environment variable. For example, this will run tests inside +railties/test/generators+ directory only:
+If you want to run the tests located in a specific directory use the +TEST_DIR+ environment variable. For example, this will run the tests of the +railties/test/generators+ directory only:
<shell>
$ cd railties
@@ -106,9 +107,9 @@ $ TEST_DIR=generators bundle exec rake test
h4. Warnings
-The test suite runs with warnings enabled. Ideally Ruby on Rails should issue no warning, but there may be a few, and also some from third-party libraries. Please ignore (or fix!) them if any, and submit patches that do not issue new warnings.
+The test suite runs with warnings enabled. Ideally, Ruby on Rails should issue no warnings, but there may be a few, as well as some from third-party libraries. Please ignore (or fix!) them, if any, and submit patches that do not issue new warnings.
-As of this writing they are specially noisy with Ruby 1.9. If you are sure about what you are doing and would like to have a more clear output, there's a way to override the flag:
+As of this writing (December, 2010) they are specially noisy with Ruby 1.9. If you are sure about what you are doing and would like to have a more clear output, there's a way to override the flag:
<shell>
$ RUBYOPT=-W0 bundle exec rake test
@@ -116,17 +117,17 @@ $ RUBYOPT=-W0 bundle exec rake test
h4. Testing Active Record
-The test suite of Active Record attempts to run four times, once for SQLite3, once for each of the two MySQL gems (+mysql+ and +mysql2+), and once for PostgreSQL. We are going to see now how to setup the environment for them.
+The test suite of Active Record attempts to run four times: once for SQLite3, once for each of the two MySQL gems (+mysql+ and +mysql2+), and once for PostgreSQL. We are going to see now how to set up the environment for them.
WARNING: If you're working with Active Record code, you _must_ ensure that the tests pass for at least MySQL, PostgreSQL, and SQLite3. Subtle differences between the various adapters have been behind the rejection of many patches that looked OK when tested only against MySQL.
-h5. Set up Database Configuration
+h5. Database Configuration
The Active Record test suite requires a custom config file: +activerecord/test/config.yml+. An example is provided in +activerecord/test/config.example.yml+ which can be copied and used as needed for your environment.
h5. SQLite3
-The gem +sqlite3-ruby+ does not belong to the "db" group indeed, if you followed the instructions above you're ready. This is how you run the Active Record test suite only for SQLite3:
+The gem +sqlite3-ruby+ does not belong to the "db" group. Indeed, if you followed the instructions above you're ready. This is how you run the Active Record test suite only for SQLite3:
<shell>
$ cd activerecord
@@ -167,13 +168,13 @@ $ cd activerecord
$ rake mysql:build_databases
</shell>
-PostgreSQL's authentication works differently. A simple way to setup the development environment for example is to run with your development account
+PostgreSQL's authentication works differently. A simple way to set up the development environment for example is to run with your development account
<shell>
$ sudo -u postgres createuser --superuser $USER
</shell>
-and after that create the test databases with
+and then create the test databases with
<shell>
$ cd activerecord
@@ -182,9 +183,9 @@ $ rake postgresql:build_databases
NOTE: Using the rake task to create the test databases ensures they have the correct character set and collation.
-If you’re using another database, check the files under +activerecord/test/connections+ for default connection information. You can edit these files if you _must_ on your machine to provide different credentials, but obviously you should not push any such changes back to Rails.
+If you’re using another database, check the files under +activerecord/test/connections+ for default connection information. You can edit these files to provide different credentials on your machine if you must, but obviously you should not push any such changes back to Rails.
-You can now run tests as you did for +sqlite3+, the tasks are
+You can now run the tests as you did for +sqlite3+. The tasks are respectively
<shell>
test_mysql
@@ -192,7 +193,7 @@ test_mysql2
test_postgresql
</shell>
-respectively. As we mentioned before
+As we mentioned before
<shell>
$ bundle exec rake test
@@ -200,9 +201,9 @@ $ bundle exec rake test
will now run the four of them in turn.
-You can also invoke +test_jdbcmysql+, +test_jdbcsqlite3+ or +test_jdbcpostgresql+. Check out the file +activerecord/RUNNING_UNIT_TESTS+ for information on running more targeted database tests, or the file +ci/travis.rb+ to see the test suite that the continuous integration server runs.
+You can invoke +test_jdbcmysql+, +test_jdbcsqlite3+ or +test_jdbcpostgresql+ also. See the file +activerecord/RUNNING_UNIT_TESTS+ for information on running more targeted database tests, or the file +ci/travis.rb+ for the test suite run by the continuous integration server.
-h4. Older versions of Ruby on Rails
+h4. Older Versions of Ruby on Rails
If you want to add a fix to older versions of Ruby on Rails, you'll need to set up and switch to your own local tracking branch. Here is an example to switch to the 3-0-stable branch:
@@ -219,9 +220,9 @@ As a next step beyond reporting issues, you can help the core team resolve exist
h4. Verifying Bug Reports
-For starters, it helps to just verify bug reports. Can you reproduce the reported issue on your own computer? If so, you can add a comment to the issue saying that you're seeing the same thing.
+For starters, it helps just to verify bug reports. Can you reproduce the reported issue on your own computer? If so, you can add a comment to the issue saying that you're seeing the same thing.
-If something is very vague, can you help squish it down into something specific? Maybe you can provide additional information to help reproduce a bug, or eliminate needless steps that aren't required to help demonstrate the problem.
+If something is very vague, can you help squash it down into something specific? Maybe you can provide additional information to help reproduce a bug, or help by eliminating needless steps that aren't required to demonstrate the problem.
If you find a bug report without a test, it's very useful to contribute a failing test. This is also a great way to get started exploring the source code: looking at the existing test files will teach you how to write more tests. New tests are best contributed in the form of a patch, as explained later on in the "Contributing to the Rails Code" section.
@@ -229,51 +230,51 @@ Anything you can do to make bug reports more succinct or easier to reproduce is
h4. Testing Patches
-You can also help out by examining pull requests that have been submitted to Ruby on Rails via GitHub. To apply someone's changes you need to first create a dedicated branch:
+You can also help out by examining pull requests that have been submitted to Ruby on Rails via GitHub. To apply someone's changes you need first to create a dedicated branch:
<shell>
$ git checkout -b testing_branch
</shell>
-Then you can use their remote branch to update your codebase. For example, let's say the GitHub user JohnSmith has forked and pushed to the topic branch located at https://github.com/JohnSmith/rails.
+Then you can use their remote branch to update your codebase. For example, let's say the GitHub user JohnSmith has forked and pushed to a topic branch "orange" located at https://github.com/JohnSmith/rails.
<shell>
$ git remote add JohnSmith git://github.com/JohnSmith/rails.git
-$ git pull JohnSmith topic
+$ git pull JohnSmith orange
</shell>
After applying their branch, test it out! Here are some things to think about:
* Does the change actually work?
* Are you happy with the tests? Can you follow what they're testing? Are there any tests missing?
-* Does it have proper documentation coverage? Should documentation elsewhere be updated?
+* Does it have the proper documentation coverage? Should documentation elsewhere be updated?
* Do you like the implementation? Can you think of a nicer or faster way to implement a part of their change?
Once you're happy that the pull request contains a good change, comment on the GitHub issue indicating your approval. Your comment should indicate that you like the change and what you like about it. Something like:
<blockquote>
-I like the way you've restructured that code in generate_finder_sql, much nicer. The tests look good too.
+I like the way you've restructured that code in generate_finder_sql -- much nicer. The tests look good too.
</blockquote>
If your comment simply says "+1", then odds are that other reviewers aren't going to take it too seriously. Show that you took the time to review the pull request.
h3. Contributing to the Rails Documentation
-Ruby on Rails has two main sets of documentation: The guides help you to learn Ruby on Rails, and the API is a reference.
+Ruby on Rails has two main sets of documentation: the guides help you in learning about Ruby on Rails, and the API is a reference.
-You can help improve the Rails guides by making them more coherent, adding missing information, correcting factual errors, fixing typos, bringing it up to date with the latest edge Rails. To get involved in the translation of Rails guides, please see "Translating Rails Guides":https://wiki.github.com/lifo/docrails/translating-rails-guides.
+You can help improve the Rails guides by making them more coherent, consistent or readable, adding missing information, correcting factual errors, fixing typos, or bringing it up to date with the latest edge Rails. To get involved in the translation of Rails guides, please see "Translating Rails Guides":https://wiki.github.com/lifo/docrails/translating-rails-guides.
-If you're confident about your changes, you can push them yourself directly via "docrails":https://github.com/lifo/docrails. docrails is a branch with an *open commit policy* and public write access. Commits to docrails are still reviewed, but that happens after they are pushed. docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
+If you're confident about your changes, you can push them directly yourself via "docrails":https://github.com/lifo/docrails. Docrails is a branch with an *open commit policy* and public write access. Commits to docrails are still reviewed, but this happens after they are pushed. Docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
If you are unsure of the documentation changes, you can create an issue in the "Rails":https://github.com/rails/rails/issues issues tracker on GitHub.
When working with documentation, please take into account the "API Documentation Guidelines":api_documentation_guidelines.html and the "Ruby on Rails Guides Guidelines":ruby_on_rails_guides_guidelines.html.
-NOTE: As explained earlier, ordinary code patches should have proper documentation coverage. docrails is only used for isolated documentation improvements.
+NOTE: As explained earlier, ordinary code patches should have proper documentation coverage. Docrails is only used for isolated documentation improvements.
-NOTE: To help our CI servers you can add [ci skip] tag to your documentation commit message to skip build on that commit. Please remember to use it for commits containing only documentation changes.
+NOTE: To help our CI servers you can add [ci skip] to your documentation commit message to skip build on that commit. Please remember to use it for commits containing only documentation changes.
-WARNING: docrails has a very strict policy: no code can be touched whatsoever, no matter how trivial or small the change. Only RDoc and guides can be edited via docrails. Also, CHANGELOGs should never be edited in docrails.
+WARNING: Docrails has a very strict policy: no code can be touched whatsoever, no matter how trivial or small the change. Only RDoc and guides can be edited via docrails. Also, CHANGELOGs should never be edited in docrails.
h3. Contributing to the Rails Code
@@ -292,37 +293,37 @@ $ cd rails
$ git checkout -b my_new_branch
</shell>
-It doesn’t really matter what name you use, because this branch will only exist on your local computer and your personal repository on Github. It won't be part of the Rails git repository.
+It doesn’t matter much what name you use, because this branch will only exist on your local computer and your personal repository on Github. It won't be part of the Rails git repository.
h4. Write Your Code
Now get busy and add or edit code. You’re on your branch now, so you can write whatever you want (you can check to make sure you’re on the right branch with +git branch -a+). But if you’re planning to submit your change back for inclusion in Rails, keep a few things in mind:
-* Get the code right
-* Use Rails idioms and helpers
-* Include tests that fail without your code, and pass with it
-* Update the documentation, the surrounding one, examples elsewhere, guides, whatever is affected by your contribution
+* Get the code right.
+* Use Rails idioms and helpers.
+* Include tests that fail without your code, and pass with it.
+* Update the (surrounding) documentation, examples elsewhere, and the guides: whatever is affected by your contribution.
h4. Follow the Coding Conventions
Rails follows a simple set of coding style conventions.
-* Two spaces, no tabs.
-* No trailing whitespace. Blank lines should not have any space.
+* Two spaces, no tabs (for indentation).
+* No trailing whitespace. Blank lines should not have any spaces.
* Indent after private/protected.
* Prefer +&amp;&amp;+/+||+ over +and+/+or+.
-* Prefer class << self block over self.method for class methods.
-* +MyClass.my_method(my_arg)+ not +my_method( my_arg )+ or +my_method my_arg+.
-* a = b and not a=b.
-* Follow the conventions you see used in the source already.
+* Prefer class << self over self.method for class methods.
+* Use +MyClass.my_method(my_arg)+ not +my_method( my_arg )+ or +my_method my_arg+.
+* Use a = b and not a=b.
+* Follow the conventions in the source you see used already.
-These are some guidelines and please use your best judgment in using them.
+The above are guidelines -- please use your best judgment in using them.
h4. Sanity Check
You should not be the only person who looks at the code before you submit it. You know at least one other Rails developer, right? Show them what you’re doing and ask for feedback. Doing this in private before you push a patch out publicly is the “smoke test” for a patch: if you can’t convince one other developer of the beauty of your code, you’re unlikely to convince the core team either.
-You might also want to check out the "RailsBridge BugMash":http://wiki.railsbridge.org/projects/railsbridge/wiki/BugMash as a way to get involved in a group effort to improve Rails. This can help you get started and help check your code when you're writing your first patches.
+You might want also to check out the "RailsBridge BugMash":http://wiki.railsbridge.org/projects/railsbridge/wiki/BugMash as a way to get involved in a group effort to improve Rails. This can help you get started and help you check your code when you're writing your first patches.
h4. Commit Your Changes
@@ -332,9 +333,9 @@ When you're happy with the code on your computer, you need to commit the changes
$ git commit -a -m "Here is a commit message on what I changed in this commit"
</shell>
-TIP. Please squash your commits into a single commit when appropriate. This simplifies future cherry picks, and also keeps the git log clean.
+TIP. Please squash your commits into a single commit when appropriate. This simplifies future cherry picks, and also keeps the git log clean.
-h4. Update master
+h4. Update Master
It’s pretty likely that other changes to master have happened while you were working. Go get them:
@@ -372,13 +373,13 @@ h4. Issue a Pull Request
Navigate to the Rails repository you just pushed to (e.g. https://github.com/your-user-name/rails) and press "Pull Request" in the upper right hand corner.
-Write your branch name in branch field (is filled with master by default) and press "Update Commit Range"
+Write your branch name in the branch field (this is filled with "master" by default) and press "Update Commit Range".
-Ensure the changesets you introduced are included in the "Commits" tab and that the "Files Changed" incorporate all of your changes.
+Ensure the changesets you introduced are included in the "Commits" tab. Ensure that the "Files Changed" incorporate all of your changes.
-Fill in some details about your potential patch including a meaningful title. When finished, press "Send pull request." Rails Core will be notified about your submission.
+Fill in some details about your potential patch including a meaningful title. When finished, press "Send pull request". The Rails core team will be notified about your submission.
-h4. Get Some Feedback
+h4. Get some Feedback
Now you need to get other people to look at your patch, just as you've looked at other people's patches. You can use the "rubyonrails-core mailing list":http://groups.google.com/group/rubyonrails-core/ or the #rails-contrib channel on IRC freenode for this. You might also try just talking to Rails developers that you know.
diff --git a/railties/guides/source/credits.html.erb b/guides/source/credits.html.erb
index da6bd6acdf..da6bd6acdf 100644
--- a/railties/guides/source/credits.html.erb
+++ b/guides/source/credits.html.erb
diff --git a/railties/guides/source/debugging_rails_applications.textile b/guides/source/debugging_rails_applications.textile
index 57c7786636..57c7786636 100644
--- a/railties/guides/source/debugging_rails_applications.textile
+++ b/guides/source/debugging_rails_applications.textile
diff --git a/railties/guides/source/documents.yaml b/guides/source/documents.yaml
index 2acdcca39c..2acdcca39c 100644
--- a/railties/guides/source/documents.yaml
+++ b/guides/source/documents.yaml
diff --git a/railties/guides/source/engines.textile b/guides/source/engines.textile
index 6ae9504c23..501d48eab8 100644
--- a/railties/guides/source/engines.textile
+++ b/guides/source/engines.textile
@@ -723,6 +723,21 @@ You can also specify these assets as dependencies of other assets using the Asse
*/
</css>
+h4. Separate Assets & Precompiling
+
+There are some situations where your engine's assets not required by the host application. For example, say that you've created
+an admin functionality that only exists for your engine. In this case, the host application doesn't need to require +admin.css+
+or +admin.js+. Only the gem's admin layout needs these assets. It doesn't make sense for the host app to include +"blorg/admin.css"+ in it's stylesheets. In this situation, you should explicitly define these assets for precompilation.
+This tells sprockets to add you engine assets when +rake assets:precompile+ is ran.
+
+You can define assets for precompilation in +engine.rb+
+
+<ruby>
+initializer do |app|
+ app.config.assets.precompile += %w(admin.css admin.js)
+end
+</ruby
+
For more information, read the "Asset Pipeline guide":http://guides.rubyonrails.org/asset_pipeline.html
h4. Other gem dependencies
diff --git a/railties/guides/source/form_helpers.textile b/guides/source/form_helpers.textile
index 8934667c5e..8934667c5e 100644
--- a/railties/guides/source/form_helpers.textile
+++ b/guides/source/form_helpers.textile
diff --git a/railties/guides/source/generators.textile b/guides/source/generators.textile
index 920ff997ae..920ff997ae 100644
--- a/railties/guides/source/generators.textile
+++ b/guides/source/generators.textile
diff --git a/railties/guides/source/getting_started.textile b/guides/source/getting_started.textile
index 3a84b69fc3..0a85c84155 100644
--- a/railties/guides/source/getting_started.textile
+++ b/guides/source/getting_started.textile
@@ -13,6 +13,8 @@ endprologue.
WARNING. This Guide is based on Rails 3.1. Some of the code shown here will not
work in earlier versions of Rails.
+WARNING: The Edge version of this guide is currently being re-worked. Please excuse us while we re-arrange the place.
+
h3. Guide Assumptions
This guide is designed for beginners who want to get started with a Rails
@@ -61,157 +63,17 @@ tremendous increase in productivity. If you persist in bringing old habits from
other languages to your Rails development, and trying to use patterns you
learned elsewhere, you may have a less happy experience.
-The Rails philosophy includes several guiding principles:
+The Rails philosophy includes two major guiding principles:
* DRY - "Don't Repeat Yourself" - suggests that writing the same code over and over again is a bad thing.
* Convention Over Configuration - means that Rails makes assumptions about what you want to do and how you're going to
do it, rather than requiring you to specify every little thing through endless configuration files.
-* REST is the best pattern for web applications - organizing your application around resources and standard HTTP verbs
-is the fastest way to go.
-
-h4. The MVC Architecture
-
-At the core of Rails is the Model, View, Controller architecture, usually just
-called MVC. MVC benefits include:
-
-* Isolation of business logic from the user interface
-* Ease of keeping code DRY
-* Making it clear where different types of code belong for easier maintenance
-
-h5. Models
-
-A model represents the information (data) of the application and the rules to
-manipulate that data. In the case of Rails, models are primarily used for
-managing the rules of interaction with a corresponding database table. In most
-cases, each table in your database will correspond to one model in your
-application. The bulk of your application's business logic will be concentrated
-in the models.
-
-h5. Views
-
-Views represent the user interface of your application. In Rails, views are
-often HTML files with embedded Ruby code that perform tasks related solely to
-the presentation of the data. Views handle the job of providing data to the web
-browser or other tool that is used to make requests from your application.
-
-h5. Controllers
-
-Controllers provide the "glue" between models and views. In Rails, controllers
-are responsible for processing the incoming requests from the web browser,
-interrogating the models for data, and passing that data on to the views for
-presentation.
-
-h4. The Components of Rails
-
-Rails ships as many individual components. Each of these components are briefly
-explained below. If you are new to Rails, as you read this section, don't get
-hung up on the details of each component, as they will be explained in further
-detail later. For instance, we will bring up Rack applications, but you don't
-need to know anything about them to continue with this guide.
-
-* Action Pack
- ** Action Controller
- ** Action Dispatch
- ** Action View
-* Action Mailer
-* Active Model
-* Active Record
-* Active Support
-* Railties
-
-h5. Action Pack
-
-Action Pack is a single gem that contains Action Controller, Action View and
-Action Dispatch. The "VC" part of "MVC".
-
-h6. Action Controller
-
-Action Controller is the component that manages the controllers in a Rails
-application. The Action Controller framework processes incoming requests to a
-Rails application, extracts parameters, and dispatches them to the intended
-action. Services provided by Action Controller include session management,
-template rendering, and redirect management.
-
-h6. Action View
-
-Action View manages the views of your Rails application. It can create both HTML
-and XML output by default. Action View manages rendering templates, including
-nested and partial templates, and includes built-in AJAX support. View
-templates are covered in more detail in another guide called "Layouts and
-Rendering":layouts_and_rendering.html.
-
-h6. Action Dispatch
-
-Action Dispatch handles routing of web requests and dispatches them as you want,
-either to your application or any other Rack application. Rack applications are
-a more advanced topic and are covered in a separate guide called "Rails on
-Rack":rails_on_rack.html.
-
-h5. Action Mailer
-
-Action Mailer is a framework for building e-mail services. You can use Action
-Mailer to receive and process incoming email and send simple plain text or
-complex multipart emails based on flexible templates.
-
-h5. Active Model
-
-Active Model provides a defined interface between the Action Pack gem services
-and Object Relationship Mapping gems such as Active Record. Active Model allows
-Rails to utilize other ORM frameworks in place of Active Record if your
-application needs this.
-
-h5. Active Record
-
-Active Record is the base for the models in a Rails application. It provides
-database independence, basic CRUD functionality, advanced finding capabilities,
-and the ability to relate models to one another, among other services.
-
-h5. Active Support
-
-Active Support is an extensive collection of utility classes and standard Ruby
-library extensions that are used in Rails, both by the core code and by your
-applications.
-
-h5. Railties
-
-Railties is the core Rails code that builds new Rails applications and glues the
-various frameworks and plugins together in any Rails application.
-
-h4. REST
-
-Rest stands for Representational State Transfer and is the foundation of the
-RESTful architecture. This is generally considered to be Roy Fielding's doctoral
-thesis, "Architectural Styles and the Design of Network-based Software
-Architectures":http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm. While
-you can read through the thesis, REST in terms of Rails boils down to two main
-principles:
-
-* Using resource identifiers such as URLs to represent resources.
-* Transferring representations of the state of that resource between system components.
-
-For example, the following HTTP request:
-
-<tt>DELETE /photos/17</tt>
-
-would be understood to refer to a photo resource with the ID of 17, and to
-indicate a desired action - deleting that resource. REST is a natural style for
-the architecture of web applications, and Rails hooks into this shielding you
-from many of the RESTful complexities and browser quirks.
-
-If you'd like more details on REST as an architectural style, these resources
-are more approachable than Fielding's thesis:
-
-* "A Brief Introduction to REST":http://www.infoq.com/articles/rest-introduction by Stefan Tilkov
-* "An Introduction to REST":http://bitworking.org/news/373/An-Introduction-to-REST (video tutorial) by Joe Gregorio
-* "Representational State Transfer":http://en.wikipedia.org/wiki/Representational_State_Transfer article in Wikipedia
-* "How to GET a Cup of Coffee":http://www.infoq.com/articles/webber-rest-workflow by Jim Webber, Savas Parastatidis &
-Ian Robinson
h3. Creating a New Rails Project
The best way to use this guide is to follow each step as it happens, no code or
step needed to make this example application has been left out, so you can
-literally follow along step by step. You can get the complete code "here":https://github.com/lifo/docrails/tree/master/railties/guides/code/getting_started.
+literally follow along step by step. You can get the complete code "here":https://github.com/lifo/docrails/tree/master/guides/code/getting_started.
By following along with this guide, you'll create a Rails project called <tt>blog</tt>, a
(very) simple weblog. Before you can start building the application, you need to
@@ -221,29 +83,27 @@ TIP: The examples below use # and $ to denote terminal prompts. If you are using
h4. Installing Rails
-In most cases, the easiest way to install Rails is to take advantage of RubyGems:
+To install Rails, use the +gem install+ command provided by RubyGems:
<shell>
-Usually run this as the root user:
# gem install rails
</shell>
-TIP. If you're working on Windows, you can quickly install Ruby and Rails with
-"Rails Installer":http://railsinstaller.org.
+TIP. If you're working on Windows, you can quickly install Ruby and Rails with "Rails Installer":http://railsinstaller.org.
-To verify that you have everything installed correctly, you should be able to run
-the following:
+To verify that you have everything installed correctly, you should be able to run the following:
<shell>
$ rails --version
</shell>
-If it says something like "Rails 3.1.3" you are ready to continue.
+If it says something like "Rails 3.2.2" you are ready to continue.
h4. Creating the Blog Application
-To begin, open a terminal, navigate to a folder where you have rights to create
-files, and type:
+Rails comes with a number of generators that are designed to make your development life easier. One of these is the new application generator, which will provide you with the foundation of a Rails application so that you don't have to write it yourself.
+
+To use this generator, open a terminal, navigate to a directory where you have rights to create files, and type:
<shell>
$ rails new blog
@@ -251,22 +111,15 @@ $ rails new blog
This will create a Rails application called Blog in a directory called blog.
-TIP: You can see all of the switches that the Rails application builder accepts
-by running
-<tt>rails new -h</tt>.
+TIP: You can see all of the switches that the Rails application builder accepts by running <tt>rails new -h</tt>.
-After you create the blog application, switch to its folder to continue work
-directly in that application:
+After you create the blog application, switch to its folder to continue work directly in that application:
<shell>
$ cd blog
</shell>
-The 'rails new blog' command we ran above created a folder in your working directory
-called <tt>blog</tt>. The <tt>blog</tt> folder has a number of auto-generated folders
-that make up the structure of a Rails application. Most of the work in
-this tutorial will happen in the <tt>app/</tt> folder, but here's a basic
-rundown on the function of each of the files and folders that Rails created by default:
+The +rails new blog+ command we ran above created a folder in your working directory called <tt>blog</tt>. The <tt>blog</tt> directory has a number of auto-generated folders that make up the structure of a Rails application. Most of the work in this tutorial will happen in the <tt>app/</tt> folder, but here's a basic rundown on the function of each of the files and folders that Rails created by default:
|_.File/Folder|_.Purpose|
|app/|Contains the controllers, models, views and assets for your application. You'll focus on this folder for the remainder of this guide.|
@@ -274,7 +127,7 @@ rundown on the function of each of the files and folders that Rails created by d
|config.ru|Rack configuration for Rack based servers used to start the application.|
|db/|Contains your current database schema, as well as the database migrations.|
|doc/|In-depth documentation for your application.|
-|Gemfile<BR />Gemfile.lock|These files allow you to specify what gem dependencies are needed for your Rails application.|
+|Gemfile<BR />Gemfile.lock|These files allow you to specify what gem dependencies are needed for your Rails application. These files are used by the Bundler gem. For more information about Bundler, see "the Bundler website":http://gembundler.com |
|lib/|Extended modules for your application.|
|log/|Application log files.|
|public/|The only folder seen to the world as-is. Contains the static files and compiled assets.|
@@ -285,203 +138,45 @@ rundown on the function of each of the files and folders that Rails created by d
|tmp/|Temporary files|
|vendor/|A place for all third-party code. In a typical Rails application, this includes Ruby Gems and the Rails source code (if you optionally install it into your project).|
-h4. Configuring a Database
-
-Just about every Rails application will interact with a database. The database
-to use is specified in a configuration file, +config/database.yml+. If you open
-this file in a new Rails application, you'll see a default database
-configured to use SQLite3. The file contains sections for three different
-environments in which Rails can run by default:
-
-* The +development+ environment is used on your development/local computer as you interact
-manually with the application.
-* The +test+ environment is used when running automated tests.
-* The +production+ environment is used when you deploy your application for the world to use.
-
-TIP: You don't have to update the database configurations manually. If you look at the
-options of the application generator, you will see that one of the options
-is named <tt>--database</tt>. This option allows you to choose an adapter from a
-list of the most used relational databases. You can even run the generator
-repeatedly: <tt>cd .. && rails new blog --database=mysql</tt>. When you confirm the overwriting
- of the +config/database.yml+ file, your application will be configured for MySQL
-instead of SQLite. Detailed examples of the common database connections are below.
-
-h5. Configuring an SQLite3 Database
-
-Rails comes with built-in support for "SQLite3":http://www.sqlite.org, which is
-a lightweight serverless database application. While a busy production
-environment may overload SQLite, it works well for development and testing.
-Rails defaults to using an SQLite database when creating a new project, but you
-can always change it later.
-
-Here's the section of the default configuration file
-(<tt>config/database.yml</tt>) with connection information for the development
-environment:
-
-<yaml>
-development:
- adapter: sqlite3
- database: db/development.sqlite3
- pool: 5
- timeout: 5000
-</yaml>
-
-NOTE: In this guide we are using an SQLite3 database for data storage, because
-it is a zero configuration database that just works. Rails also supports MySQL
-and PostgreSQL "out of the box", and has plugins for many database systems. If
-you are using a database in a production environment Rails most likely has an
-adapter for it.
-
-h5. Configuring a MySQL Database
-
-If you choose to use MySQL instead of the shipped SQLite3 database, your
-+config/database.yml+ will look a little different. Here's the development
-section:
-
-<yaml>
-development:
- adapter: mysql2
- encoding: utf8
- database: blog_development
- pool: 5
- username: root
- password:
- socket: /tmp/mysql.sock
-</yaml>
-
-If your development computer's MySQL installation includes a root user with an
-empty password, this configuration should work for you. Otherwise, change the
-username and password in the +development+ section as appropriate.
-
-h5. Configuring a PostgreSQL Database
-
-If you choose to use PostgreSQL, your +config/database.yml+ will be customized
-to use PostgreSQL databases:
-
-<yaml>
-development:
- adapter: postgresql
- encoding: unicode
- database: blog_development
- pool: 5
- username: blog
- password:
-</yaml>
-
-h5. Configuring an SQLite3 Database for JRuby Platform
-
-If you choose to use SQLite3 and are using JRuby, your +config/database.yml+ will
-look a little different. Here's the development section:
-
-<yaml>
-development:
- adapter: jdbcsqlite3
- database: db/development.sqlite3
-</yaml>
-
-h5. Configuring a MySQL Database for JRuby Platform
-
-If you choose to use MySQL and are using JRuby, your +config/database.yml+ will look
-a little different. Here's the development section:
-
-<yaml>
-development:
- adapter: jdbcmysql
- database: blog_development
- username: root
- password:
-</yaml>
-
-h5. Configuring a PostgreSQL Database for JRuby Platform
-
-Finally if you choose to use PostgreSQL and are using JRuby, your
-+config/database.yml+ will look a little different. Here's the development
-section:
-
-<yaml>
-development:
- adapter: jdbcpostgresql
- encoding: unicode
- database: blog_development
- username: blog
- password:
-</yaml>
-
-Change the username and password in the +development+ section as appropriate.
-
-h4. Creating the Database
-
-Now that you have your database configured, it's time to have Rails create an
-empty database for you. You can do this by running a rake command:
-
-<shell>
-$ rake db:create
-</shell>
-
-This will create your development and test SQLite3 databases inside the
-<tt>db/</tt> folder.
-
-TIP: Rake is a general-purpose command-runner that Rails uses for many things.
-You can see the list of available rake commands in your application by running
-+rake -T+.
-
h3. Hello, Rails!
-One of the traditional places to start with a new language is by getting some
-text up on screen quickly. To do this, you need to get your Rails application
-server running.
+One of the traditional places to start with a new language is by getting some text up on screen quickly. To do this, you need to get your Rails application server running.
h4. Starting up the Web Server
-You actually have a functional Rails application already. To see it, you need to
-start a web server on your development machine. You can do this by running:
+You actually have a functional Rails application already. To see it, you need to start a web server on your development machine. You can do this by running:
<shell>
$ rails server
</shell>
-TIP: Compiling CoffeeScript to JavaScript requires a JavaScript runtime and
-the absence of a runtime will give you an +execjs+ error. Usually Mac OS X
-and Windows come with a JavaScript runtime installed. Rails adds the +therubyracer+ gem
-to Gemfile in a commented line for new apps and you can uncomment if you need it.
-+therubyrhino+ is the recommended runtime for JRuby users and is added by default
-to Gemfile in apps generated under JRuby. You can investigate about all the
-supported runtimes at "ExecJS":https://github.com/sstephenson/execjs#readme.
+TIP: Compiling CoffeeScript to JavaScript requires a JavaScript runtime and the absence of a runtime will give you an +execjs+ error. Usually Mac OS X and Windows come with a JavaScript runtime installed. Rails adds the +therubyracer+ gem to Gemfile in a commented line for new apps and you can uncomment if you need it. +therubyrhino+ is the recommended runtime for JRuby users and is added by default to Gemfile in apps generated under JRuby. You can investigate about all the supported runtimes at "ExecJS":https://github.com/sstephenson/execjs#readme.
-This will fire up an instance of the WEBrick web server by default (Rails can
-also use several other web servers). To see your application in action, open a
-browser window and navigate to "http://localhost:3000":http://localhost:3000.
-You should see Rails' default information page:
+This will fire up an instance of a webserver built into Ruby called WEBrick by default. To see your application in action, open a browser window and navigate to "http://localhost:3000":http://localhost:3000. You should see Rails' default information page:
!images/rails_welcome.png(Welcome Aboard screenshot)!
-TIP: To stop the web server, hit Ctrl+C in the terminal window where it's
-running. In development mode, Rails does not generally require you to stop the
-server; changes you make in files will be automatically picked up by the server.
+TIP: To stop the web server, hit Ctrl+C in the terminal window where it's running. In development mode, Rails does not generally require you to stop the server; changes you make in files will be automatically picked up by the server.
-The "Welcome Aboard" page is the _smoke test_ for a new Rails application: it
-makes sure that you have your software configured correctly enough to serve a
-page. You can also click on the _About your application’s environment_ link to
-see a summary of your application's environment.
+The "Welcome Aboard" page is the _smoke test_ for a new Rails application: it makes sure that you have your software configured correctly enough to serve a page. You can also click on the _About your application’s environment_ link to see a summary of your application's environment.
h4. Say "Hello", Rails
-To get Rails saying "Hello", you need to create at minimum a controller and a
-view. Fortunately, you can do that in a single command. Enter this command in
-your terminal:
+To get Rails saying "Hello", you need to create at minimum a _controller_ and a _view_.
+
+A controller's purpose is to receive specific requests for the application. What controller receives what request is determined by the _routing_. There is very often more than one route to each controller, and different routes can be served by different _actions_. Each action's purpose is to collect information to provide it to a view.
+
+A view's purpose is to display this information in a human readable format. An important distinction to make is that it is the _controller_, not the view, where information is collected. The view should just display that information. By default, view templates are written in a language called ERB (Embedded Ruby) which is converted by the request cycle in Rails before being sent to the user.
+
+To create a new controller, you will need to run the "controller" generator and tell it you want a controller called "welcome" with an action called "index", just like this:
<shell>
-$ rails generate controller home index
+$ rails generate controller welcome index
</shell>
-TIP: If you get a command not found error when running this command, you
-need to explicitly pass Rails +rails+ commands to Ruby: <tt>ruby
-\path\to\your\application\script\rails generate controller home index</tt>.
+Rails will create several files for you. Most important of these are of course the controller, located at +app/controllers/welcome_controller.rb+ and the view, located at +app/views/welcome/index.html.erb+.
-Rails will create several files for you, including
-+app/views/home/index.html.erb+. This is the template that will be used to
-display the results of the +index+ action (method) in the +home+ controller.
-Open this file in your text editor and edit it to contain a single line of code:
+Open the +app/views/welcome/index.html.erb+ file in your text editor and edit it to contain a single line of code:
<code class="html">
<h1>Hello, Rails!</h1>
@@ -489,29 +184,15 @@ Open this file in your text editor and edit it to contain a single line of code:
h4. Setting the Application Home Page
-Now that we have made the controller and view, we need to tell Rails when we
-want "Hello Rails!" to show up. In our case, we want it to show up when we
-navigate to the root URL of our site,
-"http://localhost:3000":http://localhost:3000, instead of the "Welcome Aboard"
-smoke test.
+Now that we have made the controller and view, we need to tell Rails when we want "Hello Rails!" to show up. In our case, we want it to show up when we navigate to the root URL of our site, "http://localhost:3000":http://localhost:3000. At the moment, however, the "Welcome Aboard" smoke test is occupying that spot.
-The first step to doing this is to delete the default page from your
-application:
+To fix this, delete the +index.html+ file located inside the +public+ directory of the application.
-<shell>
-$ rm public/index.html
-</shell>
+You need to do this because Rails will serve any static file in the +public+ directory that matches a route in preference to any dynamic content you generate from the controllers.
-We need to do this as Rails will deliver any static file in the +public+
-directory in preference to any dynamic content we generate from the controllers.
+Next, you have to tell Rails where your actual home page is located.
-Now, you have to tell Rails where your actual home page is located. Open the
-file +config/routes.rb+ in your editor. This is your application's _routing
-file_ which holds entries in a special DSL (domain-specific language) that tells
-Rails how to connect incoming requests to controllers and actions. This file
-contains many sample routes on commented lines, and one of them actually shows
-you how to connect the root of your site to a specific controller and action.
-Find the line beginning with +root :to+ and uncomment it. It should look something like the following:
+Open the file +config/routes.rb+ in your editor. This is your application's _routing file_ which holds entries in a special DSL (domain-specific language) that tells Rails how to connect incoming requests to controllers and actions. This file contains many sample routes on commented lines, and one of them actually shows you how to connect the root of your site to a specific controller and action. Find the line beginning with +root :to+ and uncomment it. It should look something like the following:
<ruby>
Blog::Application.routes.draw do
@@ -519,64 +200,190 @@ Blog::Application.routes.draw do
#...
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
- root :to => "home#index"
+ root :to => "welcome#index"
</ruby>
-The +root :to => "home#index"+ tells Rails to map the root action to the home
-controller's index action.
+The +root :to => "welcome#index"+ tells Rails to map requests to the root of the application to the welcome controller's index action. This was created earlier when you ran the controller generator (+rails generate controller welcome index+).
+
+If you navigate to "http://localhost:3000":http://localhost:3000 in your browser, you'll see +Hello, Rails!+.
+
+NOTE. For more information about routing, refer to "Rails Routing from the Outside In":routing.html.
+
+h3. Getting Up and Running
+
+Now that you've seen how to create a controller, an action and a view, let's create something with a bit more substance.
+
+In the Blog application, you will now create a new _resource_. A resource is the term used for a collection of similar objects, such as posts, people or animals. You can create, read, update and destroy items for a resource and these operations are referred to as _CRUD_ operations.
+
+In the next section, you will add the ability to create new posts in your application and be able to view them. This is the "CR" from CRUD. The form for doing this will look like this:
-Now if you navigate to "http://localhost:3000":http://localhost:3000 in your
-browser, you'll see +Hello, Rails!+.
+!images/getting_started/new_post.png(The new post form)!
-NOTE. For more information about routing, refer to "Rails Routing from the
-Outside In":routing.html.
+It will look a little basic for now, but that's ok. We'll look at improving the styling for it afterwards.
-h3. Getting Up and Running Quickly with Scaffolding
+h4. Laying down the ground work
-Rails _scaffolding_ is a quick way to generate some of the major pieces of an
-application. If you want to create the models, views, and controllers for a new
-resource in a single operation, scaffolding is the tool for the job.
+The first thing that you are going to need to create a new post within the application is a place to do that. A great place for that would be at +/posts/new+. If you attempt to navigate to that now -- by visiting "http://localhost:3000/posts/new":http://localhost:3000/posts/new -- Rails will give you a routing error:
-h3. Creating a Resource
-In the case of the blog application, you can start by generating a scaffold for the
-Post resource: this will represent a single blog posting. To do this, enter this
-command in your terminal:
+!images/getting_started/routing_error_no_route_matches.png(A routing error, no route matches /posts/new)!
+
+This is because there is nowhere inside the routes for the application -- defined inside +config/routes.rb+ -- that defines this route. By default, Rails has no routes configured at all, and so you must define your routes as you need them.
+
+ To do this, you're going to need to create a route inside +config/routes.rb+ file, on a new line between the +do+ and the +end+ for the +draw+ method:
+
+<ruby>
+get "posts/new"
+</ruby>
+
+This route is a super-simple route: it defines a new route that only responds to +GET+ requests, and that the route is at +posts/new+. But how does it know where to go without the use of the +:to+ option? Well, Rails uses a sensible default here: Rails will assume that you want this route to go to the new action inside the posts controller.
+
+With the route defined, requests can now be made to +/posts/new+ in the application. Navigate to "http://localhost:3000/posts/new":http://localhost:3000/posts/new and you'll see another routing error:
+
+!images/getting_started/routing_error_no_controller.png(Another routing error, uninitialized constant PostsController)
+
+This error is happening because this route need a controller to be defined. The route is attempting to find that controller so it can serve the request, but with the controller undefined, it just can't do that. The solution to this particular problem is simple: you need to create a controller called +PostsController+. You can do this by running this command:
<shell>
-$ rails generate scaffold Post name:string title:string content:text
+$ rails g controller posts
</shell>
-The scaffold generator will build several files in your application, along with some
-folders, and edit <tt>config/routes.rb</tt>. Here's a quick overview of what it creates:
+If you open up the newly generated +app/controllers/posts_controller.rb+ you'll see a fairly empty controller:
-|_.File |_.Purpose|
-|db/migrate/20100207214725_create_posts.rb |Migration to create the posts table in your database (your name will include a different timestamp)|
-|app/models/post.rb |The Post model|
-|test/unit/post_test.rb |Unit testing harness for the posts model|
-|test/fixtures/posts.yml |Sample posts for use in testing|
-|config/routes.rb |Edited to include routing information for posts|
-|app/controllers/posts_controller.rb |The Posts controller|
-|app/views/posts/index.html.erb |A view to display an index of all posts |
-|app/views/posts/edit.html.erb |A view to edit an existing post|
-|app/views/posts/show.html.erb |A view to display a single post|
-|app/views/posts/new.html.erb |A view to create a new post|
-|app/views/posts/_form.html.erb |A partial to control the overall look and feel of the form used in edit and new views|
-|test/functional/posts_controller_test.rb |Functional testing harness for the posts controller|
-|app/helpers/posts_helper.rb |Helper functions to be used from the post views|
-|test/unit/helpers/posts_helper_test.rb |Unit testing harness for the posts helper|
-|app/assets/javascripts/posts.js.coffee |CoffeeScript for the posts controller|
-|app/assets/stylesheets/posts.css.scss |Cascading style sheet for the posts controller|
-|app/assets/stylesheets/scaffolds.css.scss |Cascading style sheet to make the scaffolded views look better|
-
-NOTE. While scaffolding will get you up and running quickly, the code it
-generates is unlikely to be a perfect fit for your application. You'll most
-probably want to customize the generated code. Many experienced Rails developers
-avoid scaffolding entirely, preferring to write all or most of their source code
-from scratch. Rails, however, makes it really simple to customize templates for
-generated models, controllers, views and other source files. You'll find more
-information in the "Creating and Customizing Rails Generators &
-Templates":generators.html guide.
+<ruby>
+class PostsController < ApplicationController
+end
+</ruby>
+
+A controller is simply a class that is defined to inherit from +ApplicationController+. It's inside this class that you'll define methods that will become the actions for this controller. These actions will perform CRUD operations on the posts within our system.
+
+If you refresh "http://localhost:3000/posts/new":http://localhost:3000/posts/new now, you'll get a new error:
+
+!images/getting_started/unknown_action_new_for_posts.png(Unknown action new for PostsController!)
+
+This error indicates that Rails cannot find the +new+ action inside the +PostsController+ that you just generated. This is because when controllers are generated in Rails they are empty by default, unless you tell it you wanted actions during the generation process.
+
+To manually define an action inside a controller, all you need to do is to define a new method inside the controller. Open +app/controllers/posts_controller.rb+ and inside the +PostsController+ class, define a +new+ method like this:
+
+<ruby>
+def new
+end
+</ruby>
+
+With the +new+ method defined in +PostsController+, if you refresh "http://localhost:3000/posts/new":http://localhost:3000/posts/new you'll see another error:
+
+!images/getting_started/template_is_missing_posts_new.png(Template is missing for posts/new)
+
+You're getting this error now because Rails expects plain actions like this one to have views associated with them to display their information. With no view available, Rails errors out.
+
+In the above image, the bottom line has been truncated. Let's see what the full thing looks like:
+
+<text>
+Missing template posts/new, application/new with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "/path/to/blog/app/views"
+</text>
+
+That's quite a lot of text! Let's quickly go through and understand what each part of it does.
+
+The first part identifies what template is missing. In this case, it's the +posts/new+ template. Rails will first look for this template. If it can't find it, then it will attempt to load a template called +application/new+. It looks for one here because the +PostsController+ inherits from +ApplicationController+.
+
+The next part of the message contains a hash. The +:locale+ key in this hash simply indicates what spoken language template should be retrieved. By default, this is the English -- or "en" -- template. The next key, +:formats+ shows what formats of template Rails is after. The default is +:html+, and so Rails is looking for an HTML template. The final key, +:handlers+, is telling us what _template handlers_ could be used to render our template. +:erb+ is most commonly used for HTML templates, +:builder+ is used for XML templates, and +:coffee+ uses CoffeeScript to build JavaScript templates.
+
+The final part of this message tells us where Rails has looked for the templates. Templates within a basic Rails application like this are kept in a single location, but in more complex applications it could be many different paths.
+
+The simplest template that would work in this case would be one located at +app/views/posts/new.html.erb+. The extension of this file name is key: the first extension is the _format_ of the template, and the second extension is the _handler_ that will be used. Rails is attempting to find a template called +posts/new+ within +app/views+ for the application. The format for this template can only be +html+ and the handler must be one of +erb+, +builder+ or +coffee+. Because you want to create a new HTML form, you will be using the +ERB+ language. Therefore the file should be called +posts/new.html.erb+ and be located inside the +app/views+ directory of the application.
+
+Go ahead now and create a new file at +app/views/posts/new.html.erb+ and write this content in it:
+
+<erb>
+<h1>New Post</h1>
+</erb>
+
+When you refresh "http://localhost:3000/posts/new":http://localhost:3000/posts/new you'll now see that the page has a title. The route, controller, action and view are now working harmoniously! It's time to create the form for a new post.
+
+h4. The first form
+
+To create a form within this template, you will use a _form builder_. The primary form builder for Rails is provided by a helper method called +form_for+. To use this method, write this code into +app/views/posts/new.html.erb+:
+
+<erb>
+<%= form_for :post do |f| %>
+ <p>
+ <%= f.label :title %><br>
+ <%= f.text_field :title %>
+ </p>
+
+ <p>
+ <%= f.label :text %><br>
+ <%= f.text_area :text %>
+ </p>
+
+ <p>
+ <%= f.submit %>
+ </p>
+<% end %>
+</erb>
+
+If you refresh the page now, you'll see the exact same form as in the example. Building forms in Rails is really just that easy!
+
+When you call +form_for+, you pass it an identifying object for this form. In this case, it's the symbol +:post+. This tells the +form_for+ helper what this form is for. Inside the block for this method, the FormBuilder object -- represented by +f+ -- is used to build two labels and two text fields, one each for the title and text of a post. Finally, a call to +submit+ on the +f+ object will create a submit button for the form.
+
+There's one problem with this form though. If you inspect the HTML that is generated, by viewing the source of the page, you will see that the +action+ attribute for the form is pointing at +/posts/new+. This is a problem because this route goes to the very page that you're on right at the moment, and that route should only be used to display the form for a new post.
+
+So the form needs to use a different URL in order to go somewhere else. This can be done quite simply with the +:url+ option of +form_for+. Typically in Rails, the action that is used for new form submissions like this is called "create", and so the form should be pointed to this action.
+
+Edit the +form_for+ line inside +app/views/posts/new.html.erb+ to look like this:
+
+<erb>
+<%= form_for :post, :url => { :action => :create } do |f| %>
+</erb>
+
+In this example, a +Hash+ object is passed to the +:url+ option. What Rails will do with this is that it will point the form to the +create+ action of the current controller, the +PostsController+, and will send a +POST+ request to that route. For this to work, you will need to add a route to +config/routes.rb+, right underneath the one for "posts/new":
+
+<ruby>
+post "posts/create"
+</ruby>
+
+By using the +post+ method rather than the +get+ method, Rails will define a route that will only respond to POST methods. The POST method is the typical method used by forms all over the web.
+
+With the form and the route for it defined now, you will be able to fill in the form and then click the submit button to begin the process of creating a new post, so go ahead and do that. When you submit the form, you should see a familiar error:
+
+!images/getting_started/unknown_action_create_for_posts(Unknown action create for PostsController)!
+
+You will now need to create the +create+ action within the +PostsController+ for this to work.
+
+h4. Creating posts
+
+To make the "Unknown action" go away, you can define a +create+ action within the +PostsController+ class in +app/controllers/posts_controller.rb+, underneath the +new+ action:
+
+<ruby>
+class PostsController < ApplicationController
+ def new
+ end
+
+ def create
+ end
+
+end
+</ruby>
+
+If you re-submit the form now, you'll see another familiar error: a template is missing. That's ok, we can ignore that for now. What the +create+ action should be doing is saving our new post to a database.
+
+When a form is submitted, the fields of the form are sent to Rails as _parameters_. These parameters can then be referenced inside the controller actions, typically to perform a particular task. To see what these parameters look like, change the +create+ action to this:
+
+<ruby>
+def create
+ render :text => params[:post].inspect
+end
+</ruby>
+
+The +render+ method here is taking a very simple hash with the key of +text+ and the value of +params[:post].inspect+. The +params+ method here is the object which represents the parameters (or fields) coming in from the form. The +params+ method returns a +HashWithIndifferentAccess+ object, which allows you to access the keys of the hash using either strings or symbols. In this situation, the only parameters that matter are the ones from the form.
+
+If you re-submit the form one more time you'll now no longer get the missing template error. Instead, you'll see something that looks like the following:
+
+<ruby>
+{"title"=>"First post!", "text"=>"This is my first post."}
+</ruby>
+
+This action is now displaying the parameters for the post that are coming in from the form. However, this isn't really all that helpful. Yes, you can see the parameters but nothing in particular is being done with them.
h4. Running a Migration
@@ -638,7 +445,7 @@ invoking the command: <tt>rake db:migrate RAILS_ENV=production</tt>.
h4. Adding a Link
To hook the posts up to the home page you've already created, you can add a link
-to the home page. Open +app/views/home/index.html.erb+ and modify it as follows:
+to the home page. Open +app/views/welcome/index.html.erb+ and modify it as follows:
<ruby>
<h1>Hello, Rails!</h1>
@@ -1225,7 +1032,7 @@ Associations":association_basics.html guide.
h4. Adding a Route for Comments
-As with the +home+ controller, we will need to add a route so that Rails knows
+As with the +welcome+ controller, we will need to add a route so that Rails knows
where we would like to navigate to see +comments+. Open up the
+config/routes.rb+ file again. Near the top, you will see the entry for +posts+
that was added automatically by the scaffold generator: <tt>resources
diff --git a/railties/guides/source/i18n.textile b/guides/source/i18n.textile
index 320f1e9d20..320f1e9d20 100644
--- a/railties/guides/source/i18n.textile
+++ b/guides/source/i18n.textile
diff --git a/railties/guides/source/index.html.erb b/guides/source/index.html.erb
index 5439459b42..5439459b42 100644
--- a/railties/guides/source/index.html.erb
+++ b/guides/source/index.html.erb
diff --git a/railties/guides/source/initialization.textile b/guides/source/initialization.textile
index 69e5c1edcc..69e5c1edcc 100644
--- a/railties/guides/source/initialization.textile
+++ b/guides/source/initialization.textile
diff --git a/railties/guides/source/kindle/KINDLE.md b/guides/source/kindle/KINDLE.md
index a7d9a4e4cf..a7d9a4e4cf 100644
--- a/railties/guides/source/kindle/KINDLE.md
+++ b/guides/source/kindle/KINDLE.md
diff --git a/railties/guides/source/kindle/copyright.html.erb b/guides/source/kindle/copyright.html.erb
index bd51d87383..bd51d87383 100644
--- a/railties/guides/source/kindle/copyright.html.erb
+++ b/guides/source/kindle/copyright.html.erb
diff --git a/railties/guides/source/kindle/layout.html.erb b/guides/source/kindle/layout.html.erb
index f0a286210b..f0a286210b 100644
--- a/railties/guides/source/kindle/layout.html.erb
+++ b/guides/source/kindle/layout.html.erb
diff --git a/railties/guides/source/kindle/rails_guides.opf.erb b/guides/source/kindle/rails_guides.opf.erb
index 4e07664fd0..4e07664fd0 100644
--- a/railties/guides/source/kindle/rails_guides.opf.erb
+++ b/guides/source/kindle/rails_guides.opf.erb
diff --git a/railties/guides/source/kindle/toc.html.erb b/guides/source/kindle/toc.html.erb
index e013797dee..e013797dee 100644
--- a/railties/guides/source/kindle/toc.html.erb
+++ b/guides/source/kindle/toc.html.erb
diff --git a/railties/guides/source/kindle/toc.ncx.erb b/guides/source/kindle/toc.ncx.erb
index 2c6d8e3bdf..2c6d8e3bdf 100644
--- a/railties/guides/source/kindle/toc.ncx.erb
+++ b/guides/source/kindle/toc.ncx.erb
diff --git a/railties/guides/source/kindle/welcome.html.erb b/guides/source/kindle/welcome.html.erb
index e30704c4e6..e30704c4e6 100644
--- a/railties/guides/source/kindle/welcome.html.erb
+++ b/guides/source/kindle/welcome.html.erb
diff --git a/railties/guides/source/layout.html.erb b/guides/source/layout.html.erb
index 35b6fc7014..35b6fc7014 100644
--- a/railties/guides/source/layout.html.erb
+++ b/guides/source/layout.html.erb
diff --git a/railties/guides/source/layouts_and_rendering.textile b/guides/source/layouts_and_rendering.textile
index 4b4f9f3745..4b4f9f3745 100644
--- a/railties/guides/source/layouts_and_rendering.textile
+++ b/guides/source/layouts_and_rendering.textile
diff --git a/railties/guides/source/migrations.textile b/guides/source/migrations.textile
index c11f8e221b..c11f8e221b 100644
--- a/railties/guides/source/migrations.textile
+++ b/guides/source/migrations.textile
diff --git a/railties/guides/source/nested_model_forms.textile b/guides/source/nested_model_forms.textile
index 82c9ab9d36..82c9ab9d36 100644
--- a/railties/guides/source/nested_model_forms.textile
+++ b/guides/source/nested_model_forms.textile
diff --git a/railties/guides/source/performance_testing.textile b/guides/source/performance_testing.textile
index 958b13cd9e..958b13cd9e 100644
--- a/railties/guides/source/performance_testing.textile
+++ b/guides/source/performance_testing.textile
diff --git a/railties/guides/source/plugins.textile b/guides/source/plugins.textile
index 07fd95c825..97b4eca779 100644
--- a/railties/guides/source/plugins.textile
+++ b/guides/source/plugins.textile
@@ -176,11 +176,11 @@ require 'test_helper'
class ActsAsYaffleTest < Test::Unit::TestCase
def test_a_hickwalls_yaffle_text_field_should_be_last_squawk
- assert_equal "last_squawk", Hickwall.yaffle_text_field
+ assert_equal :last_squawk, Hickwall.yaffle_text_field
end
def test_a_wickwalls_yaffle_text_field_should_be_last_tweet
- assert_equal "last_tweet", Wickwall.yaffle_text_field
+ assert_equal :last_tweet, Wickwall.yaffle_text_field
end
end
@@ -362,13 +362,16 @@ module Yaffle
def acts_as_yaffle(options = {})
cattr_accessor :yaffle_text_field
self.yaffle_text_field = (options[:yaffle_text_field] || :last_squawk).to_s
+
+ include Yaffle::ActsAsYaffle::LocalInstanceMethods
end
end
- def squawk(string)
- write_attribute(self.class.yaffle_text_field, string.to_squawk)
+ module LocalInstanceMethods
+ def squawk(string)
+ write_attribute(self.class.yaffle_text_field, string.to_squawk)
+ end
end
-
end
end
diff --git a/railties/guides/source/rails_application_templates.textile b/guides/source/rails_application_templates.textile
index f50ced3307..f50ced3307 100644
--- a/railties/guides/source/rails_application_templates.textile
+++ b/guides/source/rails_application_templates.textile
diff --git a/railties/guides/source/rails_on_rack.textile b/guides/source/rails_on_rack.textile
index 9526526bc7..9526526bc7 100644
--- a/railties/guides/source/rails_on_rack.textile
+++ b/guides/source/rails_on_rack.textile
diff --git a/railties/guides/source/routing.textile b/guides/source/routing.textile
index e93b1280e0..e93b1280e0 100644
--- a/railties/guides/source/routing.textile
+++ b/guides/source/routing.textile
diff --git a/railties/guides/source/ruby_on_rails_guides_guidelines.textile b/guides/source/ruby_on_rails_guides_guidelines.textile
index f3c8fa654d..f3e934d38c 100644
--- a/railties/guides/source/ruby_on_rails_guides_guidelines.textile
+++ b/guides/source/ruby_on_rails_guides_guidelines.textile
@@ -1,20 +1,20 @@
h2. Ruby on Rails Guides Guidelines
-This guide documents guidelines for writing guides. This guide follows itself in a gracile loop.
+This guide documents guidelines for writing Ruby on Rails Guides. This guide follows itself in a graceful loop, serving itself as an example.
endprologue.
h3. Textile
-Guides are written in "Textile":http://www.textism.com/tools/textile/. There's comprehensive documentation "here":http://redcloth.org/hobix.com/textile/ and a cheatsheet for markup "here":http://redcloth.org/hobix.com/textile/quick.html.
+Guides are written in "Textile":http://www.textism.com/tools/textile/. There is comprehensive "documentation":http://redcloth.org/hobix.com/textile/ and a "cheatsheet":http://redcloth.org/hobix.com/textile/quick.html for markup.
h3. Prologue
-Each guide should start with motivational text at the top (that's the little introduction in the blue area.) The prologue should tell the reader what the guide is about, and what they will learn. See for example the "Routing Guide":routing.html.
+Each guide should start with motivational text at the top (that's the little introduction in the blue area). The prologue should tell the reader what the guide is about, and what they will learn. See for example the "Routing Guide":routing.html.
h3. Titles
-The title of every guide uses +h2+, guide sections use +h3+, subsections +h4+, etc.
+The title of every guide uses +h2+; guide sections use +h3+; subsections +h4+; etc.
Capitalize all words except for internal articles, prepositions, conjunctions, and forms of the verb to be:
@@ -31,7 +31,7 @@ h6. The <tt>:content_type</tt> Option
h3. API Documentation Guidelines
-The guides and the API should be coherent where appropriate. Please have a look at these particular sections of the "API Documentation Guidelines":api_documentation_guidelines.html:
+The guides and the API should be coherent and consistent where appropriate. Please have a look at these particular sections of the "API Documentation Guidelines":api_documentation_guidelines.html:
* "Wording":api_documentation_guidelines.html#wording
* "Example Code":api_documentation_guidelines.html#example-code
@@ -44,7 +44,7 @@ h3. HTML Guides
h4. Generation
-To generate all the guides, just +cd+ into the +railties+ directory and execute:
+To generate all the guides, just +cd+ into the *+guides+* directory and execute:
<plain>
bundle exec rake generate_guides
@@ -55,16 +55,17 @@ bundle exec rake generate_guides
To process +my_guide.textile+ and nothing else use the +ONLY+ environment variable:
<plain>
+touch my_guide.textile
bundle exec rake generate_guides ONLY=my_guide
</plain>
By default, guides that have not been modified are not processed, so +ONLY+ is rarely needed in practice.
-To force process of all the guides, pass +ALL=1+.
+To force processing all the guides, pass +ALL=1+.
It is also recommended that you work with +WARNINGS=1+. This detects duplicate IDs and warns about broken internal links.
-If you want to generate guides in languages other than English, you can keep them in a separate directory under +source+ (eg. <tt>source/es</tt>) and use the +GUIDES_LANGUAGE+ environment variable:
+If you want to generate guides in a language other than English, you can keep them in a separate directory under +source+ (eg. <tt>source/es</tt>) and use the +GUIDES_LANGUAGE+ environment variable:
<plain>
bundle exec rake generate_guides GUIDES_LANGUAGE=es
@@ -78,11 +79,11 @@ Please validate the generated HTML with:
bundle exec rake validate_guides
</plain>
-Particularly, titles get an ID generated from their content and this often leads to duplicates. Please set +WARNINGS=1+ when generating guides to detect them. The warning messages suggest a way to fix them.
+Particularly, titles get an ID generated from their content and this often leads to duplicates. Please set +WARNINGS=1+ when generating guides to detect them. The warning messages suggest a solution.
h3. Kindle Guides
-h4. Generation
+h4(#generation-kindle). Generation
To generate guides for the Kindle, you need to provide +KINDLE=1+ as an environment variable:
diff --git a/railties/guides/source/security.textile b/guides/source/security.textile
index 747a4d6791..747a4d6791 100644
--- a/railties/guides/source/security.textile
+++ b/guides/source/security.textile
diff --git a/railties/guides/source/testing.textile b/guides/source/testing.textile
index c367f532ae..c367f532ae 100644
--- a/railties/guides/source/testing.textile
+++ b/guides/source/testing.textile
diff --git a/railties/guides/source/upgrading_ruby_on_rails.textile b/guides/source/upgrading_ruby_on_rails.textile
index e63548abc9..e63548abc9 100644
--- a/railties/guides/source/upgrading_ruby_on_rails.textile
+++ b/guides/source/upgrading_ruby_on_rails.textile
diff --git a/railties/guides/w3c_validator.rb b/guides/w3c_validator.rb
index f1fe1e0f33..f1fe1e0f33 100644
--- a/railties/guides/w3c_validator.rb
+++ b/guides/w3c_validator.rb
diff --git a/rails.gemspec b/rails.gemspec
index 2c47a88d7c..8314036ad1 100644
--- a/rails.gemspec
+++ b/rails.gemspec
@@ -10,12 +10,13 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 1.9.3'
s.required_rubygems_version = ">= 1.8.11"
- s.author = 'David Heinemeier Hansson'
- s.email = 'david@loudthinking.com'
- s.homepage = 'http://www.rubyonrails.org'
+ s.author = 'David Heinemeier Hansson'
+ s.email = 'david@loudthinking.com'
+ s.homepage = 'http://www.rubyonrails.org'
- s.bindir = 'bin'
- s.executables = []
+ s.bindir = 'bin'
+ s.executables = []
+ s.files = Dir['guides/**/*']
s.add_dependency('activesupport', version)
s.add_dependency('actionpack', version)
diff --git a/railties/CHANGELOG.md b/railties/CHANGELOG.md
index 34de7fe2b8..bc34ced283 100644
--- a/railties/CHANGELOG.md
+++ b/railties/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 4.0.0 (unreleased) ##
+* Remove Rack::SSL in favour of ActionDispatch::SSL. *Rafael Mendonça França*
+
* Remove Active Resource from Rails framework. *Prem Sichangrist*
* Allow to set class that will be used to run as a console, other than IRB, with `Rails.application.config.console=`. It's best to add it to `console` block. *Piotr Sarnacki*
diff --git a/railties/Rakefile b/railties/Rakefile
index 25e515e016..c4a91a1d36 100755
--- a/railties/Rakefile
+++ b/railties/Rakefile
@@ -44,18 +44,6 @@ task :update_readme do
cp "./README.rdoc", readme
end
-desc 'Generate guides (for authors), use ONLY=foo to process just "foo.textile"'
-task :generate_guides do
- ENV["WARN_BROKEN_LINKS"] = "1" # authors can't disable this
- ruby "guides/rails_guides.rb"
-end
-
-# Validate guides -------------------------------------------------------------------------
-desc 'Validate guides, use ONLY=foo to process just "foo.html"'
-task :validate_guides do
- ruby "guides/w3c_validator.rb"
-end
-
# Generate GEM ----------------------------------------------------------------------------
spec = eval(File.read('railties.gemspec'))
diff --git a/railties/guides/source/active_support_instrumentation.textile b/railties/guides/source/active_support_instrumentation.textile
deleted file mode 100644
index 8e2866dfc3..0000000000
--- a/railties/guides/source/active_support_instrumentation.textile
+++ /dev/null
@@ -1,96 +0,0 @@
-h2. Active Support Instrumentation
-
-Active Support is a part of core Rails that provides Ruby language extensions, utilities and other things. One of the things it includes is an instrumentation API that can be used inside an application to measure certain actions that occur within Ruby code, such as that inside a Rails application or the framework itself. It is not limited to Rails, however. It can be used independently in other Ruby scripts if it is so desired.
-
-In this guide, you will learn how to use the instrumentation API inside of ActiveSupport to measure events inside of Rails and other Ruby code. We cover:
-
-* What instrumentation can provide
-* The hooks inside the Rails framework for instrumentation
-* Adding a subscriber to a hook
-* Building a custom instrumentation implementation
-
-endprologue.
-
-h3. Introduction to instrumentation
-
-The instrumentation API provided by ActiveSupport allows developers to provide hooks which other developers may hook into. There are several of these within the Rails framework, as described below in <TODO: link to section detailing each hook point>. With this API, developers can choose to be notified when certain events occur inside their application or another piece of Ruby code.
-
-For example, there is a hook provided within Active Record that is called every time Active Record uses a SQL query on a database. This hook could be *subscribed* to, and used to track the number of queries during a certain action. There's another hook around the processing of an action of a controller. This could be used, for instance, to track how long a specific action has taken.
-
-You are even able to create your own events inside your application which you can later subscribe to.
-
-h3. Rails framework hooks
-
-Within the Ruby on Rails framework, there are a number of hooks provided for common events. These are detailed below.
-
-h4. Action Mailer
-
-h5. receive.action_mailer
-
-This hook is called when the +receive+ method of an +ActionMailer::Base+ class is called:
-
-<ruby>
- class Mailer < ActionMailer::Base
- def receive(mail)
-
- end
- end
-</ruby>
-
-The payload for this event has the following parameters related to the incoming email:
-
-|_.Key |_.Value|
-|mailer |Name of the mailer class|
-|message_id |ID of the message, generated by the Mail gem|
-|subject |Subject of the mail|
-|to |To address(es) of the mail|
-|from |From address of the mail|
-|bcc |BCC addresses of the mail|
-|cc |CC addresses of the mail|
-|date |Date of the mail|
-|mail |The encoded form of the mail|
-
-h5. deliver.action_mailer
-
-This hook is called when the +deliver+ method is called on a +Mail::Message+ object. This is due to a hook inserted by Action Mailer, rather than a specific feature of the Mail gem itself.
-
-The payload for this event has the following parameters related to the outgoing email:
-
-|_.Key |_.Value|
-|mailer |Name of the mailer class|
-|message_id |ID of the message, generated by the Mail gem|
-|subject |Subject of the mail|
-|to |To address(es) of the mail|
-|from |From address of the mail|
-|bcc |BCC addresses of the mail|
-|cc |CC addresses of the mail|
-|date |Date of the mail|
-|mail |The encoded form of the mail|
-
-
-h4. Action Controller
-
-h5. write_fragment.action_controller
-
-h5. read_fragment.action_controller
-
-h5. exist_fragment?.action_controller
-
-h5. expire_fragment.action_controller
-
-h5. write_page.action_controller
-
-h5. expire_page.action_controller
-
-h4. Action View
-
-h4. Active Record
-
-h4. Active Resource
-
-h4. Active Support
-
-h3. Subscribing to an event
-
-h3. Creating custom events
-
diff --git a/railties/guides/source/api_app.textile b/railties/guides/source/api_app.textile
deleted file mode 100644
index 6bc317955a..0000000000
--- a/railties/guides/source/api_app.textile
+++ /dev/null
@@ -1,273 +0,0 @@
-h2. Using Rails for API-only Apps
-
-In this guide you will learn:
-
-* What Rails provides for API-only applications
-* How to configure Rails to start without any browser features
-* How to decide which middlewares you will want to include
-* How to decide which modules to use in your controller
-
-NOTE: This guide reflects features that have not yet been fully implemented. Docs first :)
-
-endprologue.
-
-h3. What is an API app?
-
-Traditionally, when people said that they used Rails as an "API", they meant providing a programmatically accessible API alongside their web application.
-For example, GitHub provides "an API":http://developer.github.com that you can use from your own custom clients.
-
-With the advent of client-side frameworks, more developers are using Rails to build a backend that is shared between their web application and other native applications.
-
-For example, Twitter uses its "public API":https://dev.twitter.com in its web application, which is built as a static site that consumes JSON resources.
-
-Instead of using Rails to generate dynamic HTML that will communicate with the server through forms and links, many developers are treating their web application as just another client, delivered as static HTML, CSS and JavaScript, and consuming a simple JSON API
-
-This guide covers building a Rails application that serves JSON resources to an API client *or* client-side framework.
-
-h3. Why use Rails for JSON APIs?
-
-The first question a lot of people have when thinking about building a JSON API using Rails is: "isn't using Rails to spit out some JSON overkill? Shouldn't I just use something like Sinatra?"
-
-For very simple APIs, this may be true. However, even in very HTML-heavy applications, most of an application's logic is actually outside of the view layer.
-
-The reason most people use Rails is that it provides a set of defaults that allows us to get up and running quickly without having to make a lot of trivial decisions.
-
-Let's take a look at some of the things that Rails provides out of the box that are still applicable to API applications.
-
-Handled at the middleware layer:
-
-* Reloading: Rails applications support transparent reloading. This works even if your application gets big and restarting the server for every request becomes non-viable.
-* Development Mode: Rails application come with smart defaults for development, making development pleasant without compromising production-time performance.
-* Test Mode: Ditto test mode.
-* Logging: Rails applications log every request, with a level of verbosity appropriate for the current mode. Rails logs in development include information about the request environment, database queries, and basic performance information.
-* Security: Rails detects and thwarts "IP spoofing attacks":http://en.wikipedia.org/wiki/IP_address_spoofing and handles cryptographic signatures in a "timing attack":http://en.wikipedia.org/wiki/Timing_attack aware way. Don't know what an IP spoofing attack or a timing attack is? Exactly.
-* Parameter Parsing: Want to specify your parameters as JSON instead of as a URL-encoded String? No problem. Rails will decode the JSON for you and make it available in +params+. Want to use nested URL-encoded params? That works too.
-* Conditional GETs: Rails handles conditional +GET+, (+ETag+ and +Last-Modified+), processing request headers and returning the correct response headers and status code. All you need to do is use the "stale?":http://api.rubyonrails.org/classes/ActionController/ConditionalGet.html#method-i-stale-3F check in your controller, and Rails will handle all of the HTTP details for you.
-* Caching: If you use +dirty?+ with public cache control, Rails will automatically cache your responses. You can easily configure the cache store.
-* HEAD requests: Rails will transparently convert +HEAD+ requests into +GET+ requests, and return just the headers on the way out. This makes +HEAD+ work reliably in all Rails APIs.
-
-While you could obviously build these up in terms of existing Rack middlewares, I think this list demonstrates that the default Rails middleware stack provides a lot of value, even if you're "just generating JSON".
-
-Handled at the ActionPack layer:
-
-* Resourceful Routing: If you're building a RESTful JSON API, you want to be using the Rails router. Clean and conventional mapping from HTTP to controllers means not having to spend time thinking about how to model your API in terms of HTTP.
-* URL Generation: The flip side of routing is URL generation. A good API based on HTTP includes URLs (see "the GitHub gist API":http://developer.github.com/v3/gists/ for an example).
-* Header and Redirection Responses: +head :no_content+ and +redirect_to user_url(current_user)+ come in handy. Sure, you could manually add the response headers, but why?
-* Caching: Rails provides page, action and fragment caching. Fragment caching is especially helpful when building up a nested JSON object.
-* Basic, Digest and Token Authentication: Rails comes with out-of-the-box support for three kinds of HTTP authentication.
-* Instrumentation: Rails 3.0 added an instrumentation API that will trigger registered handlers for a variety of events, such as action processing, sending a file or data, redirection, and database queries. The payload of each event comes with relevant information (for the action processing event, the payload includes the controller, action, params, request format, request method and the request's full path).
-* Generators: This may be passé for advanced Rails users, but it can be nice to generate a resource and get your model, controller, test stubs, and routes created for you in a single command.
-* Plugins: Many third-party libraries come with support for Rails that reduces or eliminates the cost of setting up and gluing together the library and the web framework. This includes things like overriding default generators, adding rake tasks, and honoring Rails choices (like the logger and cache backend).
-
-Of course, the Rails boot process also glues together all registered components. For example, the Rails boot process is what uses your +config/database.yml+ file when configuring ActiveRecord.
-
-**The short version is**: you may not have thought about which parts of Rails are still applicable even if you remove the view layer, but the answer turns out to be "most of it".
-
-h3. The Basic Configuration
-
-If you're building a Rails application that will be an API server first and foremost, you can start with a more limited subset of Rails and add in features as needed.
-
-You can generate a new bare Rails app:
-
-<shell>
-$ rails new my_api --http
-</shell>
-
-This will do three main things for you:
-
-* Configure your application to start with a more limited set of middleware than normal. Specifically, it will not include any middleware primarily useful for browser applications (like cookie support) by default.
-* Make +ApplicationController+ inherit from +ActionController::HTTP+ instead of +ActionController::Base+. As with middleware, this will leave out any +ActionController+ modules that provide functionality primarily used by browser applications.
-* Configure the generators to skip generating views, helpers and assets when you generate a new resource.
-
-If you want to take an existing app and make it an API app, follow the following steps.
-
-In +config/application.rb+ add the following lines at the top of the +Application+ class:
-
-<ruby>
-config.middleware.http_only!
-config.generators.http_only!
-</ruby>
-
-Change +app/controllers/application_controller.rb+:
-
-<ruby>
-# instead of
-class ApplicationController < ActionController::Base
-end
-
-# do
-class ApplicationController < ActionController::HTTP
-end
-</ruby>
-
-h3. Choosing Middlewares
-
-An API application comes with the following middlewares by default.
-
-* +Rack::Cache+: Caches responses with public +Cache-Control+ headers using HTTP caching semantics. See below for more information.
-* +Rack::Sendfile+: Uses a front-end server's file serving support from your Rails application.
-* +Rack::Lock+: If your application is not marked as threadsafe (+config.threadsafe!+), this middleware will add a mutex around your requests.
-* +ActionDispatch::RequestId+:
-* +Rails::Rack::Logger+:
-* +Rack::Runtime+: Adds a header to the response listing the total runtime of the request.
-* +ActionDispatch::ShowExceptions+: Rescue exceptions and re-dispatch them to an exception handling application
-* +ActionDispatch::DebugExceptions+: Log exceptions
-* +ActionDispatch::RemoteIp+: Protect against IP spoofing attacks
-* +ActionDispatch::Reloader+: In development mode, support code reloading.
-* +ActionDispatch::ParamsParser+: Parse XML, YAML and JSON parameters when the request's +Content-Type+ is one of those.
-* +ActionDispatch::Head+: Dispatch +HEAD+ requests as +GET+ requests, and return only the status code and headers.
-* +Rack::ConditionalGet+: Supports the +stale?+ feature in Rails controllers.
-* +Rack::ETag+: Automatically set an +ETag+ on all string responses. This means that if the same response is returned from a controller for the same URL, the server will return a +304 Not Modified+, even if no additional caching steps are taken. This is primarily a client-side optimization; it reduces bandwidth costs but not server processing time.
-
-Other plugins, including +ActiveRecord+, may add additional middlewares. In general, these middlewares are agnostic to the type of app you are building, and make sense in an API-only Rails application.
-
-You can get a list of all middlewares in your application via:
-
-<shell>
-$ rake middleware
-</shell>
-
-h4. Using Rack::Cache
-
-When used with Rails, +Rack::Cache+ uses the Rails cache store for its entity and meta stores. This means that if you use memcache, for your Rails app, for instance, the built-in HTTP cache will use memcache.
-
-To make use of +Rack::Cache+, you will want to use +stale?+ in your controller. Here's an example of +stale?+ in use.
-
-<ruby>
-def show
- @post = Post.find(params[:id])
-
- if stale?(:last_modified => @post.updated_at)
- render json: @post
- end
-end
-</ruby>
-
-The call to +stale?+ will compare the +If-Modified-Since+ header in the request with +@post.updated_at+. If the header is newer than the last modified, this action will return a +304 Not Modified+ response. Otherwise, it will render the response and include a +Last-Modified+ header with the response.
-
-Normally, this mechanism is used on a per-client basis. +Rack::Cache+ allows us to share this caching mechanism across clients. We can enable cross-client caching in the call to +stale?+
-
-<ruby>
-def show
- @post = Post.find(params[:id])
-
- if stale?(:last_modified => @post.updated_at, :public => true)
- render json: @post
- end
-end
-</ruby>
-
-This means that +Rack::Cache+ will store off +Last-Modified+ value for a URL in the Rails cache, and add an +If-Modified-Since+ header to any subsequent inbound requests for the same URL.
-
-Think of it as page caching using HTTP semantics.
-
-NOTE: The +Rack::Cache+ middleware is always outside of the +Rack::Lock+ mutex, even in single-threaded apps.
-
-h4. Using Rack::Sendfile
-
-When you use the +send_file+ method in a Rails controller, it sets the +X-Sendfile+ header. +Rack::Sendfile+ is responsible for actually sending the file.
-
-If your front-end server supports accelerated file sending, +Rack::Sendfile+ will offload the actual file sending work to the front-end server.
-
-You can configure the name of the header that your front-end server uses for this purposes using +config.action_dispatch.x_sendfile_header+ in the appropriate environment config file.
-
-You can learn more about how to use +Rack::Sendfile+ with popular front-ends in "the Rack::Sendfile documentation":http://rubydoc.info/github/rack/rack/master/Rack/Sendfile
-
-The values for popular servers once they are configured to support accelerated file sending:
-
-<ruby>
-# Apache and lighttpd
-config.action_dispatch.x_sendfile_header = "X-Sendfile"
-
-# nginx
-config.action_dispatch.x_sendfile_header = "X-Accel-Redirect"
-</ruby>
-
-Make sure to configure your server to support these options following the instructions in the +Rack::Sendfile+ documentation.
-
-NOTE: The +Rack::Sendfile+ middleware is always outside of the +Rack::Lock+ mutex, even in single-threaded apps.
-
-h4. Using ActionDispatch::ParamsParser
-
-+ActionDispatch::ParamsParser+ will take parameters from the client in JSON and make them available in your controller as +params+.
-
-To use this, your client will need to make a request with JSON-encoded parameters and specify the +Content-Type+ as +application/json+.
-
-Here's an example in jQuery:
-
-<plain>
-jQuery.ajax({
- type: 'POST',
- url: '/people'
- dataType: 'json',
- contentType: 'application/json',
- data: JSON.stringify({ person: { firstName: "Yehuda", lastName: "Katz" } }),
-
- success: function(json) { }
-});
-</plain>
-
-+ActionDispatch::ParamsParser+ will see the +Content-Type+ and your params will be +{ :person => { :firstName => "Yehuda", :lastName => "Katz" } }+.
-
-h4. Other Middlewares
-
-Rails ships with a number of other middlewares that you might want to use in an API app, especially if one of your API clients is the browser:
-
-* +Rack::MethodOverride+: Allows the use of the +_method+ hack to route POST requests to other verbs.
-* +ActionDispatch::Cookies+: Supports the +cookie+ method in +ActionController+, including support for signed and encrypted cookies.
-* +ActionDispatch::Flash+: Supports the +flash+ mechanism in +ActionController+.
-* +ActionDispatch::BestStandards+: Tells Internet Explorer to use the most standards-compliant available renderer. In production mode, if ChromeFrame is available, use ChromeFrame.
-* Session Management: If a +config.session_store+ is supplied, this middleware makes the session available as the +session+ method in +ActionController+.
-
-Any of these middlewares can be adding via:
-
-<ruby>
-config.middleware.use Rack::MethodOverride
-</ruby>
-
-h4. Removing Middlewares
-
-If you don't want to use a middleware that is included by default in the API-only middleware set, you can remove it using +config.middleware.delete+:
-
-<ruby>
-config.middleware.delete ::Rack::Sendfile
-</ruby>
-
-Keep in mind that removing these features may remove support for certain features in +ActionController+.
-
-h3. Choosing Controller Modules
-
-An API application (using +ActionController::HTTP+) comes with the following controller modules by default:
-
-* +ActionController::UrlFor+: Makes +url_for+ and friends available
-* +ActionController::Redirecting+: Support for +redirect_to+
-* +ActionController::Rendering+: Basic support for rendering
-* +ActionController::Renderers::All+: Support for +render :json+ and friends
-* +ActionController::ConditionalGet+: Support for +stale?+
-* +ActionController::ForceSSL+: Support for +force_ssl+
-* +ActionController::RackDelegation+: Support for the +request+ and +response+ methods returning +ActionDispatch::Request+ and +ActionDispatch::Response+ objects.
-* +ActionController::DataStreaming+: Support for +send_file+ and +send_data+
-* +AbstractController::Callbacks+: Support for +before_filter+ and friends
-* +ActionController::Instrumentation+: Support for the instrumentation hooks defined by +ActionController+ (see "the source":https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/metal/instrumentation.rb for more).
-* +ActionController::Rescue+: Support for +rescue_from+.
-
-Other plugins may add additional modules. You can get a list of all modules included into +ActionController::HTTP+ in the rails console:
-
-<shell>
-$ irb
->> ActionController::HTTP.ancestors - ActionController::Metal.ancestors
-</shell>
-
-h4. Adding Other Modules
-
-All ActionController modules know about their dependent modules, so you can feel free to include any modules into your controllers, and all dependencies will be included and set up as well.
-
-Some common modules you might want to add:
-
-* +AbstractController::Translation+: Support for the +l+ and +t+ localization and translation methods. These delegate to +I18n.translate+ and +I18n.localize+.
-* +ActionController::HTTPAuthentication::Basic+ (or +Digest+ or +Token): Support for basic, digest or token HTTP authentication.
-* +AbstractController::Layouts+: Support for layouts when rendering.
-* +ActionController::MimeResponds+: Support for content negotiation (+respond_to+, +respond_with+).
-* +ActionController::Cookies+: Support for +cookies+, which includes support for signed and encrypted cookies. This requires the cookie middleware.
-
-The best place to add a module is in your +ApplicationController+. You can also add modules to individual controllers.
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 3191fe68a7..d7b8350963 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -225,8 +225,7 @@ module Rails
end
if config.force_ssl
- require "rack/ssl"
- middleware.use ::Rack::SSL, config.ssl_options
+ middleware.use ::ActionDispatch::SSL, config.ssl_options
end
if config.action_dispatch.x_sendfile_header.present?
@@ -239,7 +238,7 @@ module Rails
middleware.use ::Rack::Lock unless config.allow_concurrency
middleware.use ::Rack::Runtime
- middleware.use ::Rack::MethodOverride unless config.middleware.http_only?
+ middleware.use ::Rack::MethodOverride
middleware.use ::ActionDispatch::RequestId
middleware.use ::Rails::Rack::Logger, config.log_tags # must come after Rack::MethodOverride to properly log overridden methods
middleware.use ::ActionDispatch::ShowExceptions, config.exceptions_app || ActionDispatch::PublicExceptions.new(Rails.public_path)
@@ -252,9 +251,9 @@ module Rails
end
middleware.use ::ActionDispatch::Callbacks
- middleware.use ::ActionDispatch::Cookies unless config.middleware.http_only?
+ middleware.use ::ActionDispatch::Cookies
- if !config.middleware.http_only? && config.session_store
+ if config.session_store
if config.force_ssl && !config.session_options.key?(:secure)
config.session_options[:secure] = true
end
@@ -267,7 +266,7 @@ module Rails
middleware.use ::Rack::ConditionalGet
middleware.use ::Rack::ETag, "no-cache"
- if !config.middleware.http_only? && config.action_dispatch.best_standards_support
+ if config.action_dispatch.best_standards_support
middleware.use ::ActionDispatch::BestStandardsSupport, config.action_dispatch.best_standards_support
end
end
diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb
index 03538b2422..bcac0751d6 100644
--- a/railties/lib/rails/code_statistics.rb
+++ b/railties/lib/rails/code_statistics.rb
@@ -95,13 +95,7 @@ class CodeStatistics #:nodoc:
m_over_c = (statistics["methods"] / statistics["classes"]) rescue m_over_c = 0
loc_over_m = (statistics["codelines"] / statistics["methods"]) - 2 rescue loc_over_m = 0
- start = if TEST_TYPES.include? name
- "| #{name.ljust(20)} "
- else
- "| #{name.ljust(20)} "
- end
-
- puts start +
+ puts "| #{name.ljust(20)} " +
"| #{statistics["lines"].to_s.rjust(5)} " +
"| #{statistics["codelines"].to_s.rjust(5)} " +
"| #{statistics["classes"].to_s.rjust(7)} " +
diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb
index 86376ac7e6..d7c9e820dc 100644
--- a/railties/lib/rails/commands/console.rb
+++ b/railties/lib/rails/commands/console.rb
@@ -24,6 +24,9 @@ module Rails
OptionParser.new do |opt|
opt.banner = "Usage: console [environment] [options]"
opt.on('-s', '--sandbox', 'Rollback database modifications on exit.') { |v| options[:sandbox] = v }
+ opt.on("-e", "--environment=name", String,
+ "Specifies the environment to run this console under (test/development/production).",
+ "Default: development") { |v| options[:environment] = v.strip }
opt.on("--debugger", 'Enable ruby-debugging for the console.') { |v| options[:debugger] = v }
opt.parse!(arguments)
end
@@ -36,6 +39,14 @@ module Rails
options[:sandbox]
end
+ def environment?
+ options[:environment]
+ end
+
+ def set_environment!
+ Rails.env = options[:environment]
+ end
+
def debugger?
options[:debugger]
end
@@ -45,6 +56,8 @@ module Rails
require_debugger if debugger?
+ set_environment! if environment?
+
if sandbox?
puts "Loading #{Rails.env} environment in sandbox (Rails #{Rails.version})"
puts "Any modifications you make will be rolled back on exit"
diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb
index a608693ca4..721a47a974 100644
--- a/railties/lib/rails/commands/server.rb
+++ b/railties/lib/rails/commands/server.rb
@@ -32,6 +32,11 @@ module Rails
opt_parser.parse! args
+ # Handle's environment like RAILS_ENV=production passed in directly
+ if index = args.index {|arg| arg.include?("RAILS_ENV")}
+ options[:environment] ||= args.delete_at(index).split('=').last
+ end
+
options[:server] = args.shift
options
end
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb
index d8185bcb34..d8ca6cbd21 100644
--- a/railties/lib/rails/configuration.rb
+++ b/railties/lib/rails/configuration.rb
@@ -33,27 +33,9 @@ module Rails
#
# config.middleware.delete ActionDispatch::BestStandardsSupport
#
- # In addition to these methods to handle the stack, if your application is
- # going to be used as an API endpoint only, the middleware stack can be
- # configured like this:
- #
- # config.middleware.http_only!
- #
- # By doing this, Rails will create a smaller middleware stack, by not adding
- # some middlewares that are usually useful for browser access only, such as
- # Cookies, Session and Flash, BestStandardsSupport, and MethodOverride. You
- # can always add any of them later manually if you want.
class MiddlewareStackProxy
def initialize
@operations = []
- @http_only = false
- end
-
- attr_reader :http_only
- alias :http_only? :http_only
-
- def http_only!
- @http_only = true
end
def insert_before(*args, &block)
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 9629ac55c2..131d6e5711 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -561,7 +561,7 @@ module Rails
initializer :add_view_paths do
views = paths["app/views"].existent
unless views.empty?
- ActiveSupport.on_load(:action_controller){ prepend_view_path(views) }
+ ActiveSupport.on_load(:action_controller){ prepend_view_path(views) if respond_to?(:prepend_view_path) }
ActiveSupport.on_load(:action_mailer){ prepend_view_path(views) }
end
end
diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb
index cd277c5097..b9c1b01f54 100644
--- a/railties/lib/rails/generators.rb
+++ b/railties/lib/rails/generators.rb
@@ -70,7 +70,7 @@ module Rails
hide_namespaces(*config.hidden_namespaces)
end
- def self.templates_path
+ def self.templates_path #:nodoc:
@templates_path ||= []
end
@@ -235,7 +235,7 @@ module Rails
rails.delete("plugin_new")
print_list("rails", rails)
- hidden_namespaces.each {|n| groups.delete(n.to_s) }
+ hidden_namespaces.each { |n| groups.delete(n.to_s) }
groups.sort.each { |b, n| print_list(b, n) }
end
diff --git a/railties/lib/rails/generators/app_base.rb b/railties/lib/rails/generators/app_base.rb
index f775004f16..bb2a9fcf22 100644
--- a/railties/lib/rails/generators/app_base.rb
+++ b/railties/lib/rails/generators/app_base.rb
@@ -225,7 +225,7 @@ module Rails
if defined?(JRUBY_VERSION)
"gem 'therubyrhino'\n"
else
- "# gem 'therubyracer'\n"
+ "# gem 'therubyracer', :platform => :ruby\n"
end
end
@@ -257,11 +257,6 @@ module Rails
def git_keep(destination)
create_file("#{destination}/.gitkeep") unless options[:skip_git]
end
-
- # Returns Ruby 1.9 style key-value pair.
- def key_value(key, value)
- "#{key}: #{value}"
- end
end
end
end
diff --git a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb
index 85296ca37b..303331a4f0 100644
--- a/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb
+++ b/railties/lib/rails/generators/erb/scaffold/templates/index.html.erb
@@ -16,7 +16,7 @@
<% end -%>
<td><%%= link_to 'Show', <%= singular_table_name %> %></td>
<td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
- <td><%%= link_to 'Destroy', <%= singular_table_name %>, <%= key_value :confirm, "'Are you sure?'" %>, <%= key_value :method, ":delete" %> %></td>
+ <td><%%= link_to 'Destroy', <%= singular_table_name %>, confirm: 'Are you sure?', method: :delete %></td>
<%% end %>
</table>
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index 9cef55e0a6..862fd9e88d 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -180,11 +180,6 @@ module Rails
class_collisions "#{options[:prefix]}#{name}#{options[:suffix]}"
end
end
-
- # Returns Ruby 1.9 style key-value pair.
- def key_value(key, value)
- "#{key}: #{value}"
- end
end
end
end
diff --git a/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb b/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb
deleted file mode 100644
index b3d6adad2a..0000000000
--- a/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb
+++ /dev/null
@@ -1,5 +0,0 @@
-class ApplicationController < ActionController::Base
- # prevent CSRF attacks by raising an exception,
- # if your application has an API, you'll probably need to use :reset_session
- protect_from_forgery :with => :exception
-end
diff --git a/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt b/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt
new file mode 100644
index 0000000000..3ddc86ae0a
--- /dev/null
+++ b/railties/lib/rails/generators/rails/app/templates/app/controllers/application_controller.rb.tt
@@ -0,0 +1,5 @@
+class ApplicationController < ActionController::Base
+ # Prevent CSRF attacks by raising an exception.
+ # For APIs, you may want to use :reset_session instead.
+ protect_from_forgery :with => :exception
+end \ No newline at end of file
diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb
index 0560b5cade..c8a3c13b95 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/application.rb
+++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb
@@ -59,8 +59,8 @@ module <%= app_const_base %>
# an exception. If set to true, then an ActiveRecord::DeleteRestrictionError exception would be
# raised. If set to false, then an error will be added on the model instead.
<%= comment_if :skip_active_record %>config.active_record.dependent_restrict_raises = false
-
<% unless options.skip_sprockets? -%>
+
# Enable the asset pipeline.
config.assets.enabled = true
diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt
index ddfe4ba1e1..ade0c4f78c 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/session_store.rb.tt
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.
-<%= app_const %>.config.session_store :cookie_store, <%= key_value :key, "'_#{app_name}_session'" %>
+<%= app_const %>.config.session_store :cookie_store, key: <%= "'_#{app_name}_session'" %>
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt
index d640f578da..19cbf0e4f1 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/wrap_parameters.rb.tt
@@ -5,7 +5,7 @@
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
- wrap_parameters <%= key_value :format, "[:json]" %>
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
<%- unless options.skip_active_record? -%>
diff --git a/railties/lib/rails/generators/rails/app/templates/db/seeds.rb.tt b/railties/lib/rails/generators/rails/app/templates/db/seeds.rb.tt
index f75c5dd941..4edb1e857e 100644
--- a/railties/lib/rails/generators/rails/app/templates/db/seeds.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/db/seeds.rb.tt
@@ -3,5 +3,5 @@
#
# Examples:
#
-# cities = City.create([{ <%= key_value :name, "'Chicago'" %> }, { <%= key_value :name, "'Copenhagen'" %> }])
-# Mayor.create(<%= key_value :name, "'Emanuel'" %>, <%= key_value :city, "cities.first" %>)
+# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
+# Mayor.create(name: 'Emanuel', city: cities.first)
diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb
index c7345f3cfb..7c7b289d19 100644
--- a/railties/lib/rails/generators/rails/resource/resource_generator.rb
+++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb
@@ -14,9 +14,12 @@ module Rails
class_option :actions, :type => :array, :banner => "ACTION ACTION", :default => [],
:desc => "Actions for the resource controller"
+ class_option :http, :type => :boolean, :default => false,
+ :desc => "Generate resource with HTTP actions only"
+
def add_resource_route
return if options[:actions].present?
- route_config = regular_class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
+ route_config = regular_class_path.collect{ |namespace| "namespace :#{namespace} do " }.join(" ")
route_config << "resources :#{file_name.pluralize}"
route_config << " end" * regular_class_path.size
route route_config
diff --git a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
index 2271c6f9c1..083eb49d65 100644
--- a/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
+++ b/railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
@@ -10,8 +10,11 @@ module Rails
class_option :orm, :banner => "NAME", :type => :string, :required => true,
:desc => "ORM to generate the controller for"
+ class_option :http, :type => :boolean, :default => false,
+ :desc => "Generate controller with HTTP actions only"
+
def create_controller_files
- template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
+ template "controller.rb", File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
end
hook_for :template_engine, :test_framework, :as => :scaffold
diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
index ee49534a04..b95aea5f19 100644
--- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
+++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
@@ -7,7 +7,7 @@ class <%= controller_class_name %>Controller < ApplicationController
respond_to do |format|
format.html # index.html.erb
- format.json { render <%= key_value :json, "@#{plural_table_name}" %> }
+ format.json { render json: <%= "@#{plural_table_name}" %> }
end
end
@@ -18,7 +18,7 @@ class <%= controller_class_name %>Controller < ApplicationController
respond_to do |format|
format.html # show.html.erb
- format.json { render <%= key_value :json, "@#{singular_table_name}" %> }
+ format.json { render json: <%= "@#{singular_table_name}" %> }
end
end
@@ -29,7 +29,7 @@ class <%= controller_class_name %>Controller < ApplicationController
respond_to do |format|
format.html # new.html.erb
- format.json { render <%= key_value :json, "@#{singular_table_name}" %> }
+ format.json { render json: <%= "@#{singular_table_name}" %> }
end
end
@@ -45,11 +45,11 @@ class <%= controller_class_name %>Controller < ApplicationController
respond_to do |format|
if @<%= orm_instance.save %>
- format.html { redirect_to @<%= singular_table_name %>, <%= key_value :notice, "'#{human_name} was successfully created.'" %> }
- format.json { render <%= key_value :json, "@#{singular_table_name}" %>, <%= key_value :status, ':created' %>, <%= key_value :location, "@#{singular_table_name}" %> }
+ format.html { redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully created.'" %> }
+ format.json { render json: <%= "@#{singular_table_name}" %>, status: :created, location: <%= "@#{singular_table_name}" %> }
else
- format.html { render <%= key_value :action, '"new"' %> }
- format.json { render <%= key_value :json, "@#{orm_instance.errors}" %>, <%= key_value :status, ':unprocessable_entity' %> }
+ format.html { render action: "new" }
+ format.json { render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity }
end
end
end
@@ -61,11 +61,11 @@ class <%= controller_class_name %>Controller < ApplicationController
respond_to do |format|
if @<%= orm_instance.update_attributes("params[:#{singular_table_name}]") %>
- format.html { redirect_to @<%= singular_table_name %>, <%= key_value :notice, "'#{human_name} was successfully updated.'" %> }
+ format.html { redirect_to @<%= singular_table_name %>, notice: <%= "'#{human_name} was successfully updated.'" %> }
format.json { head :no_content }
else
- format.html { render <%= key_value :action, '"edit"' %> }
- format.json { render <%= key_value :json, "@#{orm_instance.errors}" %>, <%= key_value :status, ':unprocessable_entity' %> }
+ format.html { render action: "edit" }
+ format.json { render json: <%= "@#{orm_instance.errors}" %>, status: :unprocessable_entity }
end
end
end
diff --git a/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb b/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb
index d296b26b16..370750a175 100644
--- a/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb
+++ b/railties/lib/rails/generators/test_unit/performance/templates/performance_test.rb
@@ -3,7 +3,7 @@ require 'rails/performance_test_help'
class <%= class_name %>Test < ActionDispatch::PerformanceTest
# Refer to the documentation for all available options
- # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
+ # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory],
# :output => 'tmp/performance', :formats => [:flat] }
def test_homepage
diff --git a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
index 8e796aada9..9e76587a0d 100644
--- a/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
+++ b/railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
@@ -10,23 +10,22 @@ module TestUnit
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
+ class_option :http, :type => :boolean, :default => false,
+ :desc => "Generate functional test with HTTP actions only"
+
def create_test_files
- template 'functional_test.rb',
- File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb")
+ template "functional_test.rb",
+ File.join("test/functional", controller_class_path, "#{controller_file_name}_controller_test.rb")
end
private
- def resource_attributes
- key_value singular_table_name, "{ #{attributes_hash} }"
- end
-
def attributes_hash
return if accessible_attributes.empty?
accessible_attributes.map do |a|
name = a.name
- key_value name, "@#{singular_table_name}.#{name}"
+ "#{name}: @#{singular_table_name}.#{name}"
end.sort.join(', ')
end
diff --git a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
index 19894443d5..30e1650555 100644
--- a/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
+++ b/railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
@@ -19,30 +19,30 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
test "should create <%= singular_table_name %>" do
assert_difference('<%= class_name %>.count') do
- post :create, <%= resource_attributes %>
+ post :create, <%= "#{singular_table_name}: { #{attributes_hash} }" %>
end
assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
end
test "should show <%= singular_table_name %>" do
- get :show, <%= key_value :id, "@#{singular_table_name}" %>
+ get :show, id: <%= "@#{singular_table_name}" %>
assert_response :success
end
test "should get edit" do
- get :edit, <%= key_value :id, "@#{singular_table_name}" %>
+ get :edit, id: <%= "@#{singular_table_name}" %>
assert_response :success
end
test "should update <%= singular_table_name %>" do
- put :update, <%= key_value :id, "@#{singular_table_name}" %>, <%= resource_attributes %>
+ put :update, id: <%= "@#{singular_table_name}" %>, <%= "#{singular_table_name}: { #{attributes_hash} }" %>
assert_redirected_to <%= singular_table_name %>_path(assigns(:<%= singular_table_name %>))
end
test "should destroy <%= singular_table_name %>" do
assert_difference('<%= class_name %>.count', -1) do
- delete :destroy, <%= key_value :id, "@#{singular_table_name}" %>
+ delete :destroy, id: <%= "@#{singular_table_name}" %>
end
assert_redirected_to <%= index_helper %>_path
diff --git a/railties/lib/rails/paths.rb b/railties/lib/rails/paths.rb
index b37421c09c..4ac3d88dc2 100644
--- a/railties/lib/rails/paths.rb
+++ b/railties/lib/rails/paths.rb
@@ -157,7 +157,25 @@ module Rails
path = File.expand_path(p, @root.path)
if @glob
- result.concat Dir[File.join(path, @glob)].sort
+ if File.directory? path
+ result.concat expand_dir(path, @glob)
+ else
+ # FIXME: I think we can remove this branch, but I'm not sure.
+ # Say the filesystem has this file:
+ #
+ # /tmp/foobar
+ #
+ # and someone adds this path:
+ #
+ # /tmp/foo
+ #
+ # with a glob of "*", then this function will return
+ #
+ # /tmp/foobar
+ #
+ # We need to figure out if that is desired behavior.
+ result.concat expand_file(path, @glob)
+ end
else
result << path
end
@@ -177,6 +195,17 @@ module Rails
end
alias to_a expanded
+
+ private
+ def expand_file(path, glob)
+ Dir[File.join(path, glob)].sort
+ end
+
+ def expand_dir(path, glob)
+ Dir.chdir(path) do
+ Dir.glob(@glob).map { |file| File.join path, file }.sort
+ end
+ end
end
end
end
diff --git a/railties/lib/rails/source_annotation_extractor.rb b/railties/lib/rails/source_annotation_extractor.rb
index 9bfc2b16ab..4cd60fdc39 100644
--- a/railties/lib/rails/source_annotation_extractor.rb
+++ b/railties/lib/rails/source_annotation_extractor.rb
@@ -22,7 +22,7 @@ class SourceAnnotationExtractor
# If +options+ has a flag <tt>:tag</tt> the tag is shown as in the example above.
# Otherwise the string contains just line and text.
def to_s(options={})
- s = "[#{line.to_s.rjust(options[:indent])}]"
+ s = "[#{line.to_s.rjust(options[:indent])}] "
s << "[#{tag}] " if options[:tag]
s << text
end
diff --git a/railties/railties.gemspec b/railties/railties.gemspec
index 82655ad394..e84b1d0644 100644
--- a/railties/railties.gemspec
+++ b/railties/railties.gemspec
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
s.email = 'david@loudthinking.com'
s.homepage = 'http://www.rubyonrails.org'
- s.files = Dir['CHANGELOG.md', 'README.rdoc', 'bin/**/*', 'guides/**/*', 'lib/**/{*,.[a-z]*}']
+ s.files = Dir['CHANGELOG.md', 'README.rdoc', 'bin/**/*', 'lib/**/{*,.[a-z]*}']
s.require_path = 'lib'
s.bindir = 'bin'
@@ -22,7 +22,6 @@ Gem::Specification.new do |s|
s.add_dependency('rake', '>= 0.8.7')
s.add_dependency('thor', '~> 0.14.6')
- s.add_dependency('rack-ssl', '~> 1.3.2')
s.add_dependency('rdoc', '~> 3.4')
s.add_dependency('activesupport', version)
s.add_dependency('actionpack', version)
diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb
index 0354c08067..9302443c98 100644
--- a/railties/test/application/loading_test.rb
+++ b/railties/test/application/loading_test.rb
@@ -95,7 +95,7 @@ class LoadingTest < ActiveSupport::TestCase
assert_equal [ActiveRecord::SchemaMigration], ActiveRecord::Base.descendants
end
- test "initialize_cant_be_called_twice" do
+ test "initialize cant be called twice" do
require "#{app_path}/config/environment"
assert_raise(RuntimeError) { ::AppTemplate::Application.initialize! }
end
@@ -256,6 +256,35 @@ class LoadingTest < ActiveSupport::TestCase
assert_equal "BODY", last_response.body
end
+ test "AC load hooks can be used with metal" do
+ app_file "app/controllers/omg_controller.rb", <<-RUBY
+ begin
+ class OmgController < ActionController::Metal
+ ActiveSupport.run_load_hooks(:action_controller, self)
+ def show
+ self.response_body = ["OK"]
+ end
+ end
+ rescue => e
+ puts "Error loading metal: \#{e.class} \#{e.message}"
+ end
+ RUBY
+
+ app_file "config/routes.rb", <<-RUBY
+ AppTemplate::Application.routes.draw do
+ match "/:controller(/:action)"
+ end
+ RUBY
+
+ require "#{rails_root}/config/environment"
+
+ require 'rack/test'
+ extend Rack::Test::Methods
+
+ get '/omg/show'
+ assert_equal 'OK', last_response.body
+ end
+
protected
def setup_ar!
diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb
index e6f85918f6..fc5fb60174 100644
--- a/railties/test/application/middleware_test.rb
+++ b/railties/test/application/middleware_test.rb
@@ -52,36 +52,6 @@ module ApplicationTests
], middleware
end
- test "api middleware stack" do
- add_to_config "config.middleware.http_only!"
- add_to_config "config.force_ssl = true"
- add_to_config "config.action_dispatch.x_sendfile_header = 'X-Sendfile'"
-
- boot!
-
- assert_equal [
- "Rack::SSL",
- "Rack::Sendfile",
- "ActionDispatch::Static",
- "Rack::Lock",
- "ActiveSupport::Cache::Strategy::LocalCache",
- "Rack::Runtime",
- "ActionDispatch::RequestId",
- "Rails::Rack::Logger",
- "ActionDispatch::ShowExceptions",
- "ActionDispatch::DebugExceptions",
- "ActionDispatch::RemoteIp",
- "ActionDispatch::Reloader",
- "ActionDispatch::Callbacks",
- "ActiveRecord::ConnectionAdapters::ConnectionManagement",
- "ActiveRecord::QueryCache",
- "ActionDispatch::ParamsParser",
- "ActionDispatch::Head",
- "Rack::ConditionalGet",
- "Rack::ETag"
- ], middleware
- end
-
test "Rack::Sendfile is not included by default" do
boot!
@@ -96,13 +66,13 @@ module ApplicationTests
assert_equal "Rack::Cache", middleware.first
end
- test "Rack::SSL is present when force_ssl is set" do
+ test "ActionDispatch::SSL is present when force_ssl is set" do
add_to_config "config.force_ssl = true"
boot!
- assert middleware.include?("Rack::SSL")
+ assert middleware.include?("ActionDispatch::SSL")
end
- test "Rack::SSL is configured with options when given" do
+ test "ActionDispatch::SSL is configured with options when given" do
add_to_config "config.force_ssl = true"
add_to_config "config.ssl_options = { :host => 'example.com' }"
boot!
diff --git a/railties/test/application/rake/notes_test.rb b/railties/test/application/rake/notes_test.rb
index b66433f64d..04abf9e3a1 100644
--- a/railties/test/application/rake/notes_test.rb
+++ b/railties/test/application/rake/notes_test.rb
@@ -28,7 +28,7 @@ module ApplicationTests
Dir.chdir(app_path) do
output = `bundle exec rake notes`
- lines = output.scan(/\[([0-9\s]+)\]/).flatten
+ lines = output.scan(/\[([0-9\s]+)\](\s)/)
assert_match /note in erb/, output
assert_match /note in haml/, output
@@ -38,8 +38,9 @@ module ApplicationTests
assert_equal 5, lines.size
- lines.each do |line_number|
- assert_equal 4, line_number.size
+ lines.each do |line|
+ assert_equal 4, line[0].size
+ assert_equal ' ', line[1]
end
end
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index fed9dce8e1..27d521485c 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -123,12 +123,13 @@ module ApplicationTests
end
def test_scaffold_tests_pass_by_default
- content = Dir.chdir(app_path) do
+ output = Dir.chdir(app_path) do
`rails generate scaffold user username:string password:string;
bundle exec rake db:migrate db:test:clone test`
end
- assert_match(/\d+ tests, \d+ assertions, 0 failures, 0 errors/, content)
+ assert_match(/7 tests, 13 assertions, 0 failures, 0 errors/, output)
+ assert_no_match(/Errors running/, output)
end
def test_rake_dump_structure_should_respect_db_structure_env_variable
@@ -139,6 +140,18 @@ module ApplicationTests
assert File.exists?(File.join(app_path, 'db', 'my_structure.sql'))
end
+ def test_rake_dump_structure_should_be_called_twice_when_migrate_redo
+ add_to_config "config.active_record.schema_format = :sql"
+
+ output = Dir.chdir(app_path) do
+ `rails g model post title:string;
+ bundle exec rake db:migrate:redo 2>&1 --trace;`
+ end
+
+ # expect only Invoke db:structure:dump (first_time)
+ assert_no_match(/^\*\* Invoke db:structure:dump\s+$/, output)
+ end
+
def test_rake_dump_schema_cache
Dir.chdir(app_path) do
`rails generate model post title:string;
diff --git a/railties/test/commands/console_test.rb b/railties/test/commands/console_test.rb
index 01847ae58c..9aa1d68675 100644
--- a/railties/test/commands/console_test.rb
+++ b/railties/test/commands/console_test.rb
@@ -55,6 +55,25 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
assert_match /Loading \w+ environment in sandbox \(Rails/, output
end
+ def test_console_with_environment
+ app.expects(:sandbox=).with(nil)
+ FakeConsole.expects(:start)
+
+ start ["-e production"]
+
+ assert_match /production/, output
+ end
+
+ def test_console_with_rails_environment
+ app.expects(:sandbox=).with(nil)
+ FakeConsole.expects(:start)
+
+ start ["RAILS_ENV=production"]
+
+ assert_match /production/, output
+ end
+
+
def test_console_defaults_to_IRB
config = mock("config", :console => nil)
app = mock("app", :config => config)
diff --git a/railties/test/commands/server_test.rb b/railties/test/commands/server_test.rb
new file mode 100644
index 0000000000..8039aec873
--- /dev/null
+++ b/railties/test/commands/server_test.rb
@@ -0,0 +1,26 @@
+require 'abstract_unit'
+require 'rails/commands/server'
+
+class Rails::ServerTest < ActiveSupport::TestCase
+
+ def test_environment_with_server_option
+ args = ["thin", "RAILS_ENV=production"]
+ options = Rails::Server::Options.new.parse!(args)
+ assert_equal 'production', options[:environment]
+ assert_equal 'thin', options[:server]
+ end
+
+ def test_environment_without_server_option
+ args = ["RAILS_ENV=production"]
+ options = Rails::Server::Options.new.parse!(args)
+ assert_equal 'production', options[:environment]
+ assert_nil options[:server]
+ end
+
+ def test_server_option_without_environment
+ args = ["thin"]
+ options = Rails::Server::Options.new.parse!(args)
+ assert_nil options[:environment]
+ assert_equal 'thin', options[:server]
+ end
+end
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 4db0cdc28e..d8887a6471 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -236,7 +236,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
if defined?(JRUBY_VERSION)
assert_file "Gemfile", /gem\s+["']therubyrhino["']$/
else
- assert_file "Gemfile", /# gem\s+["']therubyracer["']$/
+ assert_file "Gemfile", /# gem\s+["']therubyracer["']+, :platform => :ruby$/
end
end
@@ -371,7 +371,6 @@ protected
def action(*args, &block)
silence(:stdout) { generator.send(*args, &block) }
end
-
end
class CustomAppGeneratorTest < Rails::Generators::TestCase
diff --git a/railties/test/generators/migration_generator_test.rb b/railties/test/generators/migration_generator_test.rb
index 4e08e5dae1..fd84164340 100644
--- a/railties/test/generators/migration_generator_test.rb
+++ b/railties/test/generators/migration_generator_test.rb
@@ -41,6 +41,24 @@ class MigrationGeneratorTest < Rails::Generators::TestCase
end
end
+ def test_remove_migration_with_indexed_attribute
+ migration = "remove_title_body_from_posts"
+ run_generator [migration, "title:string:index", "body:text"]
+
+ assert_migration "db/migrate/#{migration}.rb" do |content|
+ assert_method :up, content do |up|
+ assert_match(/remove_column :posts, :title/, up)
+ assert_match(/remove_column :posts, :body/, up)
+ end
+
+ assert_method :down, content do |down|
+ assert_match(/add_column :posts, :title, :string/, down)
+ assert_match(/add_column :posts, :body, :text/, down)
+ assert_match(/add_index :posts, :title/, down)
+ end
+ end
+ end
+
def test_remove_migration_with_attributes
migration = "remove_title_body_from_posts"
run_generator [migration, "title:string", "body:text"]
diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb
index 14a20eddb8..92117855b7 100644
--- a/railties/test/generators/shared_generator_tests.rb
+++ b/railties/test/generators/shared_generator_tests.rb
@@ -91,21 +91,6 @@ module SharedGeneratorTests
assert_match(/It works!/, capture(:stdout) { generator.invoke_all })
end
- def test_template_raises_an_error_with_invalid_path
- content = capture(:stderr){ run_generator([destination_root, "-m", "non/existant/path"]) }
- assert_match(/The template \[.*\] could not be loaded/, content)
- assert_match(/non\/existant\/path/, content)
- end
-
- def test_template_is_executed_when_supplied
- path = "http://gist.github.com/103208.txt"
- template = %{ say "It works!" }
- template.instance_eval "def read; self; end" # Make the string respond to read
-
- generator([destination_root], :template => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template)
- assert_match(/It works!/, capture(:stdout) { generator.invoke_all })
- end
-
def test_template_is_executed_when_supplied_an_https_path
path = "https://gist.github.com/103208.txt"
template = %{ say "It works!" }
diff --git a/railties/test/isolation/abstract_unit.rb b/railties/test/isolation/abstract_unit.rb
index dc52c79fb5..ac4c2abfc8 100644
--- a/railties/test/isolation/abstract_unit.rb
+++ b/railties/test/isolation/abstract_unit.rb
@@ -116,7 +116,12 @@ module TestHelpers
end
end
- add_to_config 'config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"; config.session_store :cookie_store, :key => "_myapp_session"; config.active_support.deprecation = :log'
+ add_to_config <<-RUBY
+ config.secret_token = "3b7cd727ee24e8444053437c36cc66c4"
+ config.session_store :cookie_store, :key => "_myapp_session"
+ config.active_support.deprecation = :log
+ config.action_controller.allow_forgery_protection = false
+ RUBY
end
def teardown_app