aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.rdoc4
-rw-r--r--actionmailer/CHANGELOG8
-rw-r--r--actionmailer/README.rdoc22
-rw-r--r--actionmailer/lib/action_mailer/base.rb22
-rw-r--r--actionmailer/lib/action_mailer/delivery_methods.rb4
-rw-r--r--actionmailer/lib/action_mailer/mail_helper.rb4
-rw-r--r--actionmailer/lib/action_mailer/old_api.rb32
-rw-r--r--actionmailer/lib/action_mailer/tmail_compat.rb6
-rw-r--r--actionmailer/test/base_test.rb16
-rw-r--r--actionmailer/test/delivery_methods_test.rb6
-rw-r--r--actionmailer/test/fixtures/raw_email102
-rw-r--r--actionmailer/test/fixtures/raw_email22
-rw-r--r--actionmailer/test/fixtures/raw_email32
-rw-r--r--actionmailer/test/fixtures/raw_email52
-rw-r--r--actionmailer/test/fixtures/raw_email62
-rw-r--r--actionmailer/test/fixtures/raw_email82
-rw-r--r--actionmailer/test/fixtures/raw_email910
-rw-r--r--actionmailer/test/fixtures/templates/signed_up.erb2
-rw-r--r--actionmailer/test/fixtures/test_mailer/custom_templating_extension.html.haml4
-rw-r--r--actionmailer/test/fixtures/test_mailer/custom_templating_extension.text.haml4
-rw-r--r--actionmailer/test/fixtures/test_mailer/signed_up.html.erb2
-rw-r--r--actionmailer/test/fixtures/url_test_mailer/signed_up_with_url.erb2
-rw-r--r--actionmailer/test/mailers/proc_mailer.rb6
-rw-r--r--actionmailer/test/old_base/mail_service_test.rb30
-rw-r--r--actionmailer/test/old_base/tmail_compat_test.rb2
-rw-r--r--actionmailer/test/old_base/url_test.rb2
-rw-r--r--actionmailer/test/test_helper_test.rb24
-rw-r--r--actionpack/CHANGELOG4
-rw-r--r--actionpack/README.rdoc4
-rw-r--r--actionpack/RUNNING_UNIT_TESTS4
-rw-r--r--actionpack/lib/abstract_controller/base.rb2
-rw-r--r--actionpack/lib/action_controller/metal/http_authentication.rb4
-rw-r--r--actionpack/lib/action_controller/middleware.rb2
-rw-r--r--actionpack/lib/action_controller/test_case.rb2
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/document.rb4
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/node.rb58
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb50
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb2
-rw-r--r--actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb16
-rw-r--r--actionpack/lib/action_dispatch/http/mime_type.rb20
-rw-r--r--actionpack/lib/action_dispatch/middleware/stack.rb2
-rw-r--r--actionpack/lib/action_dispatch/routing.rb8
-rw-r--r--actionpack/lib/action_view/helpers/debug_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb16
-rw-r--r--actionpack/lib/action_view/helpers/form_tag_helper.rb16
-rw-r--r--actionpack/lib/action_view/helpers/number_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/raw_output_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/sanitize_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/translation_helper.rb18
-rw-r--r--actionpack/lib/action_view/log_subscriber.rb2
-rw-r--r--actionpack/lib/action_view/template/handler.rb2
-rw-r--r--actionpack/lib/action_view/template/handlers.rb2
-rw-r--r--actionpack/lib/action_view/test_case.rb2
-rw-r--r--actionpack/lib/action_view/testing/resolvers.rb2
-rw-r--r--actionpack/test/abstract/callbacks_test.rb92
-rw-r--r--actionpack/test/abstract/helper_test.rb8
-rw-r--r--actionpack/test/abstract/translation_test.rb8
-rw-r--r--actionpack/test/abstract_unit.rb2
-rw-r--r--actionpack/test/controller/assert_select_test.rb2
-rw-r--r--actionpack/test/controller/base_test.rb12
-rw-r--r--actionpack/test/controller/dispatcher_test.rb2
-rw-r--r--actionpack/test/controller/filters_test.rb2
-rw-r--r--actionpack/test/controller/helper_test.rb14
-rw-r--r--actionpack/test/controller/http_basic_authentication_test.rb6
-rw-r--r--actionpack/test/controller/http_token_authentication_test.rb6
-rw-r--r--actionpack/test/controller/layout_test.rb4
-rw-r--r--actionpack/test/controller/mime_responds_test.rb10
-rw-r--r--actionpack/test/controller/new_base/etag_test.rb2
-rw-r--r--actionpack/test/controller/new_base/render_implicit_action_test.rb4
-rw-r--r--actionpack/test/controller/new_base/render_layout_test.rb2
-rw-r--r--actionpack/test/controller/new_base/render_partial_test.rb14
-rw-r--r--actionpack/test/controller/new_base/render_test.rb2
-rw-r--r--actionpack/test/controller/new_base/render_text_test.rb24
-rw-r--r--actionpack/test/controller/new_base/render_xml_test.rb2
-rw-r--r--actionpack/test/controller/render_test.rb4
-rw-r--r--actionpack/test/controller/rescue_test.rb2
-rw-r--r--actionpack/test/controller/selector_test.rb8
-rw-r--r--actionpack/test/controller/test_test.rb2
-rw-r--r--actionpack/test/controller/view_paths_test.rb4
-rw-r--r--actionpack/test/dispatch/callbacks_test.rb2
-rw-r--r--actionpack/test/dispatch/mount_test.rb2
-rw-r--r--actionpack/test/dispatch/request_test.rb2
-rw-r--r--actionpack/test/dispatch/session/cookie_store_test.rb8
-rw-r--r--actionpack/test/dispatch/session/mem_cache_store_test.rb2
-rw-r--r--actionpack/test/fixtures/companies.yml2
-rw-r--r--actionpack/test/fixtures/company.rb2
-rw-r--r--actionpack/test/fixtures/db_definitions/sqlite.sql20
-rw-r--r--actionpack/test/fixtures/replies.yml2
-rw-r--r--actionpack/test/fixtures/test/hello_xml_world.builder2
-rw-r--r--actionpack/test/fixtures/topics.yml2
-rw-r--r--actionpack/test/template/compiled_templates_test.rb2
-rw-r--r--actionpack/test/template/date_helper_i18n_test.rb2
-rw-r--r--actionpack/test/template/date_helper_test.rb28
-rw-r--r--actionpack/test/template/erb_util_test.rb2
-rw-r--r--actionpack/test/template/form_options_helper_test.rb12
-rw-r--r--actionpack/test/template/html-scanner/document_test.rb2
-rw-r--r--actionpack/test/template/html-scanner/node_test.rb18
-rw-r--r--actionpack/test/template/html-scanner/sanitizer_test.rb34
-rw-r--r--actionpack/test/template/html-scanner/tag_node_test.rb46
-rw-r--r--actionpack/test/template/html-scanner/text_node_test.rb10
-rw-r--r--actionpack/test/template/html-scanner/tokenizer_test.rb20
-rw-r--r--actionpack/test/template/number_helper_test.rb2
-rw-r--r--actionpack/test/template/tag_helper_test.rb6
-rw-r--r--actionpack/test/template/text_helper_test.rb12
-rw-r--r--actionpack/test/template/translation_helper_test.rb8
-rw-r--r--actionpack/test/template/url_helper_test.rb4
-rw-r--r--activemodel/CHANGELOG2
-rw-r--r--activemodel/README.rdoc54
-rw-r--r--activemodel/lib/active_model/attribute_methods.rb84
-rw-r--r--activemodel/lib/active_model/callbacks.rb58
-rw-r--r--activemodel/lib/active_model/conversion.rb12
-rw-r--r--activemodel/lib/active_model/dirty.rb36
-rw-r--r--activemodel/lib/active_model/errors.rb60
-rw-r--r--activemodel/lib/active_model/lint.rb2
-rw-r--r--activemodel/lib/active_model/naming.rb10
-rw-r--r--activemodel/lib/active_model/observing.rb14
-rw-r--r--activemodel/lib/active_model/serialization.rb44
-rw-r--r--activemodel/lib/active_model/serializers/xml.rb2
-rw-r--r--activemodel/lib/active_model/translation.rb14
-rw-r--r--activemodel/lib/active_model/validations.rb32
-rw-r--r--activemodel/lib/active_model/validations/acceptance.rb22
-rw-r--r--activemodel/lib/active_model/validations/confirmation.rb20
-rw-r--r--activemodel/lib/active_model/validations/length.rb2
-rw-r--r--activemodel/lib/active_model/validations/validates.rb10
-rw-r--r--activemodel/lib/active_model/validator.rb22
-rw-r--r--activemodel/test/cases/attribute_methods_test.rb4
-rw-r--r--activemodel/test/cases/serializeration/json_serialization_test.rb10
-rw-r--r--activemodel/test/cases/translation_test.rb4
-rw-r--r--activemodel/test/cases/validations/validates_test.rb8
-rw-r--r--activemodel/test/cases/validations_test.rb2
-rw-r--r--activemodel/test/models/custom_reader.rb4
-rw-r--r--activemodel/test/models/person_with_validator.rb2
-rw-r--r--activemodel/test/models/sheep.rb1
-rw-r--r--activerecord/README.rdoc18
-rw-r--r--activerecord/RUNNING_UNIT_TESTS16
-rw-r--r--activerecord/lib/active_record/aggregations.rb96
-rw-r--r--activerecord/lib/active_record/association_preload.rb8
-rw-r--r--activerecord/lib/active_record/associations.rb344
-rw-r--r--activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb6
-rw-r--r--activerecord/lib/active_record/associations/has_many_association.rb8
-rw-r--r--activerecord/lib/active_record/associations/has_many_through_association.rb6
-rw-r--r--activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb2
-rw-r--r--activerecord/lib/active_record/attribute_methods/write.rb2
-rw-r--r--activerecord/lib/active_record/autosave_association.rb10
-rw-r--r--activerecord/lib/active_record/base.rb174
-rw-r--r--activerecord/lib/active_record/callbacks.rb48
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb6
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb4
-rw-r--r--activerecord/lib/active_record/connection_adapters/mysql_adapter.rb2
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb8
-rw-r--r--activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb2
-rw-r--r--activerecord/lib/active_record/dynamic_finder_match.rb2
-rw-r--r--activerecord/lib/active_record/dynamic_scope_match.rb2
-rw-r--r--activerecord/lib/active_record/errors.rb8
-rw-r--r--activerecord/lib/active_record/fixtures.rb36
-rw-r--r--activerecord/lib/active_record/locale/en.yml4
-rw-r--r--activerecord/lib/active_record/migration.rb66
-rw-r--r--activerecord/lib/active_record/named_scope.rb24
-rw-r--r--activerecord/lib/active_record/nested_attributes.rb2
-rw-r--r--activerecord/lib/active_record/observer.rb2
-rw-r--r--activerecord/lib/active_record/reflection.rb26
-rw-r--r--activerecord/lib/active_record/relation.rb8
-rw-r--r--activerecord/lib/active_record/relation/calculations.rb52
-rw-r--r--activerecord/lib/active_record/relation/finder_methods.rb14
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb2
-rw-r--r--activerecord/lib/active_record/schema_dumper.rb4
-rw-r--r--activerecord/lib/active_record/serialization.rb2
-rw-r--r--activerecord/lib/active_record/serializers/xml_serializer.rb2
-rw-r--r--activerecord/lib/active_record/session_store.rb2
-rw-r--r--activerecord/lib/active_record/test_case.rb2
-rw-r--r--activerecord/lib/active_record/validations/associated.rb4
-rw-r--r--activerecord/lib/active_record/validations/uniqueness.rb20
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb4
-rw-r--r--activerecord/test/cases/associations/has_one_through_associations_test.rb14
-rw-r--r--activerecord/test/cases/associations/join_model_test.rb10
-rw-r--r--activerecord/test/cases/associations_test.rb6
-rw-r--r--activerecord/test/cases/attribute_methods_test.rb8
-rw-r--r--activerecord/test/cases/autosave_association_test.rb2
-rw-r--r--activerecord/test/cases/counter_cache_test.rb2
-rw-r--r--activerecord/test/cases/defaults_test.rb6
-rw-r--r--activerecord/test/cases/dirty_test.rb14
-rw-r--r--activerecord/test/cases/fixtures_test.rb16
-rw-r--r--activerecord/test/cases/i18n_test.rb4
-rw-r--r--activerecord/test/cases/json_serialization_test.rb2
-rw-r--r--activerecord/test/cases/migration_test.rb4
-rw-r--r--activerecord/test/cases/modules_test.rb4
-rw-r--r--activerecord/test/cases/nested_attributes_test.rb20
-rw-r--r--activerecord/test/cases/persistence_test.rb4
-rw-r--r--activerecord/test/cases/reflection_test.rb2
-rw-r--r--activerecord/test/cases/relation_scoping_test.rb4
-rw-r--r--activerecord/test/cases/relations_test.rb4
-rw-r--r--activerecord/test/cases/serialization_test.rb2
-rw-r--r--activerecord/test/cases/timestamp_test.rb28
-rw-r--r--activerecord/test/fixtures/comments.yml4
-rw-r--r--activerecord/test/fixtures/companies.yml10
-rw-r--r--activerecord/test/fixtures/items.yml1
-rw-r--r--activerecord/test/fixtures/memberships.yml2
-rw-r--r--activerecord/test/fixtures/mixins.yml2
-rw-r--r--activerecord/test/fixtures/taggings.yml2
-rw-r--r--activerecord/test/fixtures/tags.yml2
-rw-r--r--activerecord/test/models/developer.rb2
-rw-r--r--activerecord/test/models/minivan.rb4
-rw-r--r--activerecord/test/models/post.rb2
-rw-r--r--activerecord/test/models/shop.rb2
-rw-r--r--activerecord/test/models/topic.rb2
-rw-r--r--activerecord/test/schema/postgresql_specific_schema.rb2
-rw-r--r--activerecord/test/schema/schema.rb6
-rw-r--r--activeresource/CHANGELOG22
-rw-r--r--activeresource/README.rdoc8
-rw-r--r--activeresource/lib/active_resource/http_mock.rb8
-rw-r--r--activeresource/lib/active_resource/validations.rb16
-rw-r--r--activeresource/test/cases/base/custom_methods_test.rb10
-rw-r--r--activeresource/test/cases/validations_test.rb2
-rw-r--r--activeresource/test/connection_test.rb4
-rw-r--r--activesupport/CHANGELOG68
-rw-r--r--activesupport/lib/active_support/base64.rb6
-rw-r--r--activesupport/lib/active_support/benchmarkable.rb6
-rw-r--r--activesupport/lib/active_support/cache.rb22
-rw-r--r--activesupport/lib/active_support/cache/strategy/local_cache.rb2
-rw-r--r--activesupport/lib/active_support/callbacks.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/array/random_access.rb8
-rw-r--r--activesupport/lib/active_support/core_ext/array/wrap.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/date/calculations.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/conversions.rb12
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/zones.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/enumerable.rb8
-rw-r--r--activesupport/lib/active_support/core_ext/hash/conversions.rb22
-rw-r--r--activesupport/lib/active_support/core_ext/integer/time.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/module/anonymous.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/module/attribute_accessors.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/module/remove_method.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/module/synchronization.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/numeric/time.rb18
-rw-r--r--activesupport/lib/active_support/core_ext/object/blank.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/object/instance_variables.rb10
-rw-r--r--activesupport/lib/active_support/core_ext/object/returning.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/range/conversions.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/string/access.rb14
-rw-r--r--activesupport/lib/active_support/core_ext/string/inflections.rb12
-rw-r--r--activesupport/lib/active_support/core_ext/time/calculations.rb4
-rw-r--r--activesupport/lib/active_support/core_ext/time/conversions.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/time/zones.rb6
-rw-r--r--activesupport/lib/active_support/duration.rb2
-rw-r--r--activesupport/lib/active_support/i18n_railtie.rb2
-rw-r--r--activesupport/lib/active_support/lazy_load_hooks.rb4
-rw-r--r--activesupport/lib/active_support/locale/en.yml6
-rw-r--r--activesupport/lib/active_support/log_subscriber.rb2
-rw-r--r--activesupport/lib/active_support/log_subscriber/test_helper.rb2
-rw-r--r--activesupport/lib/active_support/message_encryptor.rb34
-rw-r--r--activesupport/lib/active_support/message_verifier.rb14
-rw-r--r--activesupport/lib/active_support/multibyte.rb2
-rw-r--r--activesupport/lib/active_support/ordered_hash.rb4
-rw-r--r--activesupport/lib/active_support/ordered_options.rb6
-rw-r--r--activesupport/lib/active_support/testing/assertions.rb4
-rw-r--r--activesupport/lib/active_support/testing/declarative.rb8
-rw-r--r--activesupport/lib/active_support/testing/pending.rb6
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb4
-rw-r--r--activesupport/lib/active_support/xml_mini/rexml.rb2
-rw-r--r--activesupport/test/autoloading_fixtures/class_folder/nested_class.rb2
-rw-r--r--activesupport/test/clean_backtrace_test.rb14
-rw-r--r--activesupport/test/clean_logger_test.rb4
-rw-r--r--activesupport/test/core_ext/array_ext_test.rb12
-rw-r--r--activesupport/test/core_ext/class/attribute_accessor_test.rb10
-rw-r--r--activesupport/test/core_ext/class/class_inheritable_attributes_test.rb22
-rw-r--r--activesupport/test/core_ext/date_ext_test.rb16
-rw-r--r--activesupport/test/core_ext/date_time_ext_test.rb2
-rw-r--r--activesupport/test/core_ext/duration_test.rb4
-rw-r--r--activesupport/test/core_ext/enumerable_test.rb2
-rw-r--r--activesupport/test/core_ext/hash_ext_test.rb42
-rw-r--r--activesupport/test/core_ext/kernel_test.rb2
-rw-r--r--activesupport/test/core_ext/module/anonymous_test.rb2
-rw-r--r--activesupport/test/core_ext/module/attr_accessor_with_default_test.rb8
-rw-r--r--activesupport/test/core_ext/module/attribute_accessor_test.rb2
-rw-r--r--activesupport/test/core_ext/module/attribute_aliasing_test.rb6
-rw-r--r--activesupport/test/core_ext/module/reachable_test.rb16
-rw-r--r--activesupport/test/core_ext/numeric_ext_test.rb24
-rw-r--r--activesupport/test/core_ext/object_and_class_ext_test.rb2
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb2
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb20
-rw-r--r--activesupport/test/core_ext/time_with_zone_test.rb6
-rw-r--r--activesupport/test/i18n_test.rb34
-rw-r--r--activesupport/test/message_encryptor_test.rb14
-rw-r--r--activesupport/test/multibyte_conformance.rb30
-rw-r--r--activesupport/test/option_merger_test.rb2
-rw-r--r--activesupport/test/rescuable_test.rb8
-rw-r--r--activesupport/test/test_test.rb20
-rw-r--r--activesupport/test/time_zone_test.rb2
-rw-r--r--ci/ci_setup_notes.txt6
-rw-r--r--ci/site_config.rb12
-rw-r--r--railties/CHANGELOG150
-rw-r--r--railties/README.rdoc2
-rw-r--r--railties/guides/assets/stylesheets/main.css28
-rw-r--r--railties/guides/rails_guides/generator.rb14
-rw-r--r--railties/guides/source/2_3_release_notes.textile10
-rw-r--r--railties/guides/source/action_controller_overview.textile14
-rw-r--r--railties/guides/source/action_view_overview.textile88
-rw-r--r--railties/guides/source/active_record_basics.textile4
-rw-r--r--railties/guides/source/active_record_querying.textile12
-rw-r--r--railties/guides/source/active_record_validations_callbacks.textile40
-rw-r--r--railties/guides/source/active_support_core_extensions.textile16
-rw-r--r--railties/guides/source/ajax_on_rails.textile34
-rw-r--r--railties/guides/source/api_documentation_guidelines.textile4
-rw-r--r--railties/guides/source/association_basics.textile4
-rw-r--r--railties/guides/source/caching_with_rails.textile10
-rw-r--r--railties/guides/source/command_line.textile4
-rw-r--r--railties/guides/source/configuring.textile10
-rw-r--r--railties/guides/source/getting_started.textile22
-rw-r--r--railties/guides/source/i18n.textile2
-rw-r--r--railties/guides/source/initialization.textile110
-rw-r--r--railties/guides/source/layouts_and_rendering.textile18
-rw-r--r--railties/guides/source/nested_model_forms.textile14
-rw-r--r--railties/guides/source/plugins.textile2
-rw-r--r--railties/guides/source/rails_application_templates.textile4
-rw-r--r--railties/guides/source/routing.textile4
-rw-r--r--railties/guides/source/security.textile2
-rw-r--r--railties/guides/w3c_validator.rb18
-rw-r--r--railties/lib/rails/code_statistics.rb8
-rw-r--r--railties/lib/rails/generators/base.rb2
-rw-r--r--railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js2
-rw-r--r--railties/lib/rails/generators/rails/generator/USAGE2
-rw-r--r--railties/lib/rails/generators/rails/migration/USAGE8
-rw-r--r--railties/lib/rails/generators/rails/plugin/USAGE2
-rw-r--r--railties/lib/rails/generators/rails/resource/resource_generator.rb4
-rw-r--r--railties/lib/rails/plugin.rb2
-rw-r--r--railties/lib/rails/railtie.rb4
-rw-r--r--railties/lib/rails/script_rails_loader.rb4
-rw-r--r--railties/lib/rails/tasks/documentation.rake8
-rw-r--r--railties/test/application/loading_test.rb6
-rw-r--r--railties/test/application/rake_test.rb2
-rw-r--r--railties/test/generators/actions_test.rb4
-rw-r--r--railties/test/generators/app_generator_test.rb2
-rw-r--r--railties/test/railties/railtie_test.rb2
-rw-r--r--railties/test/script_rails_loader_test.rb8
337 files changed, 2122 insertions, 2124 deletions
diff --git a/README.rdoc b/README.rdoc
index 090a6bb68c..2e5e72c0e4 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -34,7 +34,7 @@ link:files/vendor/rails/actionpack/README.html.
2. At the command prompt, create a new Rails application:
- rails new myapp
+ rails new myapp
where "myapp" is the application name.
@@ -48,7 +48,7 @@ link:files/vendor/rails/actionpack/README.html.
"Welcome aboard: You're riding Ruby on Rails!"
-5. Follow the guidelines to start developing your application. You can find
+5. Follow the guidelines to start developing your application. You can find
the following resources handy:
* The README file created within your application.
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG
index 76eab935e5..d2cc70fc85 100644
--- a/actionmailer/CHANGELOG
+++ b/actionmailer/CHANGELOG
@@ -181,7 +181,7 @@
* ActionMailer::Base documentation rewrite. Closes #4991 [Kevin Clark, Marcel Molina Jr.]
-* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
+* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
@@ -327,7 +327,7 @@
* Added that deliver_* will now return the email that was sent
-* Added that quoting to UTF-8 only happens if the characters used are in that range #955 [Jamis Buck]
+* Added that quoting to UTF-8 only happens if the characters used are in that range #955 [Jamis Buck]
* Fixed quoting for all address headers, not just to #955 [Jamis Buck]
@@ -366,7 +366,7 @@
@body = "Nothing to see here."
@charset = "iso-8859-1"
end
-
+
def unencoded_subject(recipient)
@recipients = recipient
@subject = "testing unencoded subject"
@@ -375,7 +375,7 @@
@encode_subject = false
@charset = "iso-8859-1"
end
-
+
*0.6.1* (January 18th, 2005)
diff --git a/actionmailer/README.rdoc b/actionmailer/README.rdoc
index 602326eef7..dfb696eb55 100644
--- a/actionmailer/README.rdoc
+++ b/actionmailer/README.rdoc
@@ -5,7 +5,7 @@ are used to consolidate code for sending out forgotten passwords, welcome
wishes on signup, invoices for billing, and any other use case that requires
a written notification to either a person or another system.
-Action Mailer is in essence a wrapper around Action Controller and the
+Action Mailer is in essence a wrapper around Action Controller and the
Mail gem. It provides a way to make emails using templates in the same
way that Action Controller renders views using templates.
@@ -23,7 +23,7 @@ This can be as simple as:
class Notifier < ActionMailer::Base
delivers_from 'system@loudthinking.com'
-
+
def welcome(recipient)
@recipient = recipient
mail(:to => recipient,
@@ -36,13 +36,13 @@ ERb) that has the instance variables that are declared in the mailer action.
So the corresponding body template for the method above could look like this:
- Hello there,
+ Hello there,
Mr. <%= @recipient %>
Thank you for signing up!
-
-And if the recipient was given as "david@loudthinking.com", the email
+
+And if the recipient was given as "david@loudthinking.com", the email
generated would look like this:
Date: Mon, 25 Jan 2010 22:48:09 +1100
@@ -55,7 +55,7 @@ generated would look like this:
charset="US-ASCII";
Content-Transfer-Encoding: 7bit
- Hello there,
+ Hello there,
Mr. david@loudthinking.com
@@ -75,7 +75,7 @@ Or you can just chain the methods together like:
== Receiving emails
To receive emails, you need to implement a public instance method called <tt>receive</tt> that takes a
-tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
+tmail object as its single parameter. The Action Mailer framework has a corresponding class method,
which is also called <tt>receive</tt>, that accepts a raw, unprocessed email as a string, which it then turns
into the tmail object and calls the receive instance method.
@@ -90,7 +90,7 @@ Example:
if email.has_attachments?
for attachment in email.attachments
- page.attachments.create({
+ page.attachments.create({
:file => attachment, :description => email.subject
})
end
@@ -98,13 +98,13 @@ Example:
end
end
-This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the
+This Mailman can be the target for Postfix or other MTAs. In Rails, you would use the runner in the
trivial case like this:
rails runner 'Mailman.receive(STDIN.read)'
-However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
-instance of Rails should be run within a daemon if it is going to be utilized to process more than just
+However, invoking Rails in the runner for each mail to be received is very resource intensive. A single
+instance of Rails should be run within a daemon if it is going to be utilized to process more than just
a limited number of email.
== Configuration
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb
index f742f982f2..8fe5868d52 100644
--- a/actionmailer/lib/action_mailer/base.rb
+++ b/actionmailer/lib/action_mailer/base.rb
@@ -187,31 +187,31 @@ module ActionMailer #:nodoc:
# with the filename +free_book.pdf+.
#
# = Inline Attachments
- #
- # You can also specify that a file should be displayed inline with other HTML. This is useful
+ #
+ # You can also specify that a file should be displayed inline with other HTML. This is useful
# if you want to display a corporate logo or a photo.
- #
+ #
# class ApplicationMailer < ActionMailer::Base
# def welcome(recipient)
# attachments.inline['photo.png'] = File.read('path/to/photo.png')
# mail(:to => recipient, :subject => "Here is what we look like")
# end
# end
- #
+ #
# And then to reference the image in the view, you create a <tt>welcome.html.erb</tt> file and
- # make a call to +image_tag+ passing in the attachment you want to display and then call
+ # make a call to +image_tag+ passing in the attachment you want to display and then call
# +url+ on the attachment to get the relative content id path for the image source:
- #
+ #
# <h1>Please Don't Cringe</h1>
- #
+ #
# <%= image_tag attachments['photo.png'].url -%>
- #
+ #
# As we are using Action View's +image_tag+ method, you can pass in any other options you want:
- #
+ #
# <h1>Please Don't Cringe</h1>
- #
+ #
# <%= image_tag attachments['photo.png'].url, :alt => 'Our Photo', :class => 'photo' -%>
- #
+ #
# = Observing and Intercepting Mails
#
# Action Mailer provides hooks into the Mail observer and interceptor methods. These allow you to
diff --git a/actionmailer/lib/action_mailer/delivery_methods.rb b/actionmailer/lib/action_mailer/delivery_methods.rb
index 043794bb12..b324ba790d 100644
--- a/actionmailer/lib/action_mailer/delivery_methods.rb
+++ b/actionmailer/lib/action_mailer/delivery_methods.rb
@@ -46,11 +46,11 @@ module ActionMailer
# as alias and the default options supplied:
#
# Example:
- #
+ #
# add_delivery_method :sendmail, Mail::Sendmail,
# :location => '/usr/sbin/sendmail',
# :arguments => '-i -t'
- #
+ #
def add_delivery_method(symbol, klass, default_options={})
class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
send(:"#{symbol}_settings=", default_options)
diff --git a/actionmailer/lib/action_mailer/mail_helper.rb b/actionmailer/lib/action_mailer/mail_helper.rb
index b708881edf..80ffc9b7ee 100644
--- a/actionmailer/lib/action_mailer/mail_helper.rb
+++ b/actionmailer/lib/action_mailer/mail_helper.rb
@@ -15,11 +15,11 @@ module ActionMailer
:columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph
).format
}.join("\n")
-
+
# Make list points stand on their own line
formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| " #{$1} #{$2.strip}\n" }
formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { |s| " #{$1} #{$2.strip}\n" }
-
+
formatted
end
diff --git a/actionmailer/lib/action_mailer/old_api.rb b/actionmailer/lib/action_mailer/old_api.rb
index 79d024a350..2a6289c22d 100644
--- a/actionmailer/lib/action_mailer/old_api.rb
+++ b/actionmailer/lib/action_mailer/old_api.rb
@@ -116,36 +116,36 @@ module ActionMailer
def normalize_nonfile_hash(params)
content_disposition = "attachment;"
-
+
mime_type = params.delete(:mime_type)
-
+
if content_type = params.delete(:content_type)
content_type = "#{mime_type || content_type};"
end
params[:body] = params.delete(:data) if params[:data]
-
+
{ :content_type => content_type,
:content_disposition => content_disposition }.merge(params)
end
-
+
def normalize_file_hash(params)
filename = File.basename(params.delete(:filename))
content_disposition = "attachment; filename=\"#{File.basename(filename)}\""
-
+
mime_type = params.delete(:mime_type)
-
+
if (content_type = params.delete(:content_type)) && (content_type !~ /filename=/)
content_type = "#{mime_type || content_type}; filename=\"#{filename}\""
end
-
+
params[:body] = params.delete(:data) if params[:data]
-
+
{ :content_type => content_type,
:content_disposition => content_disposition }.merge(params)
end
- def create_mail
+ def create_mail
m = @_message
set_fields!({:subject => subject, :to => recipients, :from => from,
@@ -178,14 +178,14 @@ module ActionMailer
wrap_delivery_behavior!
m.content_transfer_encoding = '8bit' unless m.body.only_us_ascii?
-
+
@_message
end
-
+
# Set up the default values for the various instance variables of this
# mailer. Subclasses may override this method to provide different
# defaults.
- def initialize_defaults(method_name)
+ def initialize_defaults(method_name)
@charset ||= self.class.default[:charset].try(:dup)
@content_type ||= self.class.default[:content_type].try(:dup)
@implicit_parts_order ||= self.class.default[:parts_order].try(:dup)
@@ -201,7 +201,7 @@ module ActionMailer
@body ||= {}
end
- def create_parts
+ def create_parts
if String === @body
@parts.unshift create_inline_part(@body)
elsif @parts.empty? || @parts.all? { |p| p.content_disposition =~ /^attachment/ }
@@ -220,7 +220,7 @@ module ActionMailer
end
end
- def create_inline_part(body, mime_type=nil)
+ def create_inline_part(body, mime_type=nil)
ct = mime_type || "text/plain"
main_type, sub_type = split_content_type(ct.to_s)
@@ -242,11 +242,11 @@ module ActionMailer
m.reply_to ||= headers.delete(:reply_to) if headers[:reply_to]
end
- def split_content_type(ct)
+ def split_content_type(ct)
ct.to_s.split("/")
end
- def parse_content_type(defaults=nil)
+ def parse_content_type(defaults=nil)
if @content_type.blank?
[ nil, {} ]
else
diff --git a/actionmailer/lib/action_mailer/tmail_compat.rb b/actionmailer/lib/action_mailer/tmail_compat.rb
index 26962f972f..26cc474e91 100644
--- a/actionmailer/lib/action_mailer/tmail_compat.rb
+++ b/actionmailer/lib/action_mailer/tmail_compat.rb
@@ -1,12 +1,12 @@
module Mail
class Message
-
+
def set_content_type(*args)
ActiveSupport::Deprecation.warn('Message#set_content_type is deprecated, please just call ' <<
'Message#content_type with the same arguments', caller[0,2])
content_type(*args)
end
-
+
alias :old_transfer_encoding :transfer_encoding
def transfer_encoding(value = nil)
if value
@@ -29,6 +29,6 @@ module Mail
'please call Message#filename', caller[0,2])
filename
end
-
+
end
end \ No newline at end of file
diff --git a/actionmailer/test/base_test.rb b/actionmailer/test/base_test.rb
index fec0ecf477..fb42ccb8aa 100644
--- a/actionmailer/test/base_test.rb
+++ b/actionmailer/test/base_test.rb
@@ -148,7 +148,7 @@ class BaseTest < ActiveSupport::TestCase
assert_equal("application/pdf", email.parts[1].mime_type)
assert_equal("VGhpcyBpcyB0ZXN0IEZpbGUgY29udGVudA==\r\n", email.parts[1].body.encoded)
end
-
+
test "can embed an inline attachment" do
email = BaseMailer.inline_attachment
# Need to call #encoded to force the JIT sort on parts
@@ -413,7 +413,7 @@ class BaseTest < ActiveSupport::TestCase
BaseMailer.welcome.deliver
assert_equal(1, BaseMailer.deliveries.length)
end
-
+
test "calling deliver, ActionMailer should yield back to mail to let it call :do_delivery on itself" do
mail = Mail::Message.new
mail.expects(:do_delivery).once
@@ -447,7 +447,7 @@ class BaseTest < ActiveSupport::TestCase
mail = BaseMailer.welcome_from_another_path(['unknown/invalid', 'another.path/base_mailer']).deliver
assert_equal("Welcome from another path", mail.body.encoded)
end
-
+
test "assets tags should use ActionMailer's asset_host settings" do
ActionMailer::Base.config.asset_host = "http://global.com"
ActionMailer::Base.config.assets_dir = "global/"
@@ -456,7 +456,7 @@ class BaseTest < ActiveSupport::TestCase
assert_equal(%{<img alt="Dummy" src="http://global.com/images/dummy.png" />}, mail.body.to_s.strip)
end
-
+
test "assets tags should use a Mailer's asset_host settings when available" do
ActionMailer::Base.config.asset_host = "global.com"
ActionMailer::Base.config.assets_dir = "global/"
@@ -469,12 +469,12 @@ class BaseTest < ActiveSupport::TestCase
end
# Before and After hooks
-
+
class MyObserver
def self.delivered_email(mail)
end
end
-
+
test "you can register an observer to the mail object that gets informed on email delivery" do
ActionMailer::Base.register_observer(MyObserver)
mail = BaseMailer.welcome
@@ -493,7 +493,7 @@ class BaseTest < ActiveSupport::TestCase
MyInterceptor.expects(:delivering_email).with(mail)
mail.deliver
end
-
+
test "being able to put proc's into the defaults hash and they get evaluated on mail sending" do
mail1 = ProcMailer.welcome
yesterday = 1.day.ago
@@ -501,7 +501,7 @@ class BaseTest < ActiveSupport::TestCase
mail2 = ProcMailer.welcome
assert(mail1['X-Proc-Method'].to_s.to_i > mail2['X-Proc-Method'].to_s.to_i)
end
-
+
test "we can call other defined methods on the class as needed" do
mail = ProcMailer.welcome
assert_equal("Thanks for signing up this afternoon", mail.subject)
diff --git a/actionmailer/test/delivery_methods_test.rb b/actionmailer/test/delivery_methods_test.rb
index 22a7d19bc2..08f84dbf3b 100644
--- a/actionmailer/test/delivery_methods_test.rb
+++ b/actionmailer/test/delivery_methods_test.rb
@@ -128,7 +128,7 @@ class MailDeliveryTest < ActiveSupport::TestCase
Mail::Message.any_instance.expects(:deliver!).never
DeliveryMailer.welcome.deliver
end
-
+
test "does not append the deliveries collection if told not to perform the delivery" do
DeliveryMailer.perform_deliveries = false
DeliveryMailer.deliveries.clear
@@ -160,7 +160,7 @@ class MailDeliveryTest < ActiveSupport::TestCase
DeliveryMailer.welcome.deliver
end
end
-
+
test "does not increment the deliveries collection on bogus deliveries" do
DeliveryMailer.delivery_method = BogusDelivery
DeliveryMailer.raise_delivery_errors = false
@@ -168,5 +168,5 @@ class MailDeliveryTest < ActiveSupport::TestCase
DeliveryMailer.welcome.deliver
assert_equal(0, DeliveryMailer.deliveries.length)
end
-
+
end
diff --git a/actionmailer/test/fixtures/raw_email10 b/actionmailer/test/fixtures/raw_email10
index b1fc2b2617..edad5ccff1 100644
--- a/actionmailer/test/fixtures/raw_email10
+++ b/actionmailer/test/fixtures/raw_email10
@@ -15,6 +15,6 @@ Content-Type: text/plain; charset=X-UNKNOWN
Test test. Hi. Waving. m
----------------------------------------------------------------
-Sent via Bell Mobility's Text Messaging service.
+Sent via Bell Mobility's Text Messaging service.
Envoyé par le service de messagerie texte de Bell Mobilité.
----------------------------------------------------------------
diff --git a/actionmailer/test/fixtures/raw_email2 b/actionmailer/test/fixtures/raw_email2
index 3999fcc877..9f87bb2a98 100644
--- a/actionmailer/test/fixtures/raw_email2
+++ b/actionmailer/test/fixtures/raw_email2
@@ -32,7 +32,7 @@ To: xxxxx xxxx <xxxxx@xxxxxxxxx.com>
Subject: Fwd: Signed email causes file attachments
In-Reply-To: <F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@mac.com>
Mime-Version: 1.0
-Content-Type: multipart/mixed;
+Content-Type: multipart/mixed;
boundary="----=_Part_5028_7368284.1115579351471"
References: <F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@mac.com>
diff --git a/actionmailer/test/fixtures/raw_email3 b/actionmailer/test/fixtures/raw_email3
index 771a96350d..3a0927490a 100644
--- a/actionmailer/test/fixtures/raw_email3
+++ b/actionmailer/test/fixtures/raw_email3
@@ -31,7 +31,7 @@ Reply-To: Test Tester <xxxx@xxxx.com>
To: xxxx@xxxx.com, xxxx@xxxx.com
Subject: Another PDF
Mime-Version: 1.0
-Content-Type: multipart/mixed;
+Content-Type: multipart/mixed;
boundary="----=_Part_2192_32400445.1115745999735"
X-Virus-Scanned: amavisd-new at textdrive.com
diff --git a/actionmailer/test/fixtures/raw_email5 b/actionmailer/test/fixtures/raw_email5
index 151c631471..bbe31bcdc5 100644
--- a/actionmailer/test/fixtures/raw_email5
+++ b/actionmailer/test/fixtures/raw_email5
@@ -14,6 +14,6 @@ Importance: normal
Test test. Hi. Waving. m
----------------------------------------------------------------
-Sent via Bell Mobility's Text Messaging service.
+Sent via Bell Mobility's Text Messaging service.
Envoyé par le service de messagerie texte de Bell Mobilité.
----------------------------------------------------------------
diff --git a/actionmailer/test/fixtures/raw_email6 b/actionmailer/test/fixtures/raw_email6
index 93289c4f92..8e37bd7392 100644
--- a/actionmailer/test/fixtures/raw_email6
+++ b/actionmailer/test/fixtures/raw_email6
@@ -15,6 +15,6 @@ Content-Type: text/plain; charset=us-ascii
Test test. Hi. Waving. m
----------------------------------------------------------------
-Sent via Bell Mobility's Text Messaging service.
+Sent via Bell Mobility's Text Messaging service.
Envoyé par le service de messagerie texte de Bell Mobilité.
----------------------------------------------------------------
diff --git a/actionmailer/test/fixtures/raw_email8 b/actionmailer/test/fixtures/raw_email8
index 2382dfdf34..79996365b3 100644
--- a/actionmailer/test/fixtures/raw_email8
+++ b/actionmailer/test/fixtures/raw_email8
@@ -8,7 +8,7 @@ To: xxxxx xxxx <xxxxx@xxxxxxxxx.com>
Subject: Fwd: Signed email causes file attachments
In-Reply-To: <F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@mac.com>
Mime-Version: 1.0
-Content-Type: multipart/mixed;
+Content-Type: multipart/mixed;
boundary="----=_Part_5028_7368284.1115579351471"
References: <F6E2D0B4-CC35-4A91-BA4C-C7C712B10C13@mac.com>
diff --git a/actionmailer/test/fixtures/raw_email9 b/actionmailer/test/fixtures/raw_email9
index 8b9b1eaa04..02ea0b05c5 100644
--- a/actionmailer/test/fixtures/raw_email9
+++ b/actionmailer/test/fixtures/raw_email9
@@ -10,19 +10,19 @@ Date: Wed, 23 Feb 2005 18:20:17 -0400
From: "xxx xxx" <xxx@xxx.xxx>
Message-ID: <4D6AA7EB.6490534@xxx.xxx>
To: xxx@xxx.com
-Subject: Stop adware/spyware once and for all.
+Subject: Stop adware/spyware once and for all.
X-Scanned-By: MIMEDefang 2.11 (www dot roaringpenguin dot com slash mimedefang)
-You are infected with:
+You are infected with:
Ad Ware and Spy Ware
-Get your free scan and removal download now,
-before it gets any worse.
+Get your free scan and removal download now,
+before it gets any worse.
http://xxx.xxx.info?aid=3D13&?stat=3D4327kdzt
-no more? (you will still be infected)
+no more? (you will still be infected)
http://xxx.xxx.info/discon/?xxx@xxx.com
diff --git a/actionmailer/test/fixtures/templates/signed_up.erb b/actionmailer/test/fixtures/templates/signed_up.erb
index a85d5fa442..7afe1f651c 100644
--- a/actionmailer/test/fixtures/templates/signed_up.erb
+++ b/actionmailer/test/fixtures/templates/signed_up.erb
@@ -1,3 +1,3 @@
-Hello there,
+Hello there,
Mr. <%= @recipient %> \ No newline at end of file
diff --git a/actionmailer/test/fixtures/test_mailer/custom_templating_extension.html.haml b/actionmailer/test/fixtures/test_mailer/custom_templating_extension.html.haml
index 847d065c37..8dcf9746cc 100644
--- a/actionmailer/test/fixtures/test_mailer/custom_templating_extension.html.haml
+++ b/actionmailer/test/fixtures/test_mailer/custom_templating_extension.html.haml
@@ -1,6 +1,6 @@
-%p Hello there,
+%p Hello there,
-%p
+%p
Mr.
= @recipient
from haml \ No newline at end of file
diff --git a/actionmailer/test/fixtures/test_mailer/custom_templating_extension.text.haml b/actionmailer/test/fixtures/test_mailer/custom_templating_extension.text.haml
index 847d065c37..8dcf9746cc 100644
--- a/actionmailer/test/fixtures/test_mailer/custom_templating_extension.text.haml
+++ b/actionmailer/test/fixtures/test_mailer/custom_templating_extension.text.haml
@@ -1,6 +1,6 @@
-%p Hello there,
+%p Hello there,
-%p
+%p
Mr.
= @recipient
from haml \ No newline at end of file
diff --git a/actionmailer/test/fixtures/test_mailer/signed_up.html.erb b/actionmailer/test/fixtures/test_mailer/signed_up.html.erb
index a85d5fa442..7afe1f651c 100644
--- a/actionmailer/test/fixtures/test_mailer/signed_up.html.erb
+++ b/actionmailer/test/fixtures/test_mailer/signed_up.html.erb
@@ -1,3 +1,3 @@
-Hello there,
+Hello there,
Mr. <%= @recipient %> \ No newline at end of file
diff --git a/actionmailer/test/fixtures/url_test_mailer/signed_up_with_url.erb b/actionmailer/test/fixtures/url_test_mailer/signed_up_with_url.erb
index 4c5806d30d..6e7875cff5 100644
--- a/actionmailer/test/fixtures/url_test_mailer/signed_up_with_url.erb
+++ b/actionmailer/test/fixtures/url_test_mailer/signed_up_with_url.erb
@@ -1,4 +1,4 @@
-Hello there,
+Hello there,
Mr. <%= @recipient %>. Please see our greeting at <%= @welcome_url %> <%= welcome_url %>
diff --git a/actionmailer/test/mailers/proc_mailer.rb b/actionmailer/test/mailers/proc_mailer.rb
index 6a79cd71fc..43916e1421 100644
--- a/actionmailer/test/mailers/proc_mailer.rb
+++ b/actionmailer/test/mailers/proc_mailer.rb
@@ -6,11 +6,11 @@ class ProcMailer < ActionMailer::Base
def welcome
mail
end
-
+
private
-
+
def give_a_greeting
"Thanks for signing up this afternoon"
end
-
+
end
diff --git a/actionmailer/test/old_base/mail_service_test.rb b/actionmailer/test/old_base/mail_service_test.rb
index 831adf3e32..4c93eb63e2 100644
--- a/actionmailer/test/old_base/mail_service_test.rb
+++ b/actionmailer/test/old_base/mail_service_test.rb
@@ -106,7 +106,7 @@ class TestMailer < ActionMailer::Base
cc "Foo áëô îü <extended@example.net>"
bcc "Foo áëô îü <extended@example.net>"
charset "UTF-8"
-
+
body "åœö blah"
end
@@ -359,7 +359,7 @@ class ActionMailerTest < Test::Unit::TestCase
assert_equal "text/plain", created.parts[0].parts[0].mime_type
assert_equal "text/html", created.parts[0].parts[1].mime_type
assert_equal "application/octet-stream", created.parts[1].mime_type
-
+
end
def test_nested_parts_with_body
@@ -399,7 +399,7 @@ class ActionMailerTest < Test::Unit::TestCase
created = nil
assert_nothing_raised { created = TestMailer.signed_up(@recipient) }
assert_not_nil created
-
+
expected.message_id = '<123@456>'
created.message_id = '<123@456>'
@@ -503,7 +503,7 @@ class ActionMailerTest < Test::Unit::TestCase
delivered = ActionMailer::Base.deliveries.first
expected.message_id = '<123@456>'
delivered.message_id = '<123@456>'
-
+
assert_equal expected.encoded, delivered.encoded
end
@@ -546,10 +546,10 @@ class ActionMailerTest < Test::Unit::TestCase
created = TestMailer.different_reply_to @recipient
end
assert_not_nil created
-
+
expected.message_id = '<123@456>'
created.message_id = '<123@456>'
-
+
assert_equal expected.encoded, created.encoded
assert_nothing_raised do
@@ -558,10 +558,10 @@ class ActionMailerTest < Test::Unit::TestCase
delivered = ActionMailer::Base.deliveries.first
assert_not_nil delivered
-
+
expected.message_id = '<123@456>'
delivered.message_id = '<123@456>'
-
+
assert_equal expected.encoded, delivered.encoded
end
@@ -581,7 +581,7 @@ class ActionMailerTest < Test::Unit::TestCase
created = TestMailer.iso_charset @recipient
end
assert_not_nil created
-
+
expected.message_id = '<123@456>'
created.message_id = '<123@456>'
@@ -596,7 +596,7 @@ class ActionMailerTest < Test::Unit::TestCase
expected.message_id = '<123@456>'
delivered.message_id = '<123@456>'
-
+
assert_equal expected.encoded, delivered.encoded
end
@@ -631,7 +631,7 @@ class ActionMailerTest < Test::Unit::TestCase
expected.message_id = '<123@456>'
delivered.message_id = '<123@456>'
-
+
assert_equal expected.encoded, delivered.encoded
end
@@ -761,10 +761,10 @@ EOF
delivered = ActionMailer::Base.deliveries.first
assert_not_nil delivered
-
+
expected.message_id = '<123@456>'
delivered.message_id = '<123@456>'
-
+
assert_equal expected.encoded, delivered.encoded
end
@@ -887,7 +887,7 @@ EOF
assert_equal "iso-8859-1", mail.parts[1].charset
assert_equal "image/jpeg", mail.parts[2].mime_type
-
+
assert_equal "attachment", mail.parts[2][:content_disposition].disposition_type
assert_equal "foo.jpg", mail.parts[2][:content_disposition].filename
assert_equal "foo.jpg", mail.parts[2][:content_type].filename
@@ -1005,7 +1005,7 @@ EOF
attachment = mail.attachments.last
expected = "01 Quien Te Dij\212at. Pitbull.mp3"
-
+
if expected.respond_to?(:force_encoding)
result = attachment.filename.dup
expected.force_encoding(Encoding::ASCII_8BIT)
diff --git a/actionmailer/test/old_base/tmail_compat_test.rb b/actionmailer/test/old_base/tmail_compat_test.rb
index 255205de84..23706e99ff 100644
--- a/actionmailer/test/old_base/tmail_compat_test.rb
+++ b/actionmailer/test/old_base/tmail_compat_test.rb
@@ -31,5 +31,5 @@ class TmailCompatTest < ActiveSupport::TestCase
end
assert_equal mail.content_transfer_encoding, "base64"
end
-
+
end
diff --git a/actionmailer/test/old_base/url_test.rb b/actionmailer/test/old_base/url_test.rb
index b6496bfe1b..b4be7dfe32 100644
--- a/actionmailer/test/old_base/url_test.rb
+++ b/actionmailer/test/old_base/url_test.rb
@@ -83,7 +83,7 @@ class ActionMailerUrlTest < ActionMailer::TestCase
assert_nothing_raised { UrlTestMailer.signed_up_with_url(@recipient).deliver }
assert_not_nil ActionMailer::Base.deliveries.first
delivered = ActionMailer::Base.deliveries.first
-
+
delivered.message_id = '<123@456>'
assert_equal expected.encoded, delivered.encoded
end
diff --git a/actionmailer/test/test_helper_test.rb b/actionmailer/test/test_helper_test.rb
index 8ff604c2c7..5a101e852f 100644
--- a/actionmailer/test/test_helper_test.rb
+++ b/actionmailer/test/test_helper_test.rb
@@ -32,7 +32,7 @@ class TestHelperMailerTest < ActionMailer::TestCase
self.class.determine_default_mailer("NotAMailerTest")
end
end
-
+
def test_charset_is_utf_8
assert_equal "UTF-8", charset
end
@@ -44,14 +44,14 @@ class TestHelperMailerTest < ActionMailer::TestCase
end
end
end
-
+
def test_repeated_assert_emails_calls
assert_nothing_raised do
assert_emails 1 do
TestHelperMailer.test.deliver
end
end
-
+
assert_nothing_raised do
assert_emails 2 do
TestHelperMailer.test.deliver
@@ -59,20 +59,20 @@ class TestHelperMailerTest < ActionMailer::TestCase
end
end
end
-
+
def test_assert_emails_with_no_block
assert_nothing_raised do
TestHelperMailer.test.deliver
assert_emails 1
end
-
+
assert_nothing_raised do
TestHelperMailer.test.deliver
TestHelperMailer.test.deliver
assert_emails 3
end
end
-
+
def test_assert_no_emails
assert_nothing_raised do
assert_no_emails do
@@ -80,17 +80,17 @@ class TestHelperMailerTest < ActionMailer::TestCase
end
end
end
-
+
def test_assert_emails_too_few_sent
error = assert_raise ActiveSupport::TestCase::Assertion do
assert_emails 2 do
TestHelperMailer.test.deliver
end
end
-
+
assert_match(/2 .* but 1/, error.message)
end
-
+
def test_assert_emails_too_many_sent
error = assert_raise ActiveSupport::TestCase::Assertion do
assert_emails 1 do
@@ -98,17 +98,17 @@ class TestHelperMailerTest < ActionMailer::TestCase
TestHelperMailer.test.deliver
end
end
-
+
assert_match(/1 .* but 2/, error.message)
end
-
+
def test_assert_no_emails_failure
error = assert_raise ActiveSupport::TestCase::Assertion do
assert_no_emails do
TestHelperMailer.test.deliver
end
end
-
+
assert_match(/0 .* but 1/, error.message)
end
end
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 81abb8b5f1..dce2e30d3f 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -26,7 +26,7 @@
resources :comments
end
end
-
+
You can now use comment_path for /comments/1 instead of post_comment_path for /posts/1/comments/1.
* Add support for multi-subdomain session by setting cookie host in session cookie so you can share session between www.example.com, example.com and user.example.com. #4818 [Guillermo Álvarez]
@@ -110,7 +110,7 @@
* ActionDispatch::Request#content_type returns a String to be compatible with
Rack::Request. Use #content_mime_type for the Mime::Type instance [YK]
-* Updated Prototype to 1.6.1 and Scriptaculous to 1.8.3 [ML]
+* Updated Prototype to 1.6.1 and Scriptaculous to 1.8.3 [ML]
* Change the preferred way that URL helpers are included into a class[YK & CL]
diff --git a/actionpack/README.rdoc b/actionpack/README.rdoc
index b297ceb0e2..0ad33cfe26 100644
--- a/actionpack/README.rdoc
+++ b/actionpack/README.rdoc
@@ -102,10 +102,10 @@ A short rundown of some of the major features:
class WeblogController < ActionController::Base
# filters as methods
before_filter :authenticate, :cache, :audit
-
+
# filter as a proc
after_filter { |c| c.response.body = Gzip::compress(c.response.body) }
-
+
# class filter
after_filter LocalizeFilter
diff --git a/actionpack/RUNNING_UNIT_TESTS b/actionpack/RUNNING_UNIT_TESTS
index 95a8bc7497..d6a1ccf871 100644
--- a/actionpack/RUNNING_UNIT_TESTS
+++ b/actionpack/RUNNING_UNIT_TESTS
@@ -1,7 +1,7 @@
== Running with Rake
The easiest way to run the unit tests is through Rake. The default task runs
-the entire test suite for all classes. For more information, checkout the
+the entire test suite for all classes. For more information, checkout the
full array of rake tasks with "rake -T"
Rake can be found at http://rake.rubyforge.org
@@ -16,7 +16,7 @@ you can do so with something like:
== Dependency on ActiveRecord and database setup
Test cases in the test/controller/active_record/ directory depend on having
-activerecord and sqlite installed. If ActiveRecord is not in
+activerecord and sqlite installed. If ActiveRecord is not in
actionpack/../activerecord directory, or the sqlite rubygem is not installed,
these tests are skipped.
diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb
index db0a6736e0..79ebf29c7f 100644
--- a/actionpack/lib/abstract_controller/base.rb
+++ b/actionpack/lib/abstract_controller/base.rb
@@ -109,7 +109,7 @@ module AbstractController
@_action_name = action_name = action.to_s
unless action_name = method_for_action(action_name)
- raise ActionNotFound, "The action '#{action}' could not be found for #{self.class.name}"
+ raise ActionNotFound, "The action '#{action}' could not be found for #{self.class.name}"
end
@_response_body = nil
diff --git a/actionpack/lib/action_controller/metal/http_authentication.rb b/actionpack/lib/action_controller/metal/http_authentication.rb
index b0eb24a4a8..acd313b039 100644
--- a/actionpack/lib/action_controller/metal/http_authentication.rb
+++ b/actionpack/lib/action_controller/metal/http_authentication.rb
@@ -392,11 +392,11 @@ module ActionController
end
end
- # If token Authorization header is present, call the login procedure with
+ # If token Authorization header is present, call the login procedure with
# the present token and options.
#
# controller - ActionController::Base instance for the current request.
- # login_procedure - Proc to call if a token is present. The Proc should
+ # login_procedure - Proc to call if a token is present. The Proc should
# take 2 arguments:
# authenticate(controller) { |token, options| ... }
#
diff --git a/actionpack/lib/action_controller/middleware.rb b/actionpack/lib/action_controller/middleware.rb
index 2115b07b3e..437fec3dc6 100644
--- a/actionpack/lib/action_controller/middleware.rb
+++ b/actionpack/lib/action_controller/middleware.rb
@@ -31,7 +31,7 @@ module ActionController
super()
@_app = app
end
-
+
def index
call(env)
end
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index e306697f4b..e02fe202e1 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -311,7 +311,7 @@ module ActionController
def tests(controller_class)
self.controller_class = controller_class
end
-
+
def controller_class=(new_class)
prepare_controller_class(new_class) if new_class
write_inheritable_attribute(:controller_class, new_class)
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
index b8d73c350d..7fa3aead82 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb
@@ -48,7 +48,7 @@ EOF
end
end
end
-
+
# Search the tree for (and return) the first node that matches the given
# conditions. The conditions are interpreted differently for different node
# types, see HTML::Text#find and HTML::Tag#find.
@@ -62,7 +62,7 @@ EOF
def find_all(conditions)
@root.find_all(conditions)
end
-
+
end
end
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
index a874519978..d581399514 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
@@ -1,7 +1,7 @@
require 'strscan'
module HTML #:nodoc:
-
+
class Conditions < Hash #:nodoc:
def initialize(hash)
super()
@@ -57,17 +57,17 @@ module HTML #:nodoc:
class Node #:nodoc:
# The array of children of this node. Not all nodes have children.
attr_reader :children
-
+
# The parent node of this node. All nodes have a parent, except for the
# root node.
attr_reader :parent
-
+
# The line number of the input where this node was begun
attr_reader :line
-
+
# The byte position in the input where this node was begun
attr_reader :position
-
+
# Create a new node as a child of the given parent.
def initialize(parent, line=0, pos=0)
@parent = parent
@@ -92,7 +92,7 @@ module HTML #:nodoc:
# returns non +nil+. Returns the result of the #find call that succeeded.
def find(conditions)
conditions = validate_conditions(conditions)
- @children.each do |child|
+ @children.each do |child|
node = child.find(conditions)
return node if node
end
@@ -133,7 +133,7 @@ module HTML #:nodoc:
equivalent
end
-
+
class <<self
def parse(parent, line, pos, content, strict=true)
if content !~ /^<\S/
@@ -160,11 +160,11 @@ module HTML #:nodoc:
return CDATA.new(parent, line, pos, scanner.pre_match.gsub(/<!\[CDATA\[/, ''))
end
-
+
closing = ( scanner.scan(/\//) ? :close : nil )
return Text.new(parent, line, pos, content) unless name = scanner.scan(/[\w:-]+/)
name.downcase!
-
+
unless closing
scanner.skip(/\s*/)
attributes = {}
@@ -191,13 +191,13 @@ module HTML #:nodoc:
attributes[attr.downcase] = value
scanner.skip(/\s*/)
end
-
+
closing = ( scanner.scan(/\//) ? :self : nil )
end
-
+
unless scanner.scan(/\s*>/)
if strict
- raise "expected > (got #{scanner.rest.inspect} for #{content}, #{attributes.inspect})"
+ raise "expected > (got #{scanner.rest.inspect} for #{content}, #{attributes.inspect})"
else
# throw away all text until we find what we're looking for
scanner.skip_until(/>/) or scanner.terminate
@@ -212,9 +212,9 @@ module HTML #:nodoc:
# A node that represents text, rather than markup.
class Text < Node #:nodoc:
-
+
attr_reader :content
-
+
# Creates a new text node as a child of the given parent, with the given
# content.
def initialize(parent, line, pos, content)
@@ -240,7 +240,7 @@ module HTML #:nodoc:
def find(conditions)
match(conditions) && self
end
-
+
# Returns non-+nil+ if this node meets the given conditions, or +nil+
# otherwise. See the discussion of #find for the valid conditions.
def match(conditions)
@@ -268,7 +268,7 @@ module HTML #:nodoc:
content == node.content
end
end
-
+
# A CDATA node is simply a text node with a specialized way of displaying
# itself.
class CDATA < Text #:nodoc:
@@ -281,16 +281,16 @@ module HTML #:nodoc:
# closing tag, or a self-closing tag. It has a name, and may have a hash of
# attributes.
class Tag < Node #:nodoc:
-
+
# Either +nil+, <tt>:close</tt>, or <tt>:self</tt>
attr_reader :closing
-
+
# Either +nil+, or a hash of attributes for this node.
attr_reader :attributes
# The name of this tag.
attr_reader :name
-
+
# Create a new node as a child of the given parent, using the given content
# to describe the node. It will be parsed and the node name, attributes and
# closing status extracted.
@@ -344,7 +344,7 @@ module HTML #:nodoc:
def tag?
true
end
-
+
# Returns +true+ if the node meets any of the given conditions. The
# +conditions+ parameter must be a hash of any of the following keys
# (all are optional):
@@ -404,7 +404,7 @@ module HTML #:nodoc:
# node.match :descendant => { :tag => "strong" }
#
# # test if the node has between 2 and 4 span tags as immediate children
- # node.match :children => { :count => 2..4, :only => { :tag => "span" } }
+ # node.match :children => { :count => 2..4, :only => { :tag => "span" } }
#
# # get funky: test to see if the node is a "div", has a "ul" ancestor
# # and an "li" parent (with "class" = "enum"), and whether or not it has
@@ -439,7 +439,7 @@ module HTML #:nodoc:
# test children
return false unless children.find { |child| child.match(conditions[:child]) } if conditions[:child]
-
+
# test ancestors
if conditions[:ancestor]
return false unless catch :found do
@@ -457,13 +457,13 @@ module HTML #:nodoc:
child.match(:descendant => conditions[:descendant])
end
end
-
+
# count children
if opts = conditions[:children]
matches = children.select do |c|
(c.kind_of?(HTML::Tag) and (c.closing == :self or ! c.childless?))
end
-
+
matches = matches.select { |c| c.match(opts[:only]) } if opts[:only]
opts.each do |key, value|
next if key == :only
@@ -489,24 +489,24 @@ module HTML #:nodoc:
self_index = siblings.index(self)
if conditions[:sibling]
- return false unless siblings.detect do |s|
+ return false unless siblings.detect do |s|
s != self && s.match(conditions[:sibling])
end
end
if conditions[:before]
- return false unless siblings[self_index+1..-1].detect do |s|
+ return false unless siblings[self_index+1..-1].detect do |s|
s != self && s.match(conditions[:before])
end
end
if conditions[:after]
- return false unless siblings[0,self_index].detect do |s|
+ return false unless siblings[0,self_index].detect do |s|
s != self && s.match(conditions[:after])
end
end
end
-
+
true
end
@@ -515,7 +515,7 @@ module HTML #:nodoc:
return false unless closing == node.closing && self.name == node.name
attributes == node.attributes
end
-
+
private
# Match the given value to the given condition.
def match_condition(value, condition)
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
index 51e0868995..dceddb9b80 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb
@@ -7,11 +7,11 @@ module HTML
return text unless sanitizeable?(text)
tokenize(text, options).join
end
-
+
def sanitizeable?(text)
!(text.nil? || text.empty? || !text.index("<"))
end
-
+
protected
def tokenize(text, options)
tokenizer = HTML::Tokenizer.new(text)
@@ -22,12 +22,12 @@ module HTML
end
result
end
-
+
def process_node(node, result, options)
result << node.to_s
end
end
-
+
class FullSanitizer < Sanitizer
def sanitize(text, options = {})
result = super
@@ -37,12 +37,12 @@ module HTML
# Recurse - handle all dirty nested tags
result == text ? result : sanitize(result, options)
end
-
+
def process_node(node, result, options)
result << node.to_s if node.class == HTML::Text
end
end
-
+
class LinkSanitizer < FullSanitizer
cattr_accessor :included_tags, :instance_writer => false
self.included_tags = Set.new(%w(a href))
@@ -50,13 +50,13 @@ module HTML
def sanitizeable?(text)
!(text.nil? || text.empty? || !((text.index("<a") || text.index("<href")) && text.index(">")))
end
-
+
protected
def process_node(node, result, options)
- result << node.to_s unless node.is_a?(HTML::Tag) && included_tags.include?(node.name)
+ result << node.to_s unless node.is_a?(HTML::Tag) && included_tags.include?(node.name)
end
end
-
+
class WhiteListSanitizer < Sanitizer
[:protocol_separator, :uri_attributes, :allowed_attributes, :allowed_tags, :allowed_protocols, :bad_tags,
:allowed_css_properties, :allowed_css_keywords, :shorthand_css_properties].each do |attr|
@@ -66,35 +66,35 @@ module HTML
# A regular expression of the valid characters used to separate protocols like
# the ':' in 'http://foo.com'
self.protocol_separator = /:|(&#0*58)|(&#x70)|(%|&#37;)3A/
-
+
# Specifies a Set of HTML attributes that can have URIs.
self.uri_attributes = Set.new(%w(href src cite action longdesc xlink:href lowsrc))
# Specifies a Set of 'bad' tags that the #sanitize helper will remove completely, as opposed
# to just escaping harmless tags like &lt;font&gt;
self.bad_tags = Set.new(%w(script))
-
+
# Specifies the default Set of tags that the #sanitize helper will allow unscathed.
- self.allowed_tags = Set.new(%w(strong em b i p code pre tt samp kbd var sub
- sup dfn cite big small address hr br div span h1 h2 h3 h4 h5 h6 ul ol li dl dt dd abbr
+ self.allowed_tags = Set.new(%w(strong em b i p code pre tt samp kbd var sub
+ sup dfn cite big small address hr br div span h1 h2 h3 h4 h5 h6 ul ol li dl dt dd abbr
acronym a img blockquote del ins))
- # Specifies the default Set of html attributes that the #sanitize helper will leave
+ # Specifies the default Set of html attributes that the #sanitize helper will leave
# in the allowed tag.
self.allowed_attributes = Set.new(%w(href src width height alt cite datetime title class name xml:lang abbr))
-
+
# Specifies the default Set of acceptable css properties that #sanitize and #sanitize_css will accept.
- self.allowed_protocols = Set.new(%w(ed2k ftp http https irc mailto news gopher nntp telnet webcal xmpp callto
+ self.allowed_protocols = Set.new(%w(ed2k ftp http https irc mailto news gopher nntp telnet webcal xmpp callto
feed svn urn aim rsync tag ssh sftp rtsp afs))
-
+
# Specifies the default Set of acceptable css keywords that #sanitize and #sanitize_css will accept.
- self.allowed_css_properties = Set.new(%w(azimuth background-color border-bottom-color border-collapse
- border-color border-left-color border-right-color border-top-color clear color cursor direction display
+ self.allowed_css_properties = Set.new(%w(azimuth background-color border-bottom-color border-collapse
+ border-color border-left-color border-right-color border-top-color clear color cursor direction display
elevation float font font-family font-size font-style font-variant font-weight height letter-spacing line-height
overflow pause pause-after pause-before pitch pitch-range richness speak speak-header speak-numeral speak-punctuation
speech-rate stress text-align text-decoration text-indent unicode-bidi vertical-align voice-family volume white-space
width))
-
+
# Specifies the default Set of acceptable css keywords that #sanitize and #sanitize_css will accept.
self.allowed_css_keywords = Set.new(%w(auto aqua black block blue bold both bottom brown center
collapse dashed dotted fuchsia gray green !important italic left lime maroon medium none navy normal
@@ -118,9 +118,9 @@ module HTML
style.scan(/([-\w]+)\s*:\s*([^:;]*)/) do |prop,val|
if allowed_css_properties.include?(prop.downcase)
clean << prop + ': ' + val + ';'
- elsif shorthand_css_properties.include?(prop.split('-')[0].downcase)
+ elsif shorthand_css_properties.include?(prop.split('-')[0].downcase)
unless val.split().any? do |keyword|
- !allowed_css_keywords.include?(keyword) &&
+ !allowed_css_keywords.include?(keyword) &&
keyword !~ /^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$/
end
clean << prop + ': ' + val + ';'
@@ -146,7 +146,7 @@ module HTML
else
options[:parent].unshift node.name
end
-
+
process_attributes_for node, options
options[:tags].include?(node.name) ? node : nil
@@ -154,7 +154,7 @@ module HTML
bad_tags.include?(options[:parent].first) ? nil : node.to_s.gsub(/</, "&lt;")
end
end
-
+
def process_attributes_for(node, options)
return unless node.attributes
node.attributes.keys.each do |attr_name|
@@ -169,7 +169,7 @@ module HTML
end
def contains_bad_protocols?(attr_name, value)
- uri_attributes.include?(attr_name) &&
+ uri_attributes.include?(attr_name) &&
(value =~ /(^[^\/:]*):|(&#0*58)|(&#x70)|(%|&#37;)3A/ && !allowed_protocols.include?(value.split(protocol_separator).first))
end
end
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
index e2c49c284f..0fe2e6d1a6 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
@@ -182,7 +182,7 @@ module HTML
# not another using <tt>:not</tt>. For example:
# p:not(.post)
# Matches all paragraphs that do not have the class <tt>.post</tt>.
- #
+ #
# === Substitution Values
#
# You can use substitution with identifiers, class names and element values.
diff --git a/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb b/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb
index 240dc1890f..c252e01cf5 100644
--- a/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb
+++ b/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb
@@ -1,7 +1,7 @@
require 'strscan'
module HTML #:nodoc:
-
+
# A simple HTML tokenizer. It simply breaks a stream of text into tokens, where each
# token is a string. Each string represents either "text", or an HTML element.
#
@@ -14,13 +14,13 @@ module HTML #:nodoc:
# p token
# end
class Tokenizer #:nodoc:
-
+
# The current (byte) position in the text
attr_reader :position
-
+
# The current line number
attr_reader :line
-
+
# Create a new Tokenizer for the given text.
def initialize(text)
text.encode! if text.encoding_aware?
@@ -42,7 +42,7 @@ module HTML #:nodoc:
update_current_line(scan_text)
end
end
-
+
private
# Treat the text at the current position as a tag, and scan it. Supports
@@ -69,13 +69,13 @@ module HTML #:nodoc:
def scan_text
"#{@scanner.getch}#{@scanner.scan(/[^<]*/)}"
end
-
+
# Counts the number of newlines in the text and updates the current line
# accordingly.
def update_current_line(text)
text.scan(/\r?\n/) { @current_line += 1 }
end
-
+
# Skips over quoted strings, so that less-than and greater-than characters
# within the strings are ignored.
def consume_quoted_regions
@@ -103,5 +103,5 @@ module HTML #:nodoc:
text
end
end
-
+
end
diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb
index c6fc582851..8f1c9b6691 100644
--- a/actionpack/lib/action_dispatch/http/mime_type.rb
+++ b/actionpack/lib/action_dispatch/http/mime_type.rb
@@ -109,10 +109,10 @@ module Mime
else
# keep track of creation order to keep the subsequent sort stable
list = []
- accept_header.split(/,/).each_with_index do |header, index|
- params, q = header.split(/;\s*q=/)
+ accept_header.split(/,/).each_with_index do |header, index|
+ params, q = header.split(/;\s*q=/)
if params
- params.strip!
+ params.strip!
list << AcceptItem.new(index, params, q) unless params.empty?
end
end
@@ -161,20 +161,20 @@ module Mime
end
end
end
-
+
def initialize(string, symbol = nil, synonyms = [])
@symbol, @synonyms = symbol, synonyms
@string = string
end
-
+
def to_s
@string
end
-
+
def to_str
to_s
end
-
+
def to_sym
@symbol || @string.to_sym
end
@@ -186,11 +186,11 @@ module Mime
super
end
end
-
+
def ==(mime_type)
return false if mime_type.blank?
- (@synonyms + [ self ]).any? do |synonym|
- synonym.to_s == mime_type.to_s || synonym.to_sym == mime_type.to_sym
+ (@synonyms + [ self ]).any? do |synonym|
+ synonym.to_s == mime_type.to_s || synonym.to_sym == mime_type.to_sym
end
end
diff --git a/actionpack/lib/action_dispatch/middleware/stack.rb b/actionpack/lib/action_dispatch/middleware/stack.rb
index 41078eced7..5a029a60d1 100644
--- a/actionpack/lib/action_dispatch/middleware/stack.rb
+++ b/actionpack/lib/action_dispatch/middleware/stack.rb
@@ -69,7 +69,7 @@ module ActionDispatch
end
def active
- ActiveSupport::Deprecation.warn "All middlewares in the chain are active since the laziness " <<
+ ActiveSupport::Deprecation.warn "All middlewares in the chain are active since the laziness " <<
"was removed from the middleware stack", caller
end
diff --git a/actionpack/lib/action_dispatch/routing.rb b/actionpack/lib/action_dispatch/routing.rb
index 683dd72555..df1b53016d 100644
--- a/actionpack/lib/action_dispatch/routing.rb
+++ b/actionpack/lib/action_dispatch/routing.rb
@@ -15,7 +15,7 @@ module ActionDispatch
# match ':controller(/:action(/:id(.:format)))'
#
# This route states that it expects requests to consist of a
- # <tt>:controller</tt> followed optionally by an <tt>:action</tt> that in
+ # <tt>:controller</tt> followed optionally by an <tt>:action</tt> that in
# turn is followed optionally by an <tt>:id</tt>, which in turn is followed
# optionally by a <tt>:format</tt>
#
@@ -134,8 +134,8 @@ module ActionDispatch
# == HTTP Methods
#
# Using the <tt>:via</tt> option when specifying a route allows you to restrict it to a specific HTTP method.
- # Possible values are <tt>:post</tt>, <tt>:get</tt>, <tt>:put</tt>, <tt>:delete</tt> and <tt>:any</tt>.
- # If your route needs to respond to more than one method you can use an array, e.g. <tt>[ :get, :post ]</tt>.
+ # Possible values are <tt>:post</tt>, <tt>:get</tt>, <tt>:put</tt>, <tt>:delete</tt> and <tt>:any</tt>.
+ # If your route needs to respond to more than one method you can use an array, e.g. <tt>[ :get, :post ]</tt>.
# The default value is <tt>:any</tt> which means that the route will respond to any of the HTTP methods.
#
# Examples:
@@ -144,7 +144,7 @@ module ActionDispatch
# match 'post/:id' => "posts#create_comment', :via => :post
#
# Now, if you POST to <tt>/posts/:id</tt>, it will route to the <tt>create_comment</tt> action. A GET on the same
- # URL will route to the <tt>show</tt> action.
+ # URL will route to the <tt>show</tt> action.
#
# === HTTP helper methods
#
diff --git a/actionpack/lib/action_view/helpers/debug_helper.rb b/actionpack/lib/action_view/helpers/debug_helper.rb
index 1491cb073f..cd67851642 100644
--- a/actionpack/lib/action_view/helpers/debug_helper.rb
+++ b/actionpack/lib/action_view/helpers/debug_helper.rb
@@ -1,6 +1,6 @@
module ActionView
# = Action View Debug Helper
- #
+ #
# Provides a set of methods for making it easier to debug Rails objects.
module Helpers
module DebugHelper
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 3c4d0b65f4..698cd3e4cd 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -53,16 +53,16 @@ module ActionView
# <option value="2">Sam</option>
# <option value="3">Tobias</option>
# </select>
- #
- # Like the other form helpers, +select+ can accept an <tt>:index</tt> option to manually set the ID used in the resulting output. Unlike other helpers, +select+ expects this
+ #
+ # Like the other form helpers, +select+ can accept an <tt>:index</tt> option to manually set the ID used in the resulting output. Unlike other helpers, +select+ expects this
# option to be in the +html_options+ parameter.
- #
- # Example:
- #
+ #
+ # Example:
+ #
# select("album[]", "genre", %w[rap rock country], {}, { :index => nil })
- #
+ #
# becomes:
- #
+ #
# <select name="album[][genre]" id="album__genre">
# <option value="rap">rap</option>
# <option value="rock">rock</option>
@@ -140,7 +140,7 @@ module ActionView
# The <tt>:value_method</tt> and <tt>:text_method</tt> parameters are methods to be called on each member
# of +collection+. The return values are used as the +value+ attribute and contents of each
# <tt><option></tt> tag, respectively.
- #
+ #
# Example object structure for use with this method:
# class Post < ActiveRecord::Base
# belongs_to :author
diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb
index 686c5b7a14..b9d27be639 100644
--- a/actionpack/lib/action_view/helpers/form_tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -25,7 +25,7 @@ module ActionView
# If "put", "delete", or another verb is used, a hidden input with name <tt>_method</tt>
# is added to simulate the verb over post.
# * 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
+ # * <tt>:remote</tt> - If set to true, will allow the Unobtrusive JavaScript drivers to control the
# submit behaviour. By default this behaviour is an ajax submit.
#
# ==== Examples
@@ -42,10 +42,10 @@ module ActionView
# <div><%= submit_tag 'Save' %></div>
# <% end -%>
# # => <form action="/posts" method="post"><div><input type="submit" name="submit" value="Save" /></div></form>
- #
+ #
# <%= form_tag('/posts', :remote => true) %>
# # => <form action="/posts" method="post" data-remote="true">
- #
+ #
def form_tag(url_for_options = {}, options = {}, *parameters_for_url, &block)
html_options = html_options_for_form(url_for_options, options, *parameters_for_url)
if block_given?
@@ -351,12 +351,12 @@ module ActionView
# Creates a submit button with the text <tt>value</tt> as the caption.
#
# ==== Options
- # * <tt>:confirm => 'question?'</tt> - If present the unobtrusive JavaScript
- # drivers will provide a prompt with the question specified. If the user accepts,
+ # * <tt>:confirm => 'question?'</tt> - If present the unobtrusive JavaScript
+ # drivers will provide a prompt with the question specified. If the user accepts,
# the form is processed normally, otherwise no action is taken.
# * <tt>:disabled</tt> - If true, the user will not be able to use this input.
- # * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a
- # disabled version of the submit button when the form is submitted. This feature is
+ # * <tt>:disable_with</tt> - Value of this parameter will be used as the value for a
+ # disabled version of the submit button when the form is submitted. This feature is
# provided by the unobtrusive JavaScript driver.
# * Any other key creates standard HTML options for the tag.
#
@@ -383,7 +383,7 @@ module ActionView
# # name="commit" type="submit" value="Edit" />
#
# submit_tag "Save", :confirm => "Are you sure?"
- # # => <input name='commit' type='submit' value='Save'
+ # # => <input name='commit' type='submit' value='Save'
# data-confirm="Are you sure?" />
#
def submit_tag(value = "Save changes", options = {})
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb
index f11027bc93..9dc47272b0 100644
--- a/actionpack/lib/action_view/helpers/number_helper.rb
+++ b/actionpack/lib/action_view/helpers/number_helper.rb
@@ -325,7 +325,7 @@ module ActionView
defaults = I18n.translate(:'number.format', :locale => options[:locale], :default => {})
human = I18n.translate(:'number.human.format', :locale => options[:locale], :default => {})
defaults = defaults.merge(human)
-
+
options = options.reverse_merge(defaults)
#for backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files
options[:strip_insignificant_zeros] = true if not options.key?(:strip_insignificant_zeros)
diff --git a/actionpack/lib/action_view/helpers/raw_output_helper.rb b/actionpack/lib/action_view/helpers/raw_output_helper.rb
index da7599fa8f..216683a2e0 100644
--- a/actionpack/lib/action_view/helpers/raw_output_helper.rb
+++ b/actionpack/lib/action_view/helpers/raw_output_helper.rb
@@ -2,7 +2,7 @@ module ActionView #:nodoc:
# = Action View Raw Output Helper
module Helpers #:nodoc:
module RawOutputHelper
- # This method outputs without escaping a string. Since escaping tags is
+ # This method outputs without escaping a string. Since escaping tags is
# now default, this can be used when you don't want Rails to automatically
# escape tags. This is not recommended if the data is coming from the user's
# input.
diff --git a/actionpack/lib/action_view/helpers/sanitize_helper.rb b/actionpack/lib/action_view/helpers/sanitize_helper.rb
index d82005fa24..0fee34f8a4 100644
--- a/actionpack/lib/action_view/helpers/sanitize_helper.rb
+++ b/actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -9,7 +9,7 @@ module ActionView
# These helper methods extend Action View making them callable within your template files.
module SanitizeHelper
extend ActiveSupport::Concern
- # This +sanitize+ helper will html encode all tags and strip all attributes that
+ # This +sanitize+ helper will html encode all tags and strip all attributes that
# aren't specifically allowed.
#
# It also strips href/src tags with invalid protocols, like javascript: especially.
@@ -21,7 +21,7 @@ module ActionView
#
# You can add or remove tags/attributes if you want to customize it a bit.
# See ActionView::Base for full docs on the available options. You can add
- # tags/attributes for single uses of +sanitize+ by passing either the
+ # tags/attributes for single uses of +sanitize+ by passing either the
# <tt>:attributes</tt> or <tt>:tags</tt> options:
#
# Normal Use
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index c1de5c8cb3..46af3012d9 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -462,7 +462,7 @@ module ActionView
text.gsub(AUTO_LINK_RE) do
scheme, href = $1, $&
punctuation = []
-
+
if auto_linked?($`, $')
# do not change string; URL is already linked
href
@@ -507,7 +507,7 @@ module ActionView
end
end
end
-
+
# Detects already linked context or position in the middle of a tag
def auto_linked?(left, right)
(left =~ AUTO_LINK_CRE[0] and right =~ AUTO_LINK_CRE[1]) or
diff --git a/actionpack/lib/action_view/helpers/translation_helper.rb b/actionpack/lib/action_view/helpers/translation_helper.rb
index dac9c28ab7..13767a09f9 100644
--- a/actionpack/lib/action_view/helpers/translation_helper.rb
+++ b/actionpack/lib/action_view/helpers/translation_helper.rb
@@ -5,21 +5,21 @@ module ActionView
module Helpers
module TranslationHelper
# Delegates to I18n#translate but also performs three additional functions.
- # First, it'll catch MissingTranslationData exceptions and turn them into
- # inline spans that contains the missing key, such that you can see in a
+ # First, it'll catch MissingTranslationData exceptions and turn them into
+ # inline spans that contains the missing key, such that you can see in a
# view what is missing where.
#
- # Second, it'll scope the key by the current partial if the key starts
- # with a period. So if you call <tt>translate(".foo")</tt> from the
- # <tt>people/index.html.erb</tt> template, you'll actually be calling
+ # Second, it'll scope the key by the current partial if the key starts
+ # with a period. So if you call <tt>translate(".foo")</tt> from the
+ # <tt>people/index.html.erb</tt> template, you'll actually be calling
# <tt>I18n.translate("people.index.foo")</tt>. This makes it less repetitive
# to translate many keys within the same partials and gives you a simple framework
- # for scoping them consistently. If you don't prepend the key with a period,
+ # for scoping them consistently. If you don't prepend the key with a period,
# nothing is converted.
#
- # Third, it'll mark the translation as safe HTML if the key has the suffix
- # "_html" or the last element of the key is the word "html". For example,
- # calling translate("footer_html") or translate("footer.html") will return
+ # Third, it'll mark the translation as safe HTML if the key has the suffix
+ # "_html" or the last element of the key is the word "html". For example,
+ # calling translate("footer_html") or translate("footer.html") will return
# a safe HTML string that won't be escaped by other HTML helper methods. This
# naming convention helps to identify translations that include HTML tags so that
# you know what kind of output to expect when you call translate in a template.
diff --git a/actionpack/lib/action_view/log_subscriber.rb b/actionpack/lib/action_view/log_subscriber.rb
index 443a0eafd1..29ffbd6fdd 100644
--- a/actionpack/lib/action_view/log_subscriber.rb
+++ b/actionpack/lib/action_view/log_subscriber.rb
@@ -7,7 +7,7 @@ module ActionView
message = "Rendered #{from_rails_root(event.payload[:identifier])}"
message << " within #{from_rails_root(event.payload[:layout])}" if event.payload[:layout]
message << (" (%.1fms)" % event.duration)
- info(message)
+ info(message)
end
alias :render_partial :render_template
alias :render_collection :render_template
diff --git a/actionpack/lib/action_view/template/handler.rb b/actionpack/lib/action_view/template/handler.rb
index 8ecc911519..c6a1bc6235 100644
--- a/actionpack/lib/action_view/template/handler.rb
+++ b/actionpack/lib/action_view/template/handler.rb
@@ -35,7 +35,7 @@ module ActionView
end
end
end
-
+
TemplateHandlers = Template::Handlers
TemplateHandler = Template::Handler
end
diff --git a/actionpack/lib/action_view/template/handlers.rb b/actionpack/lib/action_view/template/handlers.rb
index 84d6474dd1..ed397699b0 100644
--- a/actionpack/lib/action_view/template/handlers.rb
+++ b/actionpack/lib/action_view/template/handlers.rb
@@ -18,7 +18,7 @@ module ActionView #:nodoc:
@@template_handlers = {}
@@default_template_handlers = nil
-
+
def self.extensions
@@template_extensions ||= @@template_handlers.keys
end
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index 137281e5e9..e9d2e0b843 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -44,7 +44,7 @@ module ActionView
include ActionView::Helpers
attr_accessor :controller, :output_buffer, :rendered
-
+
module ClassMethods
def tests(helper_class)
self.helper_class = helper_class
diff --git a/actionpack/lib/action_view/testing/resolvers.rb b/actionpack/lib/action_view/testing/resolvers.rb
index 578c56c6c4..97de2471cf 100644
--- a/actionpack/lib/action_view/testing/resolvers.rb
+++ b/actionpack/lib/action_view/testing/resolvers.rb
@@ -38,6 +38,6 @@ module ActionView #:nodoc:
[ActionView::Template.new("Template generated by Null Resolver", path, handler, :virtual_path => path, :format => format)]
end
end
-
+
end
diff --git a/actionpack/test/abstract/callbacks_test.rb b/actionpack/test/abstract/callbacks_test.rb
index 232a1679e0..b2d4d5f79a 100644
--- a/actionpack/test/abstract/callbacks_test.rb
+++ b/actionpack/test/abstract/callbacks_test.rb
@@ -2,23 +2,23 @@ require 'abstract_unit'
module AbstractController
module Testing
-
+
class ControllerWithCallbacks < AbstractController::Base
include AbstractController::Callbacks
end
-
+
class Callback1 < ControllerWithCallbacks
set_callback :process_action, :before, :first
-
+
def first
@text = "Hello world"
end
-
+
def index
self.response_body = @text
end
end
-
+
class TestCallbacks1 < ActiveSupport::TestCase
test "basic callbacks work" do
controller = Callback1.new
@@ -31,21 +31,21 @@ module AbstractController
before_filter :first
after_filter :second
around_filter :aroundz
-
+
def first
@text = "Hello world"
end
-
+
def second
@second = "Goodbye"
end
-
+
def aroundz
@aroundz = "FIRST"
yield
@aroundz << "SECOND"
end
-
+
def index
self.response_body = @text.to_s
end
@@ -54,7 +54,7 @@ module AbstractController
class Callback2Overwrite < Callback2
before_filter :first, :except => :index
end
-
+
class TestCallbacks2 < ActiveSupport::TestCase
def setup
@controller = Callback2.new
@@ -64,12 +64,12 @@ module AbstractController
result = @controller.process(:index)
assert_equal "Hello world", @controller.response_body
end
-
+
test "after_filter works" do
@controller.process(:index)
assert_equal "Goodbye", @controller.instance_variable_get("@second")
end
-
+
test "around_filter works" do
@controller.process(:index)
assert_equal "FIRSTSECOND", @controller.instance_variable_get("@aroundz")
@@ -81,16 +81,16 @@ module AbstractController
assert_equal "", @controller.response_body
end
end
-
+
class Callback3 < ControllerWithCallbacks
before_filter do |c|
c.instance_variable_set("@text", "Hello world")
end
-
+
after_filter do |c|
c.instance_variable_set("@second", "Goodbye")
end
-
+
def index
self.response_body = @text
end
@@ -100,41 +100,41 @@ module AbstractController
def setup
@controller = Callback3.new
end
-
+
test "before_filter works with procs" do
result = @controller.process(:index)
assert_equal "Hello world", @controller.response_body
end
-
+
test "after_filter works with procs" do
result = @controller.process(:index)
assert_equal "Goodbye", @controller.instance_variable_get("@second")
- end
+ end
end
-
+
class CallbacksWithConditions < ControllerWithCallbacks
before_filter :list, :only => :index
before_filter :authenticate, :except => :index
-
+
def index
self.response_body = @list.join(", ")
end
-
+
def sekrit_data
self.response_body = (@list + [@authenticated]).join(", ")
end
-
+
private
def list
@list = ["Hello", "World"]
end
-
+
def authenticate
@list = []
@authenticated = "true"
end
end
-
+
class TestCallbacksWithConditions < ActiveSupport::TestCase
def setup
@controller = CallbacksWithConditions.new
@@ -144,41 +144,41 @@ module AbstractController
@controller.process(:index)
assert_equal "Hello, World", @controller.response_body
end
-
+
test "when :only is specified, a before filter is not triggered on other actions" do
@controller.process(:sekrit_data)
assert_equal "true", @controller.response_body
end
-
+
test "when :except is specified, an after filter is not triggered on that action" do
result = @controller.process(:index)
assert_nil @controller.instance_variable_get("@authenticated")
end
end
-
+
class CallbacksWithArrayConditions < ControllerWithCallbacks
before_filter :list, :only => [:index, :listy]
before_filter :authenticate, :except => [:index, :listy]
-
+
def index
self.response_body = @list.join(", ")
end
-
+
def sekrit_data
self.response_body = (@list + [@authenticated]).join(", ")
end
-
+
private
def list
@list = ["Hello", "World"]
end
-
+
def authenticate
@list = []
@authenticated = "true"
- end
+ end
end
-
+
class TestCallbacksWithArrayConditions < ActiveSupport::TestCase
def setup
@controller = CallbacksWithArrayConditions.new
@@ -188,54 +188,54 @@ module AbstractController
result = @controller.process(:index)
assert_equal "Hello, World", @controller.response_body
end
-
+
test "when :only is specified with an array, a before filter is not triggered on other actions" do
result = @controller.process(:sekrit_data)
assert_equal "true", @controller.response_body
end
-
+
test "when :except is specified with an array, an after filter is not triggered on that action" do
result = @controller.process(:index)
assert_nil @controller.instance_variable_get("@authenticated")
end
- end
-
+ end
+
class ChangedConditions < Callback2
before_filter :first, :only => :index
-
+
def not_index
self.response_body = @text.to_s
end
end
-
+
class TestCallbacksWithChangedConditions < ActiveSupport::TestCase
def setup
@controller = ChangedConditions.new
end
-
+
test "when a callback is modified in a child with :only, it works for the :only action" do
result = @controller.process(:index)
assert_equal "Hello world", @controller.response_body
end
-
+
test "when a callback is modified in a child with :only, it does not work for other actions" do
result = @controller.process(:not_index)
assert_equal "", @controller.response_body
end
end
-
+
class SetsResponseBody < ControllerWithCallbacks
before_filter :set_body
-
+
def index
self.response_body = "Fail"
end
-
+
def set_body
self.response_body = "Success"
end
end
-
+
class TestHalting < ActiveSupport::TestCase
test "when a callback sets the response body, the action should not be invoked" do
controller = SetsResponseBody.new
@@ -243,6 +243,6 @@ module AbstractController
assert_equal "Success", controller.response_body
end
end
-
+
end
end
diff --git a/actionpack/test/abstract/helper_test.rb b/actionpack/test/abstract/helper_test.rb
index 15c27501f2..73941222dc 100644
--- a/actionpack/test/abstract/helper_test.rb
+++ b/actionpack/test/abstract/helper_test.rb
@@ -4,7 +4,7 @@ ActionController::Base.helpers_path = File.expand_path('../../fixtures/helpers',
module AbstractController
module Testing
-
+
class ControllerWithHelpers < AbstractController::Base
include AbstractController::Rendering
include Helpers
@@ -13,13 +13,13 @@ module AbstractController
render :inline => "Module <%= included_method %>"
end
end
-
+
module HelperyTest
def included_method
"Included"
end
end
-
+
class AbstractHelpers < ControllerWithHelpers
helper(HelperyTest) do
def helpery_test
@@ -76,6 +76,6 @@ module AbstractController
end
end
-
+
end
end
diff --git a/actionpack/test/abstract/translation_test.rb b/actionpack/test/abstract/translation_test.rb
index 09ebfab85e..8ec50fd57a 100644
--- a/actionpack/test/abstract/translation_test.rb
+++ b/actionpack/test/abstract/translation_test.rb
@@ -7,19 +7,19 @@ class TranslationControllerTest < Test::Unit::TestCase
def setup
@controller = ActionController::Base.new
end
-
+
def test_action_controller_base_responds_to_translate
assert_respond_to @controller, :translate
end
-
+
def test_action_controller_base_responds_to_t
assert_respond_to @controller, :t
end
-
+
def test_action_controller_base_responds_to_localize
assert_respond_to @controller, :localize
end
-
+
def test_action_controller_base_responds_to_l
assert_respond_to @controller, :l
end
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 5be47f7c96..fb6961d4a3 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -218,7 +218,7 @@ class ActionController::IntegrationTest < ActiveSupport::TestCase
end
def with_autoload_path(path)
- path = File.join(File.dirname(__FILE__), "fixtures", path)
+ path = File.join(File.dirname(__FILE__), "fixtures", path)
if ActiveSupport::Dependencies.autoload_paths.include?(path)
yield
else
diff --git a/actionpack/test/controller/assert_select_test.rb b/actionpack/test/controller/assert_select_test.rb
index 4f8ad23174..ef0df9d6a8 100644
--- a/actionpack/test/controller/assert_select_test.rb
+++ b/actionpack/test/controller/assert_select_test.rb
@@ -257,7 +257,7 @@ class AssertSelectTest < ActionController::TestCase
end
assert_raise(Assertion) {assert_select_rjs :insert, :top, "test2"}
end
-
+
def test_assert_select_rjs_for_redirect_to
render_rjs do |page|
page.redirect_to '/'
diff --git a/actionpack/test/controller/base_test.rb b/actionpack/test/controller/base_test.rb
index ae270b751e..032c22db3b 100644
--- a/actionpack/test/controller/base_test.rb
+++ b/actionpack/test/controller/base_test.rb
@@ -87,7 +87,7 @@ class RecordIdentifierController < ActionController::Base
end
class ControllerClassTests < ActiveSupport::TestCase
-
+
def test_controller_path
assert_equal 'empty', EmptyController.controller_path
assert_equal EmptyController.controller_path, EmptyController.new.controller_path
@@ -99,7 +99,7 @@ class ControllerClassTests < ActiveSupport::TestCase
assert_equal 'empty', EmptyController.controller_name
assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name
end
-
+
def test_filter_parameter_logging
parameters = []
config = mock(:config => mock(:filter_parameters => parameters))
@@ -164,15 +164,15 @@ class PerformActionTest < ActionController::TestCase
rescue_action_in_public!
end
-
+
def test_process_should_be_precise
use_controller EmptyController
exception = assert_raise AbstractController::ActionNotFound do
get :non_existent
end
- assert_equal exception.message, "The action 'non_existent' could not be found for EmptyController"
+ assert_equal exception.message, "The action 'non_existent' could not be found for EmptyController"
end
-
+
def test_get_on_priv_should_show_selector
use_controller MethodMissingController
get :shouldnt_be_called
@@ -224,7 +224,7 @@ class UrlOptionsTest < ActionController::TestCase
assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url)
assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options')
end
- end
+ end
def test_url_helpers_does_not_become_actions
with_routing do |set|
diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb
index 7e19bce3b7..ebe089aaf4 100644
--- a/actionpack/test/controller/dispatcher_test.rb
+++ b/actionpack/test/controller/dispatcher_test.rb
@@ -6,7 +6,7 @@ class DeprecatedDispatcherTest < ActiveSupport::TestCase
def call(env)
[200, {}, 'response']
end
- end
+ end
def setup
ActionDispatch::Callbacks.reset_callbacks(:prepare)
diff --git a/actionpack/test/controller/filters_test.rb b/actionpack/test/controller/filters_test.rb
index 14f1bd797a..d0fd9e8e46 100644
--- a/actionpack/test/controller/filters_test.rb
+++ b/actionpack/test/controller/filters_test.rb
@@ -447,7 +447,7 @@ class FilterTest < ActionController::TestCase
class ::AppSweeper < ActionController::Caching::Sweeper; end
class SweeperTestController < ActionController::Base
- cache_sweeper :app_sweeper
+ cache_sweeper :app_sweeper
def show
render :text => 'hello world'
end
diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb
index 9b9657929f..ad66f138eb 100644
--- a/actionpack/test/controller/helper_test.rb
+++ b/actionpack/test/controller/helper_test.rb
@@ -50,7 +50,7 @@ class HelperTest < ActiveSupport::TestCase
# Set default test helper.
self.test_helper = LocalAbcHelper
end
-
+
def test_deprecated_helper
assert_equal expected_helper_methods, missing_methods
assert_nothing_raised { @controller_class.helper TestHelper }
@@ -70,25 +70,25 @@ class HelperTest < ActiveSupport::TestCase
def call_controller(klass, action)
request = ActionController::TestRequest.new
- klass.action(action).call(request.env)
+ klass.action(action).call(request.env)
end
def test_helper_for_nested_controller
- assert_equal 'hello: Iz guuut!',
+ assert_equal 'hello: Iz guuut!',
call_controller(Fun::GamesController, "render_hello_world").last.body
# request = ActionController::TestRequest.new
- #
+ #
# resp = Fun::GamesController.action(:render_hello_world).call(request.env)
# assert_equal 'hello: Iz guuut!', resp.last.body
end
def test_helper_for_acronym_controller
assert_equal "test: baz", call_controller(Fun::PdfController, "test").last.body
- #
+ #
# request = ActionController::TestRequest.new
# response = ActionController::TestResponse.new
# request.action = 'test'
- #
+ #
# assert_equal 'test: baz', Fun::PdfController.process(request, response).body
end
@@ -192,7 +192,7 @@ class IsolatedHelpersTest < ActiveSupport::TestCase
def call_controller(klass, action)
request = ActionController::TestRequest.new
- klass.action(action).call(request.env)
+ klass.action(action).call(request.env)
end
def setup
diff --git a/actionpack/test/controller/http_basic_authentication_test.rb b/actionpack/test/controller/http_basic_authentication_test.rb
index 23688ca584..01c650a494 100644
--- a/actionpack/test/controller/http_basic_authentication_test.rb
+++ b/actionpack/test/controller/http_basic_authentication_test.rb
@@ -13,7 +13,7 @@ class HttpBasicAuthenticationTest < ActionController::TestCase
def display
render :text => 'Definitely Maybe'
end
-
+
def show
render :text => 'Only for loooooong credentials'
end
@@ -33,7 +33,7 @@ class HttpBasicAuthenticationTest < ActionController::TestCase
request_http_basic_authentication("SuperSecret")
end
end
-
+
def authenticate_long_credentials
authenticate_or_request_with_http_basic do |username, password|
username == '1234567890123456789012345678901234567890' && password == '1234567890123456789012345678901234567890'
@@ -56,7 +56,7 @@ class HttpBasicAuthenticationTest < ActionController::TestCase
test "successful authentication with #{header.downcase} and long credentials" do
@request.env[header] = encode_credentials('1234567890123456789012345678901234567890', '1234567890123456789012345678901234567890')
get :show
-
+
assert_response :success
assert_equal 'Only for loooooong credentials', @response.body, "Authentication failed for request header #{header} and long credentials"
end
diff --git a/actionpack/test/controller/http_token_authentication_test.rb b/actionpack/test/controller/http_token_authentication_test.rb
index 3dfccae3db..3054c1684c 100644
--- a/actionpack/test/controller/http_token_authentication_test.rb
+++ b/actionpack/test/controller/http_token_authentication_test.rb
@@ -13,7 +13,7 @@ class HttpTokenAuthenticationTest < ActionController::TestCase
def display
render :text => 'Definitely Maybe'
end
-
+
def show
render :text => 'Only for loooooong credentials'
end
@@ -33,7 +33,7 @@ class HttpTokenAuthenticationTest < ActionController::TestCase
request_http_token_authentication("SuperSecret")
end
end
-
+
def authenticate_long_credentials
authenticate_or_request_with_http_token do |token, options|
token == '1234567890123456789012345678901234567890' && options[:algorithm] == 'test'
@@ -56,7 +56,7 @@ class HttpTokenAuthenticationTest < ActionController::TestCase
test "successful authentication with #{header.downcase} and long credentials" do
@request.env[header] = encode_credentials('1234567890123456789012345678901234567890', :algorithm => 'test')
get :show
-
+
assert_response :success
assert_equal 'Only for loooooong credentials', @response.body, "Authentication failed for request header #{header} and long credentials"
end
diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb
index 165c61ffad..e8751747d1 100644
--- a/actionpack/test/controller/layout_test.rb
+++ b/actionpack/test/controller/layout_test.rb
@@ -115,7 +115,7 @@ end
class LayoutSetInResponseTest < ActionController::TestCase
include ActionView::Template::Handlers
-
+
def test_layout_set_when_using_default_layout
@controller = DefaultLayoutController.new
get :hello
@@ -127,7 +127,7 @@ class LayoutSetInResponseTest < ActionController::TestCase
get :hello
assert_template :layout => "layouts/item"
end
-
+
def test_layout_only_exception_when_included
@controller = OnlyLayoutController.new
get :hello
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index b5ce391b61..6364b7140d 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -36,7 +36,7 @@ class RespondToController < ActionController::Base
type.all { render :text => "Nothing" }
end
end
-
+
def json_xml_or_html
respond_to do |type|
type.json { render :text => 'JSON' }
@@ -44,7 +44,7 @@ class RespondToController < ActionController::Base
type.html { render :text => 'HTML' }
end
end
-
+
def forced_xml
request.format = :xml
@@ -373,17 +373,17 @@ class RespondToControllerTest < ActionController::TestCase
get :handle_any_any
assert_equal 'Whatever you ask for, I got it', @response.body
end
-
+
def test_browser_check_with_any_any
@request.accept = "application/json, application/xml"
get :json_xml_or_html
assert_equal 'JSON', @response.body
-
+
@request.accept = "application/json, application/xml, */*"
get :json_xml_or_html
assert_equal 'HTML', @response.body
end
-
+
def test_rjs_type_skips_layout
@request.accept = "text/javascript"
diff --git a/actionpack/test/controller/new_base/etag_test.rb b/actionpack/test/controller/new_base/etag_test.rb
index 51bfb2278a..2bca5aec6a 100644
--- a/actionpack/test/controller/new_base/etag_test.rb
+++ b/actionpack/test/controller/new_base/etag_test.rb
@@ -34,7 +34,7 @@ module Etags
body = "teh Hello from without_layout.html.erb tagz"
assert_body body
assert_header "Etag", etag_for(body)
- assert_status 200
+ assert_status 200
end
private
diff --git a/actionpack/test/controller/new_base/render_implicit_action_test.rb b/actionpack/test/controller/new_base/render_implicit_action_test.rb
index 90cc7933ff..9f69d20329 100644
--- a/actionpack/test/controller/new_base/render_implicit_action_test.rb
+++ b/actionpack/test/controller/new_base/render_implicit_action_test.rb
@@ -6,10 +6,10 @@ module RenderImplicitAction
"render_implicit_action/simple/hello_world.html.erb" => "Hello world!",
"render_implicit_action/simple/hyphen-ated.html.erb" => "Hello hyphen-ated!"
)]
-
+
def hello_world() end
end
-
+
class RenderImplicitActionTest < Rack::TestCase
test "render a simple action with new explicit call to render" do
get "/render_implicit_action/simple/hello_world"
diff --git a/actionpack/test/controller/new_base/render_layout_test.rb b/actionpack/test/controller/new_base/render_layout_test.rb
index 372fb66b88..bb2a953536 100644
--- a/actionpack/test/controller/new_base/render_layout_test.rb
+++ b/actionpack/test/controller/new_base/render_layout_test.rb
@@ -71,7 +71,7 @@ module ControllerLayouts
self.view_paths = [ActionView::FixtureResolver.new(
"layouts/application.html.erb" => "<html><%= yield %></html>",
"controller_layouts/mismatch_format/index.js.rjs" => "page[:test].ext",
- "controller_layouts/mismatch_format/implicit.rjs" => "page[:test].ext"
+ "controller_layouts/mismatch_format/implicit.rjs" => "page[:test].ext"
)]
def explicit
diff --git a/actionpack/test/controller/new_base/render_partial_test.rb b/actionpack/test/controller/new_base/render_partial_test.rb
index 1a1b36a65e..5c7e66dba2 100644
--- a/actionpack/test/controller/new_base/render_partial_test.rb
+++ b/actionpack/test/controller/new_base/render_partial_test.rb
@@ -1,27 +1,27 @@
require 'abstract_unit'
module RenderPartial
-
+
class BasicController < ActionController::Base
-
+
self.view_paths = [ActionView::FixtureResolver.new(
"render_partial/basic/_basic.html.erb" => "BasicPartial!",
"render_partial/basic/basic.html.erb" => "<%= @test_unchanged = 'goodbye' %><%= render :partial => 'basic' %><%= @test_unchanged %>"
)]
-
+
def changing
@test_unchanged = 'hello'
render :action => "basic"
- end
+ end
end
-
+
class TestPartial < Rack::TestCase
testing BasicController
-
+
test "rendering a partial in ActionView doesn't pull the ivars again from the controller" do
get :changing
assert_response("goodbyeBasicPartial!goodbye")
end
end
-
+
end
diff --git a/actionpack/test/controller/new_base/render_test.rb b/actionpack/test/controller/new_base/render_test.rb
index d985d9f9ad..6bd7453d1a 100644
--- a/actionpack/test/controller/new_base/render_test.rb
+++ b/actionpack/test/controller/new_base/render_test.rb
@@ -65,7 +65,7 @@ module Render
end
end
end
-
+
class TestVariousObjectsAvailableInView < Rack::TestCase
test "The request object is accessible in the view" do
get "/render/blank_render/access_request"
diff --git a/actionpack/test/controller/new_base/render_text_test.rb b/actionpack/test/controller/new_base/render_text_test.rb
index 0e6f51c998..81c2a9daf2 100644
--- a/actionpack/test/controller/new_base/render_text_test.rb
+++ b/actionpack/test/controller/new_base/render_text_test.rb
@@ -3,7 +3,7 @@ require 'abstract_unit'
module RenderText
class SimpleController < ActionController::Base
self.view_paths = [ActionView::FixtureResolver.new]
-
+
def index
render :text => "hello david"
end
@@ -14,24 +14,24 @@ module RenderText
"layouts/application.html.erb" => "<%= yield %>, I'm here!",
"layouts/greetings.html.erb" => "<%= yield %>, I wish thee well.",
"layouts/ivar.html.erb" => "<%= yield %>, <%= @ivar %>"
- )]
-
+ )]
+
def index
render :text => "hello david"
end
-
+
def custom_code
render :text => "hello world", :status => 404
end
-
+
def with_custom_code_as_string
render :text => "hello world", :status => "404 Not Found"
end
-
+
def with_nil
render :text => nil
end
-
+
def with_nil_and_status
render :text => nil, :status => 403
end
@@ -39,23 +39,23 @@ module RenderText
def with_false
render :text => false
end
-
+
def with_layout_true
render :text => "hello world", :layout => true
end
-
+
def with_layout_false
render :text => "hello world", :layout => false
end
-
+
def with_layout_nil
render :text => "hello world", :layout => nil
end
-
+
def with_custom_layout
render :text => "hello world", :layout => "greetings"
end
-
+
def with_ivar_in_layout
@ivar = "hello world"
render :text => "hello world", :layout => "ivar"
diff --git a/actionpack/test/controller/new_base/render_xml_test.rb b/actionpack/test/controller/new_base/render_xml_test.rb
index d044738a78..b8527a943d 100644
--- a/actionpack/test/controller/new_base/render_xml_test.rb
+++ b/actionpack/test/controller/new_base/render_xml_test.rb
@@ -1,7 +1,7 @@
require 'abstract_unit'
module RenderXml
-
+
# This has no layout and it works
class BasicController < ActionController::Base
self.view_paths = [ActionView::FixtureResolver.new(
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index a57a12f271..258f511f10 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -7,7 +7,7 @@ module Fun
# :ported:
def hello_world
end
-
+
def nested_partial_with_form_builder
render :partial => ActionView::Helpers::FormBuilder.new(:post, nil, view_context, {}, Proc.new {})
end
@@ -1234,7 +1234,7 @@ class RenderTest < ActionController::TestCase
assert_match(/<label/, @response.body)
assert_template('test/_labelling_form')
end
-
+
def test_nested_partial_with_form_builder
@controller = Fun::GamesController.new
get :nested_partial_with_form_builder
diff --git a/actionpack/test/controller/rescue_test.rb b/actionpack/test/controller/rescue_test.rb
index a24de62b19..f476db3792 100644
--- a/actionpack/test/controller/rescue_test.rb
+++ b/actionpack/test/controller/rescue_test.rb
@@ -149,7 +149,7 @@ class RescueController < ActionController::Base
def missing_template
end
-
+
def io_error_in_view
raise ActionView::TemplateError.new(nil, {}, IOError.new('this is io error'))
end
diff --git a/actionpack/test/controller/selector_test.rb b/actionpack/test/controller/selector_test.rb
index 5a5dc840b5..23ccbf6987 100644
--- a/actionpack/test/controller/selector_test.rb
+++ b/actionpack/test/controller/selector_test.rb
@@ -437,7 +437,7 @@ class SelectorTest < Test::Unit::TestCase
assert_equal "4", @matches[1].attributes["id"]
end
-
+
def test_first_and_last
parse(%Q{<table><thead></thead><tr id="1"></tr><tr id="2"></tr><tr id="3"></tr><tr id="4"></tr></table>})
# First child.
@@ -503,7 +503,7 @@ class SelectorTest < Test::Unit::TestCase
assert_equal 1, @matches.size
end
-
+
def test_content
parse(%Q{<div> </div>})
select("div:content()")
@@ -582,7 +582,7 @@ class SelectorTest < Test::Unit::TestCase
assert_equal "foo", @matches[0].attributes["title"]
end
-
+
def test_pseudo_class_negation
parse(%Q{<div><p id="1"></p><p id="2"></p></div>})
select("p")
@@ -594,7 +594,7 @@ class SelectorTest < Test::Unit::TestCase
assert_equal 1, @matches.size
assert_equal "1", @matches[0].attributes["id"]
end
-
+
def test_negation_details
parse(%Q{<p id="1"></p><p id="2"></p><p id="3"></p>})
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index 13c9d9ee38..7e7e4bd463 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -462,7 +462,7 @@ XML
def test_assert_routing_in_module
assert_routing 'admin/user', :controller => 'admin/user', :action => 'index'
end
-
+
def test_assert_routing_with_glob
with_routing do |set|
set.draw { |map| match('*path' => "pages#show") }
diff --git a/actionpack/test/controller/view_paths_test.rb b/actionpack/test/controller/view_paths_test.rb
index b8972b04b6..edfcb5cc4d 100644
--- a/actionpack/test/controller/view_paths_test.rb
+++ b/actionpack/test/controller/view_paths_test.rb
@@ -20,7 +20,7 @@ class ViewLoadPathsTest < ActionController::TestCase
layout 'test/sub'
def hello_world; render(:template => 'test/hello_world'); end
end
-
+
def setup
# TestController.view_paths = nil
@@ -64,7 +64,7 @@ class ViewLoadPathsTest < ActionController::TestCase
@controller.append_view_path(%w(bar baz))
assert_paths(FIXTURE_LOAD_PATH, "foo", "bar", "baz")
-
+
@controller.append_view_path(FIXTURE_LOAD_PATH)
assert_paths(FIXTURE_LOAD_PATH, "foo", "bar", "baz", FIXTURE_LOAD_PATH)
end
diff --git a/actionpack/test/dispatch/callbacks_test.rb b/actionpack/test/dispatch/callbacks_test.rb
index 9df882ce75..d3aa55a1ba 100644
--- a/actionpack/test/dispatch/callbacks_test.rb
+++ b/actionpack/test/dispatch/callbacks_test.rb
@@ -9,7 +9,7 @@ class DispatcherTest < Test::Unit::TestCase
def call(env)
[200, {}, 'response']
end
- end
+ end
def setup
Foo.a, Foo.b = 0, 0
diff --git a/actionpack/test/dispatch/mount_test.rb b/actionpack/test/dispatch/mount_test.rb
index 00ca5ec9dc..0f584af31e 100644
--- a/actionpack/test/dispatch/mount_test.rb
+++ b/actionpack/test/dispatch/mount_test.rb
@@ -28,7 +28,7 @@ class TestRoutingMount < ActionDispatch::IntegrationTest
get "/its_a/sprocket/omg"
assert_equal "/its_a/sprocket -- /omg", response.body
end
-
+
def test_mounting_with_shorthand
get "/shorthand/omg"
assert_equal "/shorthand -- /omg", response.body
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index c8947aac80..249fa406a0 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -428,7 +428,7 @@ class RequestTest < ActiveSupport::TestCase
assert_equal "[FILTERED]", request.raw_post
assert_equal "[FILTERED]", request.params["amount"]
- assert_equal "1", request.params["step"]
+ assert_equal "1", request.params["step"]
end
protected
diff --git a/actionpack/test/dispatch/session/cookie_store_test.rb b/actionpack/test/dispatch/session/cookie_store_test.rb
index 3864821ef0..d60362fb10 100644
--- a/actionpack/test/dispatch/session/cookie_store_test.rb
+++ b/actionpack/test/dispatch/session/cookie_store_test.rb
@@ -118,11 +118,11 @@ class CookieStoreTest < ActionController::IntegrationTest
assert_equal 'id: ce8b0752a6ab7c7af3cdb8a80e6b9e46', response.body, "should auto-load unloaded class"
end
end
- end
-
+ end
+
def test_deserializes_unloaded_classes_on_get_value
with_test_route_set do
- with_autoload_path "session_autoload_test" do
+ with_autoload_path "session_autoload_test" do
cookies[SessionKey] = SignedSerializedCookie
get '/get_session_value'
assert_response :success
@@ -267,7 +267,7 @@ class CookieStoreTest < ActionController::IntegrationTest
end
end
- def test_session_store_without_domain
+ def test_session_store_without_domain
with_test_route_set do
get '/set_session_value'
assert_no_match(/domain\=/, headers['Set-Cookie'])
diff --git a/actionpack/test/dispatch/session/mem_cache_store_test.rb b/actionpack/test/dispatch/session/mem_cache_store_test.rb
index 9bd6f9b8c4..6b21678d25 100644
--- a/actionpack/test/dispatch/session/mem_cache_store_test.rb
+++ b/actionpack/test/dispatch/session/mem_cache_store_test.rb
@@ -11,7 +11,7 @@ class MemCacheStoreTest < ActionController::IntegrationTest
session[:foo] = "bar"
head :ok
end
-
+
def set_serialized_session_value
session[:foo] = SessionAutoloadTest::Foo.new
head :ok
diff --git a/actionpack/test/fixtures/companies.yml b/actionpack/test/fixtures/companies.yml
index 707f72abc6..ed2992e0b1 100644
--- a/actionpack/test/fixtures/companies.yml
+++ b/actionpack/test/fixtures/companies.yml
@@ -17,7 +17,7 @@ Google:
id: 4
name: Google
rating: 4
-
+
Ionist:
id: 5
name: Ioni.st
diff --git a/actionpack/test/fixtures/company.rb b/actionpack/test/fixtures/company.rb
index cbbd0edb14..cd39ea7898 100644
--- a/actionpack/test/fixtures/company.rb
+++ b/actionpack/test/fixtures/company.rb
@@ -6,5 +6,5 @@ class Company < ActiveRecord::Base
validates_presence_of :name
def validate
errors.add('rating', 'rating should not be 2') if rating == 2
- end
+ end
end \ No newline at end of file
diff --git a/actionpack/test/fixtures/db_definitions/sqlite.sql b/actionpack/test/fixtures/db_definitions/sqlite.sql
index 8e1947d14a..99df4b3e61 100644
--- a/actionpack/test/fixtures/db_definitions/sqlite.sql
+++ b/actionpack/test/fixtures/db_definitions/sqlite.sql
@@ -5,20 +5,20 @@ CREATE TABLE 'companies' (
);
CREATE TABLE 'replies' (
- 'id' INTEGER PRIMARY KEY NOT NULL,
- 'content' text,
- 'created_at' datetime,
- 'updated_at' datetime,
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'content' text,
+ 'created_at' datetime,
+ 'updated_at' datetime,
'topic_id' integer,
'developer_id' integer
);
CREATE TABLE 'topics' (
- 'id' INTEGER PRIMARY KEY NOT NULL,
- 'title' varchar(255),
- 'subtitle' varchar(255),
- 'content' text,
- 'created_at' datetime,
+ 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'title' varchar(255),
+ 'subtitle' varchar(255),
+ 'content' text,
+ 'created_at' datetime,
'updated_at' datetime
);
@@ -43,7 +43,7 @@ CREATE TABLE 'developers_projects' (
);
CREATE TABLE 'mascots' (
- 'id' INTEGER PRIMARY KEY NOT NULL,
+ 'id' INTEGER PRIMARY KEY NOT NULL,
'company_id' INTEGER NOT NULL,
'name' TEXT DEFAULT NULL
); \ No newline at end of file
diff --git a/actionpack/test/fixtures/replies.yml b/actionpack/test/fixtures/replies.yml
index 66020b706a..2a3454b8bf 100644
--- a/actionpack/test/fixtures/replies.yml
+++ b/actionpack/test/fixtures/replies.yml
@@ -5,7 +5,7 @@ witty_retort:
content: Birdman is better!
created_at: <%= 6.hours.ago.to_s(:db) %>
updated_at: nil
-
+
another:
id: 2
topic_id: 2
diff --git a/actionpack/test/fixtures/test/hello_xml_world.builder b/actionpack/test/fixtures/test/hello_xml_world.builder
index 02b14fe87c..e7081b89fe 100644
--- a/actionpack/test/fixtures/test/hello_xml_world.builder
+++ b/actionpack/test/fixtures/test/hello_xml_world.builder
@@ -2,7 +2,7 @@ xml.html do
xml.head do
xml.title "Hello World"
end
-
+
xml.body do
xml.p "abes"
xml.p "monks"
diff --git a/actionpack/test/fixtures/topics.yml b/actionpack/test/fixtures/topics.yml
index 61ea02d76f..7fdd49d54e 100644
--- a/actionpack/test/fixtures/topics.yml
+++ b/actionpack/test/fixtures/topics.yml
@@ -5,7 +5,7 @@ futurama:
content: I like futurama
created_at: <%= 1.day.ago.to_s(:db) %>
updated_at:
-
+
harvey_birdman:
id: 2
title: Harvey Birdman is the king of all men
diff --git a/actionpack/test/template/compiled_templates_test.rb b/actionpack/test/template/compiled_templates_test.rb
index 2c719757e4..3f31edd5ce 100644
--- a/actionpack/test/template/compiled_templates_test.rb
+++ b/actionpack/test/template/compiled_templates_test.rb
@@ -8,7 +8,7 @@ class CompiledTemplatesTest < Test::Unit::TestCase
@compiled_templates.send(:remove_method, m) if m =~ /^_render_template_/
end
end
-
+
def test_template_gets_recompiled_when_using_different_keys_in_local_assigns
assert_equal "one", render(:file => "test/render_file_with_locals_and_default.erb")
assert_equal "two", render(:file => "test/render_file_with_locals_and_default.erb", :locals => { :secret => "two" })
diff --git a/actionpack/test/template/date_helper_i18n_test.rb b/actionpack/test/template/date_helper_i18n_test.rb
index b69a449617..74498e4ffc 100644
--- a/actionpack/test/template/date_helper_i18n_test.rb
+++ b/actionpack/test/template/date_helper_i18n_test.rb
@@ -62,7 +62,7 @@ class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase
[:'about_x_years', 1] => 'about 1 year',
[:'about_x_years', 2] => 'about 2 years',
[:'over_x_years', 1] => 'over 1 year',
- [:'over_x_years', 2] => 'over 2 years'
+ [:'over_x_years', 2] => 'over 2 years'
}.each do |args, expected|
key, count = *args
diff --git a/actionpack/test/template/date_helper_test.rb b/actionpack/test/template/date_helper_test.rb
index a1db49d4d0..0d9508dfe8 100644
--- a/actionpack/test/template/date_helper_test.rb
+++ b/actionpack/test/template/date_helper_test.rb
@@ -673,7 +673,7 @@ class DateHelperTest < ActionView::TestCase
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)
-
+
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), :start_year => 2003, :end_year => 2005, :prefix => "date[first]", :order => [:day])
end
@@ -897,7 +897,7 @@ class DateHelperTest < ActionView::TestCase
assert_dom_equal expected, select_date(Time.mktime(2003, 8, 16), { :date_separator => " / ", :discard_day => true, :start_year => 2003, :end_year => 2005, :prefix => "date[first]"})
end
-
+
def test_select_date_with_separator_discard_month_and_day
expected = %(<select id="date_first_year" name="date[first][year]">\n)
expected << %(<option value="2003" selected="selected">2003</option>\n<option value="2004">2004</option>\n<option value="2005">2005</option>\n)
@@ -978,7 +978,7 @@ class DateHelperTest < ActionView::TestCase
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</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<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
expected << "</select>\n"
- expected << " &mdash; "
+ expected << " &mdash; "
expected << %(<select id="date_first_hour" name="date[first][hour]">\n)
expected << %(<option 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)
@@ -1007,7 +1007,7 @@ class DateHelperTest < ActionView::TestCase
expected << %(<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="4">4</option>\n<option value="5">5</option>\n<option value="6">6</option>\n<option value="7">7</option>\n<option value="8">8</option>\n<option value="9">9</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" selected="selected">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<option value="24">24</option>\n<option value="25">25</option>\n<option value="26">26</option>\n<option value="27">27</option>\n<option value="28">28</option>\n<option value="29">29</option>\n<option value="30">30</option>\n<option value="31">31</option>\n)
expected << "</select>\n"
- expected << " &mdash; "
+ expected << " &mdash; "
expected << %(<select id="date_first_hour" name="date[first][hour]" class="selector">\n)
expected << %(<option 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" selected="selected">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)
@@ -1121,7 +1121,7 @@ class DateHelperTest < ActionView::TestCase
expected = %(<input name="date[year]" id="date_year" value="2003" type="hidden" />\n)
expected << %(<input name="date[month]" id="date_month" value="8" type="hidden" />\n)
expected << %(<input name="date[day]" id="date_day" value="16" type="hidden" />\n)
-
+
expected << %(<select id="date_hour" name="date[hour]">\n)
expected << %(<option 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" selected="selected">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)
expected << "</select>\n"
@@ -1158,7 +1158,7 @@ class DateHelperTest < ActionView::TestCase
expected = %(<input name="date[year]" id="date_year" value="2003" type="hidden" />\n)
expected << %(<input name="date[month]" id="date_month" value="8" type="hidden" />\n)
expected << %(<input name="date[day]" id="date_day" value="16" type="hidden" />\n)
-
+
expected << %(<select id="date_hour" name="date[hour]">\n)
expected << %(<option 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" selected="selected">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)
expected << "</select>\n"
@@ -1182,7 +1182,7 @@ class DateHelperTest < ActionView::TestCase
expected = %(<input name="date[year]" id="date_year" value="2003" type="hidden" />\n)
expected << %(<input name="date[month]" id="date_month" value="8" type="hidden" />\n)
expected << %(<input name="date[day]" id="date_day" value="16" type="hidden" />\n)
-
+
expected << %(<select id="date_hour" name="date[hour]">\n)
expected << %(<option 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" selected="selected">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)
expected << "</select>\n"
@@ -1206,7 +1206,7 @@ class DateHelperTest < ActionView::TestCase
expected = %(<input name="date[year]" id="date_year" value="2003" type="hidden" />\n)
expected << %(<input name="date[month]" id="date_month" value="8" type="hidden" />\n)
expected << %(<input name="date[day]" id="date_day" value="16" type="hidden" />\n)
-
+
expected << %(<select id="date_hour" name="date[hour]" class="selector">\n)
expected << %(<option 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" selected="selected">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)
expected << "</select>\n"
@@ -1229,11 +1229,11 @@ class DateHelperTest < ActionView::TestCase
expected = %(<input name="date[year]" id="date_year" value="2003" type="hidden" />\n)
expected << %(<input name="date[month]" id="date_month" value="8" type="hidden" />\n)
expected << %(<input name="date[day]" id="date_day" value="16" type="hidden" />\n)
-
+
expected << %(<select id="date_hour" name="date[hour]">\n)
expected << %(<option value="">Hour</option>\n<option 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" selected="selected">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)
expected << "</select>\n"
-
+
expected << " : "
expected << %(<select id="date_minute" name="date[minute]">\n)
@@ -1253,7 +1253,7 @@ class DateHelperTest < ActionView::TestCase
expected = %(<input name="date[year]" id="date_year" value="2003" type="hidden" />\n)
expected << %(<input name="date[month]" id="date_month" value="8" type="hidden" />\n)
expected << %(<input name="date[day]" id="date_day" value="16" type="hidden" />\n)
-
+
expected << %(<select id="date_hour" name="date[hour]">\n)
expected << %(<option value="">Choose hour</option>\n<option 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" selected="selected">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)
expected << "</select>\n"
@@ -2670,13 +2670,13 @@ class DateHelperTest < ActionView::TestCase
assert select_time(Time.mktime(2003, 8, 16, 8, 4, 18), {}, :class => 'selector').html_safe?
assert select_date(Time.mktime(2003, 8, 16), :date_separator => " / ", :start_year => 2003, :end_year => 2005, :prefix => "date[first]").html_safe?
end
-
+
def test_object_select_html_safety
@post = Post.new
@post.written_on = Date.new(2004, 6, 15)
- assert date_select("post", "written_on", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true).html_safe?
- assert time_select("post", "written_on", :ignore_date => true).html_safe?
+ assert date_select("post", "written_on", :default => Time.local(2006, 9, 19, 15, 16, 35), :include_blank => true).html_safe?
+ assert time_select("post", "written_on", :ignore_date => true).html_safe?
end
protected
diff --git a/actionpack/test/template/erb_util_test.rb b/actionpack/test/template/erb_util_test.rb
index d3129d0e1a..d1891094e8 100644
--- a/actionpack/test/template/erb_util_test.rb
+++ b/actionpack/test/template/erb_util_test.rb
@@ -14,7 +14,7 @@ class ErbUtilTest < Test::Unit::TestCase
end
end
end
-
+
def test_html_escape_is_html_safe
escaped = h("<p>")
assert_equal "&lt;p&gt;", escaped
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index d14e5020c7..3dfaffbe97 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -305,7 +305,7 @@ class FormOptionsHelperTest < ActionView::TestCase
output_buffer = fields_for :post, @post do |f|
concat f.select(:category, %w( abe <mus> hest))
end
-
+
assert_dom_equal(
"<select id=\"post_category\" name=\"post[category]\"><option value=\"abe\">abe</option>\n<option value=\"&lt;mus&gt;\" selected=\"selected\">&lt;mus&gt;</option>\n<option value=\"hest\">hest</option></select>",
output_buffer
@@ -438,11 +438,11 @@ class FormOptionsHelperTest < ActionView::TestCase
def test_select_with_index_option
@album = Album.new
@album.id = 1
-
- expected = "<select id=\"album__genre\" name=\"album[][genre]\"><option value=\"rap\">rap</option>\n<option value=\"rock\">rock</option>\n<option value=\"country\">country</option></select>"
+
+ expected = "<select id=\"album__genre\" name=\"album[][genre]\"><option value=\"rap\">rap</option>\n<option value=\"rock\">rock</option>\n<option value=\"country\">country</option></select>"
assert_dom_equal(
- expected,
+ expected,
select("album[]", "genre", %w[rap rock country], {}, { :index => nil })
)
end
@@ -491,7 +491,7 @@ class FormOptionsHelperTest < ActionView::TestCase
output_buffer = fields_for :post, @post do |f|
concat f.collection_select(:author_name, dummy_posts, :author_name, :author_name)
end
-
+
assert_dom_equal(
"<select id=\"post_author_name\" name=\"post[author_name]\"><option value=\"&lt;Abe&gt;\">&lt;Abe&gt;</option>\n<option value=\"Babe\" selected=\"selected\">Babe</option>\n<option value=\"Cabe\">Cabe</option></select>",
output_buffer
@@ -599,7 +599,7 @@ class FormOptionsHelperTest < ActionView::TestCase
output_buffer = fields_for :firm, @firm do |f|
concat f.time_zone_select(:time_zone)
end
-
+
assert_dom_equal(
"<select id=\"firm_time_zone\" name=\"firm[time_zone]\">" +
"<option value=\"A\">A</option>\n" +
diff --git a/actionpack/test/template/html-scanner/document_test.rb b/actionpack/test/template/html-scanner/document_test.rb
index c68f04fa75..ddfb351595 100644
--- a/actionpack/test/template/html-scanner/document_test.rb
+++ b/actionpack/test/template/html-scanner/document_test.rb
@@ -15,7 +15,7 @@ class DocumentTest < Test::Unit::TestCase
assert_match %r{\s+}m, doc.root.children[1].content
assert_equal "html", doc.root.children[2].name
end
-
+
def test_find_img
doc = HTML::Document.new <<-HTML.strip
<html>
diff --git a/actionpack/test/template/html-scanner/node_test.rb b/actionpack/test/template/html-scanner/node_test.rb
index b0df36877e..f4b9b198e8 100644
--- a/actionpack/test/template/html-scanner/node_test.rb
+++ b/actionpack/test/template/html-scanner/node_test.rb
@@ -1,39 +1,39 @@
require 'abstract_unit'
class NodeTest < Test::Unit::TestCase
-
+
class MockNode
def initialize(matched, value)
@matched = matched
@value = value
end
-
+
def find(conditions)
@matched && self
end
-
+
def to_s
@value.to_s
end
end
-
+
def setup
@node = HTML::Node.new("parent")
@node.children.concat [MockNode.new(false,1), MockNode.new(true,"two"), MockNode.new(false,:three)]
end
-
+
def test_match
assert !@node.match("foo")
end
-
+
def test_tag
assert !@node.tag?
end
-
+
def test_to_s
assert_equal "1twothree", @node.to_s
end
-
+
def test_find
assert_equal "two", @node.find('blah').to_s
end
@@ -58,7 +58,7 @@ class NodeTest < Test::Unit::TestCase
assert node.attributes.has_key?("bar")
assert "<b foo bar>", node.to_s
end
-
+
def test_parse_with_unclosed_tag
s = "<span onmouseover='bang'"
node = nil
diff --git a/actionpack/test/template/html-scanner/sanitizer_test.rb b/actionpack/test/template/html-scanner/sanitizer_test.rb
index c9edde8892..3e80317b30 100644
--- a/actionpack/test/template/html-scanner/sanitizer_test.rb
+++ b/actionpack/test/template/html-scanner/sanitizer_test.rb
@@ -24,11 +24,11 @@ class SanitizerTest < ActionController::TestCase
def test_strip_links
sanitizer = HTML::LinkSanitizer.new
- assert_equal "Dont touch me", sanitizer.sanitize("Dont touch me")
+ assert_equal "Dont touch me", sanitizer.sanitize("Dont touch me")
assert_equal "on my mind\nall day long", sanitizer.sanitize("<a href='almost'>on my mind</a>\n<A href='almost'>all day long</A>")
- assert_equal "0wn3d", sanitizer.sanitize("<a href='http://www.rubyonrails.com/'><a href='http://www.rubyonrails.com/' onlclick='steal()'>0wn3d</a></a>")
- assert_equal "Magic", sanitizer.sanitize("<a href='http://www.rubyonrails.com/'>Mag<a href='http://www.ruby-lang.org/'>ic")
- assert_equal "FrrFox", sanitizer.sanitize("<href onlclick='steal()'>FrrFox</a></href>")
+ assert_equal "0wn3d", sanitizer.sanitize("<a href='http://www.rubyonrails.com/'><a href='http://www.rubyonrails.com/' onlclick='steal()'>0wn3d</a></a>")
+ assert_equal "Magic", sanitizer.sanitize("<a href='http://www.rubyonrails.com/'>Mag<a href='http://www.ruby-lang.org/'>ic")
+ assert_equal "FrrFox", sanitizer.sanitize("<href onlclick='steal()'>FrrFox</a></href>")
assert_equal "My mind\nall <b>day</b> long", sanitizer.sanitize("<a href='almost'>My mind</a>\n<A href='almost'>all <b>day</b> long</A>")
assert_equal "all <b>day</b> long", sanitizer.sanitize("<<a>a href='hello'>all <b>day</b> long<</A>/a>")
@@ -58,7 +58,7 @@ class SanitizerTest < ActionController::TestCase
raw = %{href="javascript:bang" <a href="javascript:bang" name="hello">foo</a>, <span href="javascript:bang">bar</span>}
assert_sanitized raw, %{href="javascript:bang" <a name="hello">foo</a>, <span>bar</span>}
end
-
+
def test_sanitize_image_src
raw = %{src="javascript:bang" <img src="javascript:bang" width="5">foo</img>, <span src="javascript:bang">bar</span>}
assert_sanitized raw, %{src="javascript:bang" <img width="5">foo</img>, <span>bar</span>}
@@ -147,9 +147,9 @@ class SanitizerTest < ActionController::TestCase
assert_sanitized %(<SCRIPT\nSRC=http://ha.ckers.org/xss.js></SCRIPT>), ""
end
- [%(<IMG SRC="javascript:alert('XSS');">),
- %(<IMG SRC=javascript:alert('XSS')>),
- %(<IMG SRC=JaVaScRiPt:alert('XSS')>),
+ [%(<IMG SRC="javascript:alert('XSS');">),
+ %(<IMG SRC=javascript:alert('XSS')>),
+ %(<IMG SRC=JaVaScRiPt:alert('XSS')>),
%(<IMG """><SCRIPT>alert("XSS")</SCRIPT>">),
%(<IMG SRC=javascript:alert(&quot;XSS&quot;)>),
%(<IMG SRC=javascript:alert(String.fromCharCode(88,83,83))>),
@@ -166,28 +166,28 @@ class SanitizerTest < ActionController::TestCase
assert_sanitized img_hack, "<img>"
end
end
-
+
def test_should_sanitize_tag_broken_up_by_null
assert_sanitized %(<SCR\0IPT>alert(\"XSS\")</SCR\0IPT>), "alert(\"XSS\")"
end
-
+
def test_should_sanitize_invalid_script_tag
assert_sanitized %(<SCRIPT/XSS SRC="http://ha.ckers.org/xss.js"></SCRIPT>), ""
end
-
+
def test_should_sanitize_script_tag_with_multiple_open_brackets
assert_sanitized %(<<SCRIPT>alert("XSS");//<</SCRIPT>), "&lt;"
assert_sanitized %(<iframe src=http://ha.ckers.org/scriptlet.html\n<a), %(&lt;a)
end
-
+
def test_should_sanitize_unclosed_script
assert_sanitized %(<SCRIPT SRC=http://ha.ckers.org/xss.js?<B>), "<b>"
end
-
+
def test_should_sanitize_half_open_scripts
assert_sanitized %(<IMG SRC="javascript:alert('XSS')"), "<img>"
end
-
+
def test_should_not_fall_for_ridiculous_hack
img_hack = %(<IMG\nSRC\n=\n"\nj\na\nv\na\ns\nc\nr\ni\np\nt\n:\na\nl\ne\nr\nt\n(\n'\nX\nS\nS\n'\n)\n"\n>)
assert_sanitized img_hack, "<img>"
@@ -214,15 +214,15 @@ class SanitizerTest < ActionController::TestCase
raw = %(-moz-binding:url('http://ha.ckers.org/xssmoz.xml#xss'))
assert_equal '', sanitize_css(raw)
end
-
+
def test_should_sanitize_invalid_tag_names
assert_sanitized(%(a b c<script/XSS src="http://ha.ckers.org/xss.js"></script>d e f), "a b cd e f")
end
-
+
def test_should_sanitize_non_alpha_and_non_digit_characters_in_tags
assert_sanitized('<a onclick!#$%&()*~+-_.,:;?@[/|\]^`=alert("XSS")>foo</a>', "<a>foo</a>")
end
-
+
def test_should_sanitize_invalid_tag_names_in_single_tags
assert_sanitized('<img/src="http://ha.ckers.org/xss.js"/>', "<img />")
end
diff --git a/actionpack/test/template/html-scanner/tag_node_test.rb b/actionpack/test/template/html-scanner/tag_node_test.rb
index d1d4667378..9c8fcdc8fc 100644
--- a/actionpack/test/template/html-scanner/tag_node_test.rb
+++ b/actionpack/test/template/html-scanner/tag_node_test.rb
@@ -7,7 +7,7 @@ class TagNodeTest < Test::Unit::TestCase
assert_equal Hash.new, node.attributes
assert_nil node.closing
end
-
+
def test_open_with_attributes
node = tag("<TAG1 foo=hey_ho x:bar=\"blah blah\" BAZ='blah blah blah' >")
assert_equal "tag1", node.name
@@ -15,28 +15,28 @@ class TagNodeTest < Test::Unit::TestCase
assert_equal "blah blah", node["x:bar"]
assert_equal "blah blah blah", node["baz"]
end
-
+
def test_self_closing_without_attributes
node = tag("<tag/>")
assert_equal "tag", node.name
assert_equal Hash.new, node.attributes
assert_equal :self, node.closing
end
-
+
def test_self_closing_with_attributes
node = tag("<tag a=b/>")
assert_equal "tag", node.name
assert_equal( { "a" => "b" }, node.attributes )
assert_equal :self, node.closing
end
-
+
def test_closing_without_attributes
node = tag("</tag>")
assert_equal "tag", node.name
assert_nil node.attributes
assert_equal :close, node.closing
end
-
+
def test_bracket_op_when_no_attributes
node = tag("</tag>")
assert_nil node["foo"]
@@ -46,27 +46,27 @@ class TagNodeTest < Test::Unit::TestCase
node = tag("<tag a=b/>")
assert_equal "b", node["a"]
end
-
+
def test_attributes_with_escaped_quotes
node = tag("<tag a='b\\'c' b=\"bob \\\"float\\\"\">")
assert_equal "b\\'c", node["a"]
assert_equal "bob \\\"float\\\"", node["b"]
end
-
+
def test_to_s
node = tag("<a b=c d='f' g=\"h 'i'\" />")
assert_equal %(<a b='c' d='f' g='h \\'i\\'' />), node.to_s
end
-
+
def test_tag
assert tag("<tag>").tag?
end
-
+
def test_match_tag_as_string
assert tag("<tag>").match(:tag => "tag")
assert !tag("<tag>").match(:tag => "b")
end
-
+
def test_match_tag_as_regexp
assert tag("<tag>").match(:tag => /t.g/)
assert !tag("<tag>").match(:tag => /t[bqs]g/)
@@ -77,45 +77,45 @@ class TagNodeTest < Test::Unit::TestCase
assert t.match(:attributes => {"a" => "something"})
assert t.match(:attributes => {"b" => "else"})
end
-
+
def test_match_attributes_as_regexp
t = tag("<tag a=something b=else />")
assert t.match(:attributes => {"a" => /^something$/})
assert t.match(:attributes => {"b" => /e.*e/})
assert t.match(:attributes => {"a" => /me..i/, "b" => /.ls.$/})
end
-
+
def test_match_attributes_as_number
t = tag("<tag a=15 b=3.1415 />")
assert t.match(:attributes => {"a" => 15})
assert t.match(:attributes => {"b" => 3.1415})
assert t.match(:attributes => {"a" => 15, "b" => 3.1415})
end
-
+
def test_match_attributes_exist
t = tag("<tag a=15 b=3.1415 />")
assert t.match(:attributes => {"a" => true})
assert t.match(:attributes => {"b" => true})
assert t.match(:attributes => {"a" => true, "b" => true})
end
-
+
def test_match_attributes_not_exist
t = tag("<tag a=15 b=3.1415 />")
assert t.match(:attributes => {"c" => false})
assert t.match(:attributes => {"c" => nil})
assert t.match(:attributes => {"a" => true, "c" => false})
end
-
+
def test_match_parent_success
t = tag("<tag a=15 b='hello'>", tag("<foo k='value'>"))
assert t.match(:parent => {:tag => "foo", :attributes => {"k" => /v.l/, "j" => false}})
end
-
+
def test_match_parent_fail
t = tag("<tag a=15 b='hello'>", tag("<foo k='value'>"))
assert !t.match(:parent => {:tag => /kafka/})
end
-
+
def test_match_child_success
t = tag("<tag x:k='something'>")
tag("<child v=john a=kelly>", t)
@@ -123,7 +123,7 @@ class TagNodeTest < Test::Unit::TestCase
assert t.match(:child => { :tag => "sib", :attributes => {"v" => /j/}})
assert t.match(:child => { :attributes => {"a" => "kelly"}})
end
-
+
def test_match_child_fail
t = tag("<tag x:k='something'>")
tag("<child v=john a=kelly>", t)
@@ -131,13 +131,13 @@ class TagNodeTest < Test::Unit::TestCase
assert !t.match(:child => { :tag => "sib", :attributes => {"v" => /r/}})
assert !t.match(:child => { :attributes => {"v" => false}})
end
-
+
def test_match_ancestor_success
t = tag("<tag x:k='something'>", tag("<parent v=john a=kelly>", tag("<grandparent m=vaughn v=james>")))
assert t.match(:ancestor => {:tag => "parent", :attributes => {"a" => /ll/}})
assert t.match(:ancestor => {:attributes => {"m" => "vaughn"}})
end
-
+
def test_match_ancestor_fail
t = tag("<tag x:k='something'>", tag("<parent v=john a=kelly>", tag("<grandparent m=vaughn v=james>")))
assert !t.match(:ancestor => {:tag => /^parent/, :attributes => {"v" => /m/}})
@@ -149,13 +149,13 @@ class TagNodeTest < Test::Unit::TestCase
assert t.match(:descendant => {:tag => "child", :attributes => {"a" => /ll/}})
assert t.match(:descendant => {:attributes => {"m" => "vaughn"}})
end
-
+
def test_match_descendant_fail
tag("<grandchild m=vaughn v=james>", tag("<child v=john a=kelly>", t = tag("<tag x:k='something'>")))
assert !t.match(:descendant => {:tag => /^child/, :attributes => {"v" => /m/}})
assert !t.match(:descendant => {:attributes => {"v" => false}})
end
-
+
def test_match_child_count
t = tag("<tag x:k='something'>")
tag("hello", t)
@@ -229,7 +229,7 @@ class TagNodeTest < Test::Unit::TestCase
end
private
-
+
def tag(content, parent=nil)
node = HTML::Node.parse(parent,0,0,content)
parent.children << node if parent
diff --git a/actionpack/test/template/html-scanner/text_node_test.rb b/actionpack/test/template/html-scanner/text_node_test.rb
index 1ab3f4454e..6f61253ffa 100644
--- a/actionpack/test/template/html-scanner/text_node_test.rb
+++ b/actionpack/test/template/html-scanner/text_node_test.rb
@@ -4,27 +4,27 @@ class TextNodeTest < Test::Unit::TestCase
def setup
@node = HTML::Text.new(nil, 0, 0, "hello, howdy, aloha, annyeong")
end
-
+
def test_to_s
assert_equal "hello, howdy, aloha, annyeong", @node.to_s
end
-
+
def test_find_string
assert_equal @node, @node.find("hello, howdy, aloha, annyeong")
assert_equal false, @node.find("bogus")
end
-
+
def test_find_regexp
assert_equal @node, @node.find(/an+y/)
assert_nil @node.find(/b/)
end
-
+
def test_find_hash
assert_equal @node, @node.find(:content => /howdy/)
assert_nil @node.find(:content => /^howdy$/)
assert_equal false, @node.find(:content => "howdy")
end
-
+
def test_find_other
assert_nil @node.find(:hello)
end
diff --git a/actionpack/test/template/html-scanner/tokenizer_test.rb b/actionpack/test/template/html-scanner/tokenizer_test.rb
index a001bcbbad..bf45a7c2e3 100644
--- a/actionpack/test/template/html-scanner/tokenizer_test.rb
+++ b/actionpack/test/template/html-scanner/tokenizer_test.rb
@@ -29,7 +29,7 @@ class TokenizerTest < Test::Unit::TestCase
tokenize "</tag>"
assert_next "</tag>"
end
-
+
def test_tag_with_single_quoted_attribute
tokenize %{<tag a='hello'>x}
assert_next %{<tag a='hello'>}
@@ -49,7 +49,7 @@ class TokenizerTest < Test::Unit::TestCase
tokenize %{<tag a="hello\\"">x}
assert_next %{<tag a="hello\\"">}
end
-
+
def test_tag_with_unquoted_attribute
tokenize %{<tag a=hello>x}
assert_next %{<tag a=hello>}
@@ -59,12 +59,12 @@ class TokenizerTest < Test::Unit::TestCase
tokenize %{<tag a="x < y">x}
assert_next %{<tag a="x < y">}
end
-
+
def test_tag_with_gt_char_in_attribute
tokenize %{<tag a="x > y">x}
assert_next %{<tag a="x > y">}
end
-
+
def test_doctype_tag
tokenize %{<!DOCTYPE "blah" "blah" "blah">\n <html>}
assert_next %{<!DOCTYPE "blah" "blah" "blah">}
@@ -90,7 +90,7 @@ class TokenizerTest < Test::Unit::TestCase
assert_next %{original }
assert_next %{< hello > world}
end
-
+
def test_less_than_without_matching_greater_than
tokenize %{hello <span onmouseover="gotcha"\n<b>foo</b>\nbar</span>}
assert_next %{hello }
@@ -109,22 +109,22 @@ class TokenizerTest < Test::Unit::TestCase
assert_next %{<!-- neverending...}
assert_end
end
-
+
private
-
+
def tokenize(text)
@tokenizer = HTML::Tokenizer.new(text)
end
-
+
def assert_next(expected, message=nil)
token = @tokenizer.next
assert_equal expected, token, message
end
-
+
def assert_sequence(*expected)
assert_next expected.shift until expected.empty?
end
-
+
def assert_end(message=nil)
assert_nil @tokenizer.next, message
end
diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb
index 7f787b7b00..d27cec0a29 100644
--- a/actionpack/test/template/number_helper_test.rb
+++ b/actionpack/test/template/number_helper_test.rb
@@ -116,7 +116,7 @@ class NumberHelperTest < ActionView::TestCase
assert_equal "9775.00", number_with_precision(9775, :precision => 6, :significant => true )
assert_equal "5.392900", number_with_precision(5.3929, :precision => 7, :significant => true )
assert_equal "0.0", number_with_precision(0, :precision => 2, :significant => true )
- assert_equal "0", number_with_precision(0, :precision => 1, :significant => true )
+ assert_equal "0", number_with_precision(0, :precision => 1, :significant => true )
assert_equal "0.0001", number_with_precision(0.0001, :precision => 1, :significant => true )
assert_equal "0.000100", number_with_precision(0.0001, :precision => 3, :significant => true )
assert_equal "0.0001", number_with_precision(0.0001111, :precision => 1, :significant => true )
diff --git a/actionpack/test/template/tag_helper_test.rb b/actionpack/test/template/tag_helper_test.rb
index 507cdca8d0..85ac515660 100644
--- a/actionpack/test/template/tag_helper_test.rb
+++ b/actionpack/test/template/tag_helper_test.rb
@@ -90,17 +90,17 @@ class TagHelperTest < ActionView::TestCase
def test_cdata_section
assert_equal "<![CDATA[<hello world>]]>", cdata_section("<hello world>")
end
-
+
def test_escape_once
assert_equal '1 &lt; 2 &amp; 3', escape_once('1 < 2 &amp; 3')
end
-
+
def test_tag_honors_html_safe_for_param_values
['1&amp;2', '1 &lt; 2', '&#8220;test&#8220;'].each do |escaped|
assert_equal %(<a href="#{escaped}" />), tag('a', :href => escaped.html_safe)
end
end
-
+
def test_skip_invalid_escaped_attributes
['&1;', '&#1dfa3;', '& #123;'].each do |escaped|
assert_equal %(<a href="#{escaped.gsub /&/, '&amp;'}" />), tag('a', :href => escaped)
diff --git a/actionpack/test/template/text_helper_test.rb b/actionpack/test/template/text_helper_test.rb
index d22b9fe406..88ec6fc740 100644
--- a/actionpack/test/template/text_helper_test.rb
+++ b/actionpack/test/template/text_helper_test.rb
@@ -99,7 +99,7 @@ class TextHelperTest < ActionView::TestCase
def test_highlight_should_be_html_safe
assert highlight("This is a beautiful morning", "beautiful").html_safe?
end
-
+
def test_highlight
assert_equal(
"This is a <strong class=\"highlight\">beautiful</strong> morning",
@@ -430,7 +430,7 @@ class TextHelperTest < ActionView::TestCase
def test_auto_link_other_protocols
ftp_raw = 'ftp://example.com/file.txt'
assert_equal %(Download #{generate_result(ftp_raw)}), auto_link("Download #{ftp_raw}")
-
+
file_scheme = 'file:///home/username/RomeoAndJuliet.pdf'
z39_scheme = 'z39.50r://host:696/db'
chrome_scheme = 'chrome://package/section/path'
@@ -452,7 +452,7 @@ class TextHelperTest < ActionView::TestCase
assert_equal linked3, auto_link(linked3)
assert_equal linked4, auto_link(linked4)
assert_equal linked5, auto_link(linked5)
-
+
linked_email = %Q(<a href="mailto:david@loudthinking.com">Mail me</a>)
assert_equal linked_email, auto_link(linked_email)
end
@@ -493,11 +493,11 @@ class TextHelperTest < ActionView::TestCase
assert_equal %(<p><a href="#{url}">#{url[0...7]}...</a><br /><a href="mailto:#{email}">#{email[0...7]}...</a><br /></p>), auto_link("<p>#{url}<br />#{email}<br /></p>") { |url| truncate(url, :length => 10) }
end
-
+
def test_auto_link_with_block_with_html
pic = "http://example.com/pic.png"
url = "http://example.com/album?a&b=c"
-
+
assert_equal %(My pic: <a href="#{pic}"><img src="#{pic}" width="160px"></a> -- full album here #{generate_result(url)}), auto_link("My pic: #{pic} -- full album here #{url}") { |link|
if link =~ /\.(jpg|gif|png|bmp|tif)$/i
raw %(<img src="#{link}" width="160px">)
@@ -512,7 +512,7 @@ class TextHelperTest < ActionView::TestCase
auto_link("Welcome to my new blog at http://www.myblog.com/. Please e-mail me at me@email.com.",
:link => :all, :html => { :class => "menu", :target => "_blank" })
end
-
+
def test_auto_link_with_multiple_trailing_punctuations
url = "http://youtube.com"
url_result = generate_result(url)
diff --git a/actionpack/test/template/translation_helper_test.rb b/actionpack/test/template/translation_helper_test.rb
index 1be418a206..952719a589 100644
--- a/actionpack/test/template/translation_helper_test.rb
+++ b/actionpack/test/template/translation_helper_test.rb
@@ -7,12 +7,12 @@ class TranslationHelperTest < ActiveSupport::TestCase
attr_reader :request
def setup
end
-
+
def test_delegates_to_i18n_setting_the_raise_option
I18n.expects(:translate).with(:foo, :locale => 'en', :raise => true).returns("")
translate :foo, :locale => 'en'
end
-
+
def test_returns_missing_translation_message_wrapped_into_span
expected = '<span class="translation_missing">en, foo</span>'
assert_equal expected, translate(:foo)
@@ -28,7 +28,7 @@ class TranslationHelperTest < ActiveSupport::TestCase
I18n.expects(:localize).with(@time)
localize @time
end
-
+
def test_scoping_by_partial
I18n.expects(:translate).with("test.translation.helper", :raise => true).returns("helper")
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
@@ -40,7 +40,7 @@ class TranslationHelperTest < ActiveSupport::TestCase
@view = ActionView::Base.new(ActionController::Base.view_paths, {})
assert_equal "foobar", @view.render(:file => "test/scoped_translation")
end
-
+
def test_translate_does_not_mark_plain_text_as_safe_html
I18n.expects(:translate).with("hello", :raise => true).returns("Hello World")
assert_equal false, translate("hello").html_safe?
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index d59bbec4a9..19effbc82f 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -654,10 +654,10 @@ class PolymorphicControllerTest < ActionController::TestCase
get :index, :workshop_id => 1
assert_equal "/workshops/1/sessions\n<a href=\"/workshops/1/sessions\">Session</a>", @response.body
end
-
+
def test_existing_nested_resource
@controller = SessionsController.new
-
+
get :show, :workshop_id => 1, :id => 1
assert_equal "/workshops/1/sessions/1\n<a href=\"/workshops/1/sessions/1\">Session</a>", @response.body
end
diff --git a/activemodel/CHANGELOG b/activemodel/CHANGELOG
index 8374853231..3ad8ac75aa 100644
--- a/activemodel/CHANGELOG
+++ b/activemodel/CHANGELOG
@@ -16,7 +16,7 @@
*Rails 3.0.0 [beta 2] (April 1st, 2010)*
* #new_record? and #destroyed? were removed from ActiveModel::Lint. Use
- persisted? instead. A model is persisted if it's not a new_record? and it was
+ persisted? instead. A model is persisted if it's not a new_record? and it was
not destroyed? [MG]
* Added validations reflection in ActiveModel::Validations [JV]
diff --git a/activemodel/README.rdoc b/activemodel/README.rdoc
index 73c58a87db..9b96bfaba7 100644
--- a/activemodel/README.rdoc
+++ b/activemodel/README.rdoc
@@ -18,38 +18,38 @@ modules:
class Person
include ActiveModel::AttributeMethods
-
+
attribute_method_prefix 'clear_'
define_attribute_methods [:name, :age]
-
+
attr_accessor :name, :age
-
+
def clear_attribute(attr)
send("#{attr}=", nil)
end
end
-
+
person.clear_name
person.clear_age
-
+
{Learn more}[link:classes/ActiveModel/AttributeMethods.html]
-
+
* Callbacks for certain operations
class Person
extend ActiveModel::Callbacks
define_model_callbacks :create
-
+
def create
_run_create_callbacks do
# Your create action methods here
end
end
end
-
+
This generates +before_create+, +around_create+ and +after_create+
class methods that wrap your create method.
-
+
{Learn more}[link:classes/ActiveModel/CallBacks.html]
* Tracking value changes
@@ -66,36 +66,36 @@ modules:
person.name = 'robert'
person.save
person.previous_changes # => {'name' => ['bob, 'robert']}
-
+
{Learn more}[link:classes/ActiveModel/Dirty.html]
* Adding +errors+ interface to objects
Exposing error messages allows objects to interact with Action Pack
helpers seamlessly.
-
+
class Person
-
+
def initialize
@errors = ActiveModel::Errors.new(self)
end
-
+
attr_accessor :name
attr_reader :errors
-
+
def validate!
errors.add(:name, "can not be nil") if name == nil
end
-
+
def ErrorsPerson.human_attribute_name(attr, options = {})
"Name"
end
-
+
end
-
+
person.errors.full_messages
# => ["Name Can not be nil"]
-
+
person.errors.full_messages
# => ["Name Can not be nil"]
@@ -106,7 +106,7 @@ modules:
class NamedPerson
extend ActiveModel::Naming
end
-
+
NamedPerson.model_name # => "NamedPerson"
NamedPerson.model_name.human # => "Named person"
@@ -117,19 +117,19 @@ modules:
ActiveModel::Observers allows your object to implement the Observer
pattern in a Rails App and take advantage of all the standard observer
functions.
-
+
{Learn more}[link:classes/ActiveModel/Observer.html]
* Making objects serializable
ActiveModel::Serialization provides a standard interface for your object
to provide +to_json+ or +to_xml+ serialization.
-
+
s = SerialPerson.new
s.serializable_hash # => {"name"=>nil}
s.to_json # => "{\"name\":null}"
s.to_xml # => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<serial-person...
-
+
{Learn more}[link:classes/ActiveModel/Serialization.html]
* Internationalization (i18n) support
@@ -137,10 +137,10 @@ modules:
class Person
extend ActiveModel::Translation
end
-
+
Person.human_attribute_name('my_attribute')
# => "My attribute"
-
+
{Learn more}[link:classes/ActiveModel/Translation.html]
* Validation support
@@ -160,7 +160,7 @@ modules:
person.valid? # => false
{Learn more}[link:classes/ActiveModel/Validations.html]
-
+
* Custom validators
class Person
@@ -168,13 +168,13 @@ modules:
validates_with HasNameValidator
attr_accessor :name
end
-
+
class HasNameValidator < ActiveModel::Validator
def validate(record)
record.errors[:name] = "must exist" if record.name.blank?
end
end
-
+
p = ValidatorPerson.new
p.valid? # => false
p.errors.full_messages # => ["Name must exist"]
diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb
index a43436e008..b8126fb67e 100644
--- a/activemodel/lib/active_model/attribute_methods.rb
+++ b/activemodel/lib/active_model/attribute_methods.rb
@@ -9,46 +9,46 @@ module ActiveModel
# <tt>ActiveModel::AttributeMethods</tt> provides a way to add prefixes and suffixes
# to your methods as well as handling the creation of Active Record like class methods
# such as +table_name+.
- #
+ #
# The requirements to implement ActiveModel::AttributeMethods are to:
#
# * <tt>include ActiveModel::AttributeMethods</tt> in your object
- # * Call each Attribute Method module method you want to add, such as
+ # * Call each Attribute Method module method you want to add, such as
# attribute_method_suffix or attribute_method_prefix
# * Call <tt>define_attribute_methods</tt> after the other methods are
# called.
# * Define the various generic +_attribute+ methods that you have declared
- #
+ #
# A minimal implementation could be:
- #
+ #
# class Person
# include ActiveModel::AttributeMethods
- #
+ #
# attribute_method_affix :prefix => 'reset_', :suffix => '_to_default!'
# attribute_method_suffix '_contrived?'
# attribute_method_prefix 'clear_'
# define_attribute_methods ['name']
- #
+ #
# attr_accessor :name
- #
+ #
# private
- #
+ #
# def attribute_contrived?(attr)
# true
# end
- #
+ #
# def clear_attribute(attr)
# send("#{attr}=", nil)
# end
- #
+ #
# def reset_attribute_to_default!(attr)
# send("#{attr}=", "Default Name")
# end
# end
#
# Notice that whenever you include ActiveModel::AttributeMethods in your class,
- # it requires you to implement a <tt>attributes</tt> methods which returns a hash
- # with each attribute name in your model as hash key and the attribute value as
+ # it requires you to implement a <tt>attributes</tt> methods which returns a hash
+ # with each attribute name in your model as hash key and the attribute value as
# hash value.
#
# Hash keys must be strings.
@@ -57,34 +57,34 @@ module ActiveModel
extend ActiveSupport::Concern
module ClassMethods
- # Defines an "attribute" method (like +inheritance_column+ or +table_name+).
- # A new (class) method will be created with the given name. If a value is
- # specified, the new method will return that value (as a string).
- # Otherwise, the given block will be used to compute the value of the
+ # Defines an "attribute" method (like +inheritance_column+ or +table_name+).
+ # A new (class) method will be created with the given name. If a value is
+ # specified, the new method will return that value (as a string).
+ # Otherwise, the given block will be used to compute the value of the
# method.
#
# The original method will be aliased, with the new name being prefixed
- # with "original_". This allows the new method to access the original
+ # with "original_". This allows the new method to access the original
# value.
#
# Example:
#
# class Person
- #
+ #
# include ActiveModel::AttributeMethods
- #
+ #
# cattr_accessor :primary_key
# cattr_accessor :inheritance_column
- #
+ #
# define_attr_method :primary_key, "sysid"
# define_attr_method( :inheritance_column ) do
# original_inheritance_column + "_id"
# end
- #
+ #
# end
- #
+ #
# Provides you with:
- #
+ #
# AttributePerson.primary_key
# # => "sysid"
# AttributePerson.inheritance_column = 'address'
@@ -118,20 +118,20 @@ module ActiveModel
#
# #{prefix}attribute(#{attr}, *args, &block)
#
- # An instance method <tt>#{prefix}attribute</tt> must exist and accept
+ # An instance method <tt>#{prefix}attribute</tt> must exist and accept
# at least the +attr+ argument.
#
# For example:
#
# class Person
- #
+ #
# include ActiveModel::AttributeMethods
# attr_accessor :name
# attribute_method_prefix 'clear_'
# define_attribute_methods [:name]
#
# private
- #
+ #
# def clear_attribute(attr)
# send("#{attr}=", nil)
# end
@@ -162,14 +162,14 @@ module ActiveModel
# For example:
#
# class Person
- #
+ #
# include ActiveModel::AttributeMethods
# attr_accessor :name
# attribute_method_suffix '_short?'
# define_attribute_methods [:name]
#
# private
- #
+ #
# def attribute_short?(attr)
# send(attr).length < 5
# end
@@ -200,14 +200,14 @@ module ActiveModel
# For example:
#
# class Person
- #
+ #
# include ActiveModel::AttributeMethods
# attr_accessor :name
# attribute_method_affix :prefix => 'reset_', :suffix => '_to_default!'
# define_attribute_methods [:name]
#
# private
- #
+ #
# def reset_attribute_to_default!(attr)
# ...
# end
@@ -232,15 +232,15 @@ module ActiveModel
end
end
- # Declares a the attributes that should be prefixed and suffixed by
+ # Declares a the attributes that should be prefixed and suffixed by
# ActiveModel::AttributeMethods.
- #
+ #
# To use, pass in an array of attribute names (as strings or symbols),
# be sure to declare +define_attribute_methods+ after you define any
# prefix, suffix or affix methods, or they will not hook in.
- #
+ #
# class Person
- #
+ #
# include ActiveModel::AttributeMethods
# attr_accessor :name, :age, :address
# attribute_method_prefix 'clear_'
@@ -251,7 +251,7 @@ module ActiveModel
# define_attribute_methods [:name, :age, :address]
#
# private
- #
+ #
# def clear_attribute(attr)
# ...
# end
@@ -344,16 +344,16 @@ module ActiveModel
end
end
- # Allows access to the object attributes, which are held in the
- # <tt>@attributes</tt> hash, as though they were first-class methods. So a
- # Person class with a name attribute can use Person#name and Person#name=
+ # Allows access to the object attributes, which are held in the
+ # <tt>@attributes</tt> hash, as though they were first-class methods. So a
+ # Person class with a name attribute can use Person#name and Person#name=
# and never directly use the attributes hash -- except for multiple assigns
- # with ActiveRecord#attributes=. A Milestone class can also ask
- # Milestone#completed? to test that the completed attribute is not +nil+
+ # with ActiveRecord#attributes=. A Milestone class can also ask
+ # Milestone#completed? to test that the completed attribute is not +nil+
# or 0.
#
- # It's also possible to instantiate related objects, so a Client class
- # belonging to the clients table with a +master_id+ foreign key can
+ # It's also possible to instantiate related objects, so a Client class
+ # belonging to the clients table with a +master_id+ foreign key can
# instantiate master through Client#master.
def method_missing(method_id, *args, &block)
method_name = method_id.to_s
diff --git a/activemodel/lib/active_model/callbacks.rb b/activemodel/lib/active_model/callbacks.rb
index b150fc60f7..aaa41f5ec6 100644
--- a/activemodel/lib/active_model/callbacks.rb
+++ b/activemodel/lib/active_model/callbacks.rb
@@ -3,49 +3,49 @@ require 'active_support/callbacks'
module ActiveModel
# == Active Model Callbacks
- #
+ #
# Provides an interface for any class to have Active Record like callbacks.
- #
+ #
# Like the Active Record methods, the callback chain is aborted as soon as
# one of the methods in the chain returns false.
#
# First, extend ActiveModel::Callbacks from the class you are creating:
- #
+ #
# class MyModel
# extend ActiveModel::Callbacks
# end
- #
+ #
# Then define a list of methods that you want callbacks attached to:
- #
+ #
# define_model_callbacks :create, :update
- #
+ #
# This will provide all three standard callbacks (before, around and after) for
- # both the :create and :update methods. To implement, you need to wrap the methods
+ # both the :create and :update methods. To implement, you need to wrap the methods
# you want callbacks on in a block so that the callbacks get a chance to fire:
- #
+ #
# def create
# _run_create_callbacks do
# # Your create action methods here
# end
# end
- #
+ #
# The _run_<method_name>_callbacks methods are dynamically created when you extend
# the <tt>ActiveModel::Callbacks</tt> module.
- #
+ #
# Then in your class, you can use the +before_create+, +after_create+ and +around_create+
# methods, just as you would in an Active Record module.
- #
+ #
# before_create :action_before_create
- #
+ #
# def action_before_create
# # Your code here
# end
- #
- # You can choose not to have all three callbacks by passing a hash to the
+ #
+ # You can choose not to have all three callbacks by passing a hash to the
# define_model_callbacks method.
- #
+ #
# define_model_callbacks :create, :only => :after, :before
- #
+ #
# Would only create the after_create and before_create callback methods in your
# class.
module Callbacks
@@ -56,44 +56,44 @@ module ActiveModel
end
# define_model_callbacks accepts the same options define_callbacks does, in case
- # you want to overwrite a default. Besides that, it also accepts an :only option,
+ # you want to overwrite a default. Besides that, it also accepts an :only option,
# where you can choose if you want all types (before, around or after) or just some.
#
# define_model_callbacks :initializer, :only => :after
- #
+ #
# Note, the <tt>:only => <type></tt> hash will apply to all callbacks defined on
# that method call. To get around this you can call the define_model_callbacks
# method as many times as you need.
- #
+ #
# define_model_callbacks :create, :only => :after
# define_model_callbacks :update, :only => :before
# define_model_callbacks :destroy, :only => :around
- #
+ #
# Would create +after_create+, +before_update+ and +around_destroy+ methods only.
- #
+ #
# You can pass in a class to before_<type>, after_<type> and around_<type>, in which
# case the callback will call that class's <action>_<type> method passing the object
# that the callback is being called on.
- #
+ #
# class MyModel
# extend ActiveModel::Callbacks
# define_model_callbacks :create
- #
+ #
# before_create AnotherClass
# end
- #
+ #
# class AnotherClass
# def self.before_create( obj )
# # obj is the MyModel instance that the callback is being called on
# end
# end
- #
+ #
def define_model_callbacks(*callbacks)
options = callbacks.extract_options!
- options = {
- :terminator => "result == false",
- :scope => [:kind, :name],
- :only => [:before, :around, :after]
+ options = {
+ :terminator => "result == false",
+ :scope => [:kind, :name],
+ :only => [:before, :around, :after]
}.merge(options)
types = Array.wrap(options.delete(:only))
diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb
index d2bd160dc7..b998a59e81 100644
--- a/activemodel/lib/active_model/conversion.rb
+++ b/activemodel/lib/active_model/conversion.rb
@@ -22,18 +22,18 @@ module ActiveModel
# cm.to_param # => nil
#
module Conversion
- # If your object is already designed to implement all of the Active Model
- # you can use the default to_model implementation, which simply returns
+ # If your object is already designed to implement all of the Active Model
+ # you can use the default to_model implementation, which simply returns
# self.
- #
- # If your model does not act like an Active Model object, then you should
- # define <tt>:to_model</tt> yourself returning a proxy object that wraps
+ #
+ # If your model does not act like an Active Model object, then you should
+ # define <tt>:to_model</tt> yourself returning a proxy object that wraps
# your object with Active Model compliant methods.
def to_model
self
end
- # Returns an Enumerable of all (primary) key attributes or nil if
+ # Returns an Enumerable of all (primary) key attributes or nil if
# persisted? is false
def to_key
persisted? ? [id] : nil
diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb
index 2516377afd..1361d327b3 100644
--- a/activemodel/lib/active_model/dirty.rb
+++ b/activemodel/lib/active_model/dirty.rb
@@ -6,48 +6,48 @@ require 'active_support/core_ext/object/duplicable'
module ActiveModel
# == Active Model Dirty
#
- # Provides a way to track changes in your object in the same way as
+ # Provides a way to track changes in your object in the same way as
# Active Record does.
- #
+ #
# The requirements to implement ActiveModel::Dirty are to:
#
# * <tt>include ActiveModel::Dirty</tt> in your object
- # * Call <tt>define_attribute_methods</tt> passing each method you want to
+ # * Call <tt>define_attribute_methods</tt> passing each method you want to
# track
- # * Call <tt>attr_name_will_change!</tt> before each change to the tracked
+ # * Call <tt>attr_name_will_change!</tt> before each change to the tracked
# attribute
- #
- # If you wish to also track previous changes on save or update, you need to
+ #
+ # If you wish to also track previous changes on save or update, you need to
# add
- #
+ #
# @previously_changed = changes
- #
+ #
# inside of your save or update method.
- #
+ #
# A minimal implementation could be:
- #
+ #
# class Person
- #
+ #
# include ActiveModel::Dirty
- #
+ #
# define_attribute_methods [:name]
- #
+ #
# def name
# @name
# end
- #
+ #
# def name=(val)
# name_will_change! unless val == @name
# @name = val
# end
- #
+ #
# def save
# @previously_changed = changes
# @changed_attributes.clear
# end
- #
+ #
# end
- #
+ #
# == Examples:
#
# A newly instantiated object is unchanged:
@@ -79,7 +79,7 @@ module ActiveModel
# person.changes # => { 'name' => ['Bill', 'Bob'] }
#
# If an attribute is modified in-place then make use of <tt>[attribute_name]_will_change!</tt>
- # to mark that the attribute is changing. Otherwise ActiveModel can't track changes to
+ # to mark that the attribute is changing. Otherwise ActiveModel can't track changes to
# in-place attributes.
#
# person.name_will_change!
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 272ddb1554..14312283d1 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -12,50 +12,50 @@ module ActiveModel
#
# Provides a modified +OrderedHash+ that you can include in your object
# for handling error messages and interacting with Action Pack helpers.
- #
+ #
# A minimal implementation could be:
- #
+ #
# class Person
- #
+ #
# # Required dependency for ActiveModel::Errors
# extend ActiveModel::Naming
- #
+ #
# def initialize
# @errors = ActiveModel::Errors.new(self)
# end
- #
+ #
# attr_accessor :name
# attr_reader :errors
- #
+ #
# def validate!
# errors.add(:name, "can not be nil") if name == nil
# end
- #
+ #
# # The following methods are needed to be minimally implemented
#
# def read_attribute_for_validation(attr)
# send(attr)
# end
- #
+ #
# def Person.human_attribute_name(attr, options = {})
# attr
# end
- #
+ #
# def Person.lookup_ancestors
# [self]
# end
- #
+ #
# end
- #
+ #
# The last three methods are required in your object for Errors to be
# able to generate error messages correctly and also handle multiple
# languages. Of course, if you extend your object with ActiveModel::Translations
# you will not need to implement the last two. Likewise, using
# ActiveModel::Validations will handle the validation related methods
# for you.
- #
+ #
# The above allows you to do:
- #
+ #
# p = Person.new
# p.validate! # => ["can not be nil"]
# p.errors.full_messages # => ["name can not be nil"]
@@ -66,7 +66,7 @@ module ActiveModel
CALLBACKS_OPTIONS = [:if, :unless, :on, :allow_nil, :allow_blank]
# Pass in the instance of the object that is using the errors object.
- #
+ #
# class Person
# def initialize
# @errors = ActiveModel::Errors.new(self)
@@ -80,9 +80,9 @@ module ActiveModel
alias_method :get, :[]
alias_method :set, :[]=
- # When passed a symbol or a name of a method, returns an array of errors
+ # When passed a symbol or a name of a method, returns an array of errors
# for the method.
- #
+ #
# p.errors[:name] # => ["can not be nil"]
# p.errors['name'] # => ["can not be nil"]
def [](attribute)
@@ -90,7 +90,7 @@ module ActiveModel
end
# Adds to the supplied attribute the supplied error message.
- #
+ #
# p.errors[:name] = "must be set"
# p.errors[:name] # => ['must be set']
def []=(attribute, error)
@@ -100,12 +100,12 @@ module ActiveModel
# Iterates through each error key, value pair in the error messages hash.
# Yields the attribute and the error for that attribute. If the attribute
# has more than one error message, yields once for each error message.
- #
+ #
# p.errors.add(:name, "can't be blank")
# p.errors.each do |attribute, errors_array|
# # Will yield :name and "can't be blank"
# end
- #
+ #
# p.errors.add(:name, "must be specified")
# p.errors.each do |attribute, errors_array|
# # Will yield :name and "can't be blank"
@@ -118,7 +118,7 @@ module ActiveModel
end
# Returns the number of error messages.
- #
+ #
# p.errors.add(:name, "can't be blank")
# p.errors.size # => 1
# p.errors.add(:name, "must be specified")
@@ -128,7 +128,7 @@ module ActiveModel
end
# Returns an array of error messages, with the attribute name included
- #
+ #
# p.errors.add(:name, "can't be blank")
# p.errors.add(:name, "must be specified")
# p.errors.to_a # => ["name can't be blank", "name must be specified"]
@@ -151,7 +151,7 @@ module ActiveModel
end
# Returns an xml formatted representation of the Errors hash.
- #
+ #
# p.errors.add(:name, "can't be blank")
# p.errors.add(:name, "must be specified")
# p.errors.to_xml
@@ -167,14 +167,14 @@ module ActiveModel
# Returns an ActiveSupport::OrderedHash that can be used as the JSON representation for this object.
def as_json(options=nil)
- self
+ self
end
# Adds +message+ to the error messages on +attribute+, which will be returned on a call to
# <tt>on(attribute)</tt> for the same attribute. More than one error can be added to the same
# +attribute+ in which case an array will be returned on a call to <tt>on(attribute)</tt>.
# If no +message+ is supplied, <tt>:invalid</tt> is assumed.
- #
+ #
# If +message+ is a symbol, it will be translated using the appropriate scope (see +translate_error+).
# If +message+ is a proc, it will be called, allowing for things like <tt>Time.now</tt> to be used within an error.
def add(attribute, message = nil, options = {})
@@ -253,19 +253,19 @@ module ActiveModel
full_messages
end
- # Translates an error message in its default scope
+ # Translates an error message in its default scope
# (<tt>activemodel.errors.messages</tt>).
#
- # Error messages are first looked up in <tt>models.MODEL.attributes.ATTRIBUTE.MESSAGE</tt>,
- # if it's not there, it's looked up in <tt>models.MODEL.MESSAGE</tt> and if that is not
- # there also, it returns the translation of the default message
+ # Error messages are first looked up in <tt>models.MODEL.attributes.ATTRIBUTE.MESSAGE</tt>,
+ # if it's not there, it's looked up in <tt>models.MODEL.MESSAGE</tt> and if that is not
+ # there also, it returns the translation of the default message
# (e.g. <tt>activemodel.errors.messages.MESSAGE</tt>). The translated model name,
# translated attribute name and the value are available for interpolation.
#
# When using inheritance in your models, it will check all the inherited
# models too, but only if the model itself hasn't been found. Say you have
- # <tt>class Admin < User; end</tt> and you wanted the translation for
- # the <tt>:blank</tt> error +message+ for the <tt>title</tt> +attribute+,
+ # <tt>class Admin < User; end</tt> and you wanted the translation for
+ # the <tt>:blank</tt> error +message+ for the <tt>title</tt> +attribute+,
# it looks for these translations:
#
# <ol>
diff --git a/activemodel/lib/active_model/lint.rb b/activemodel/lib/active_model/lint.rb
index fe650053d9..26eb4a3c41 100644
--- a/activemodel/lib/active_model/lint.rb
+++ b/activemodel/lib/active_model/lint.rb
@@ -79,7 +79,7 @@ module ActiveModel
end
# == Errors Testing
- #
+ #
# Returns an object that has :[] and :full_messages defined on it. See below
# for more details.
#
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb
index b74d669f0a..d79635cfb3 100644
--- a/activemodel/lib/active_model/naming.rb
+++ b/activemodel/lib/active_model/naming.rb
@@ -41,16 +41,16 @@ module ActiveModel
# == Active Model Naming
#
# Creates a +model_name+ method on your object.
- #
+ #
# To implement, just extend ActiveModel::Naming in your object:
- #
+ #
# class BookCover
# extend ActiveModel::Naming
# end
- #
+ #
# BookCover.model_name # => "BookCover"
# BookCover.model_name.human # => "Book cover"
- #
+ #
# Providing the functionality that ActiveModel::Naming provides in your object
# is required to pass the Active Model Lint test. So either extending the provided
# method below, or rolling your own is required..
@@ -90,5 +90,5 @@ module ActiveModel
(record_or_class.is_a?(Class) ? record_or_class : record_or_class.class).model_name
end
end
-
+
end
diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb
index c6a79acf81..62d2694da5 100644
--- a/activemodel/lib/active_model/observing.rb
+++ b/activemodel/lib/active_model/observing.rb
@@ -10,7 +10,7 @@ module ActiveModel
module ClassMethods
# == Active Model Observers Activation
- #
+ #
# Activates the observers assigned. Examples:
#
# # Calls PersonObserver.instance
@@ -22,7 +22,7 @@ module ActiveModel
# # Same as above, just using explicit class references
# ActiveRecord::Base.observers = Cacher, GarbageCollector
#
- # Note: Setting this does not instantiate the observers yet.
+ # Note: Setting this does not instantiate the observers yet.
# +instantiate_observers+ is called during startup, and before
# each development request.
def observers=(*values)
@@ -123,9 +123,9 @@ module ActiveModel
#
# Observers will by default be mapped to the class with which they share a
# name. So CommentObserver will be tied to observing Comment, ProductManagerObserver
- # to ProductManager, and so on. If you want to name your observer differently than
- # the class you're interested in observing, you can use the Observer.observe class
- # method which takes either the concrete class (Product) or a symbol for that
+ # to ProductManager, and so on. If you want to name your observer differently than
+ # the class you're interested in observing, you can use the Observer.observe class
+ # method which takes either the concrete class (Product) or a symbol for that
# class (:product):
#
# class AuditObserver < ActiveModel::Observer
@@ -136,7 +136,7 @@ module ActiveModel
# end
# end
#
- # If the audit observer needs to watch more than one kind of object, this can be
+ # If the audit observer needs to watch more than one kind of object, this can be
# specified with multiple arguments:
#
# class AuditObserver < ActiveModel::Observer
@@ -147,7 +147,7 @@ module ActiveModel
# end
# end
#
- # The AuditObserver will now act on both updates to Account and Balance by treating
+ # The AuditObserver will now act on both updates to Account and Balance by treating
# them both as records.
#
class Observer
diff --git a/activemodel/lib/active_model/serialization.rb b/activemodel/lib/active_model/serialization.rb
index e675937f4d..d4c6c15e01 100644
--- a/activemodel/lib/active_model/serialization.rb
+++ b/activemodel/lib/active_model/serialization.rb
@@ -3,25 +3,25 @@ require 'active_support/core_ext/hash/slice'
module ActiveModel
# == Active Model Serialization
- #
+ #
# Provides a basic serialization to a serializable_hash for your object.
- #
+ #
# A minimal implementation could be:
- #
+ #
# class Person
- #
+ #
# include ActiveModel::Serialization
- #
+ #
# attr_accessor :name
- #
+ #
# def attributes
# @attributes ||= {'name' => 'nil'}
# end
- #
+ #
# end
- #
+ #
# Which would provide you with:
- #
+ #
# person = Person.new
# person.serializable_hash # => {"name"=>nil}
# person.name = "Bob"
@@ -29,40 +29,40 @@ module ActiveModel
#
# You need to declare some sort of attributes hash which contains the attributes
# you want to serialize and their current value.
- #
- # Most of the time though, you will want to include the JSON or XML
- # serializations. Both of these modules automatically include the
+ #
+ # Most of the time though, you will want to include the JSON or XML
+ # serializations. Both of these modules automatically include the
# ActiveModel::Serialization module, so there is no need to explicitly
# include it.
- #
+ #
# So a minimal implementation including XML and JSON would be:
- #
+ #
# class Person
- #
+ #
# include ActiveModel::Serializers::JSON
# include ActiveModel::Serializers::Xml
- #
+ #
# attr_accessor :name
- #
+ #
# def attributes
# @attributes ||= {'name' => 'nil'}
# end
- #
+ #
# end
- #
+ #
# Which would provide you with:
- #
+ #
# person = Person.new
# person.serializable_hash # => {"name"=>nil}
# person.to_json # => "{\"name\":null}"
# person.to_xml # => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<serial-person...
- #
+ #
# person.name = "Bob"
# person.serializable_hash # => {"name"=>"Bob"}
# person.to_json # => "{\"name\":\"Bob\"}"
# person.to_xml # => "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<serial-person...
#
- # Valid options are <tt>:only</tt>, <tt>:except</tt> and <tt>:methods</tt> .
+ # Valid options are <tt>:only</tt>, <tt>:except</tt> and <tt>:methods</tt> .
module Serialization
def serializable_hash(options = nil)
options ||= {}
diff --git a/activemodel/lib/active_model/serializers/xml.rb b/activemodel/lib/active_model/serializers/xml.rb
index ed64434b8f..16ab8e7928 100644
--- a/activemodel/lib/active_model/serializers/xml.rb
+++ b/activemodel/lib/active_model/serializers/xml.rb
@@ -52,7 +52,7 @@ module ActiveModel
@options[:except] = Array.wrap(@options[:except]).map { |n| n.to_s }
end
- # To replicate the behavior in ActiveRecord#attributes, <tt>:except</tt>
+ # To replicate the behavior in ActiveRecord#attributes, <tt>:except</tt>
# takes precedence over <tt>:only</tt>. If <tt>:only</tt> is not set
# for a N level model but is set for the N+1 level models,
# then because <tt>:except</tt> is set to a default value, the second
diff --git a/activemodel/lib/active_model/translation.rb b/activemodel/lib/active_model/translation.rb
index 0facbd6ce1..6c1cecd9b7 100644
--- a/activemodel/lib/active_model/translation.rb
+++ b/activemodel/lib/active_model/translation.rb
@@ -3,19 +3,19 @@ require 'active_support/core_ext/hash/reverse_merge'
module ActiveModel
# == Active Model Translation
- #
+ #
# Provides integration between your object and the Rails internationalization
# (i18n) framework.
- #
+ #
# A minimal implementation could be:
- #
+ #
# class TranslatedPerson
# extend ActiveModel::Translation
# end
- #
+ #
# TranslatedPerson.human_attribute_name('my_attribute')
# # => "My attribute"
- #
+ #
# This also provides the required class methods for hooking into the
# Rails internationalization API, including being able to define a
# class based i18n_scope and lookup_ancestors to find translations in
@@ -28,9 +28,9 @@ module ActiveModel
:activemodel
end
- # When localizing a string, it goes through the lookup returned by this
+ # When localizing a string, it goes through the lookup returned by this
# method, which is used in ActiveModel::Name#human,
- # ActiveModel::Errors#full_messages and
+ # ActiveModel::Errors#full_messages and
# ActiveModel::Translation#human_attribute_name.
def lookup_ancestors
self.ancestors.select { |x| x.respond_to?(:model_name) }
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 37429f2bb8..cd37925292 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -9,24 +9,24 @@ require 'active_model/validations/callbacks'
module ActiveModel
# == Active Model Validations
- #
+ #
# Provides a full validation framework to your objects.
- #
+ #
# A minimal implementation could be:
- #
+ #
# class Person
# include ActiveModel::Validations
- #
+ #
# attr_accessor :first_name, :last_name
#
# validates_each :first_name, :last_name do |record, attr, value|
# record.errors.add attr, 'starts with z.' if value.to_s[0] == ?z
# end
# end
- #
+ #
# Which provides you with the full standard validation stack that you
# know from Active Record:
- #
+ #
# person = Person.new
# person.valid? # => true
# person.invalid? # => false
@@ -35,11 +35,11 @@ module ActiveModel
# person.valid? # => false
# person.invalid? # => true
# person.errors # => #<OrderedHash {:first_name=>["starts with z."]}>
- #
+ #
# Note that ActiveModel::Validations automatically adds an +errors+ method
# to your instances initialized with a new ActiveModel::Errors object, so
# there is no need for you to do this manually.
- #
+ #
module Validations
extend ActiveSupport::Concern
include ActiveSupport::Callbacks
@@ -62,7 +62,7 @@ module ActiveModel
#
# class Person
# include ActiveModel::Validations
- #
+ #
# attr_accessor :first_name, :last_name
#
# validates_each :first_name, :last_name do |record, attr, value|
@@ -71,7 +71,7 @@ module ActiveModel
# end
#
# Options:
- # * <tt>:on</tt> - Specifies when this validation is active (default is
+ # * <tt>:on</tt> - Specifies when this validation is active (default is
# <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>).
# * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+.
# * <tt>:allow_blank</tt> - Skip validation if attribute is blank.
@@ -96,7 +96,7 @@ module ActiveModel
#
# class Comment
# include ActiveModel::Validations
- #
+ #
# validate :must_be_friends
#
# def must_be_friends
@@ -129,7 +129,7 @@ module ActiveModel
set_callback(:validate, *args, &block)
end
- # List all validators that are being used to validate the model using
+ # List all validators that are being used to validate the model using
# +validates_with+ method.
def validators
_validators.values.flatten.uniq
@@ -169,14 +169,14 @@ module ActiveModel
self.validation_context = current_context
end
- # Performs the opposite of <tt>valid?</tt>. Returns true if errors were added,
+ # Performs the opposite of <tt>valid?</tt>. Returns true if errors were added,
# false otherwise.
def invalid?(context = nil)
!valid?(context)
end
- # Hook method defining how an attribute value should be retrieved. By default
- # this is assumed to be an instance named after the attribute. Override this
+ # Hook method defining how an attribute value should be retrieved. By default
+ # this is assumed to be an instance named after the attribute. Override this
# method in subclasses should you need to retrieve the value for a given
# attribute differently:
#
@@ -195,7 +195,7 @@ module ActiveModel
alias :read_attribute_for_validation :send
protected
-
+
def run_validations!
_run_validate_callbacks
errors.empty?
diff --git a/activemodel/lib/active_model/validations/acceptance.rb b/activemodel/lib/active_model/validations/acceptance.rb
index 99b8966def..d9dfe0c855 100644
--- a/activemodel/lib/active_model/validations/acceptance.rb
+++ b/activemodel/lib/active_model/validations/acceptance.rb
@@ -24,7 +24,7 @@ module ActiveModel
end
module HelperMethods
- # Encapsulates the pattern of wanting to validate the acceptance of a
+ # Encapsulates the pattern of wanting to validate the acceptance of a
# terms of service check box (or similar agreement). Example:
#
# class Person < ActiveRecord::Base
@@ -32,33 +32,33 @@ module ActiveModel
# validates_acceptance_of :eula, :message => "must be abided"
# end
#
- # If the database column does not exist, the +terms_of_service+ attribute
+ # If the database column does not exist, the +terms_of_service+ attribute
# is entirely virtual. This check is performed only if +terms_of_service+
# is not +nil+ and by default on save.
#
# Configuration options:
- # * <tt>:message</tt> - A custom error message (default is: "must be
+ # * <tt>:message</tt> - A custom error message (default is: "must be
# accepted").
# * <tt>:on</tt> - Specifies when this validation is active (default is
- # <tt>:save</tt>, other options are <tt>:create</tt> and
+ # <tt>:save</tt>, other options are <tt>:create</tt> and
# <tt>:update</tt>).
# * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+ (default
# is true).
- # * <tt>:accept</tt> - Specifies value that is considered accepted.
+ # * <tt>:accept</tt> - Specifies value that is considered accepted.
# The default value is a string "1", which makes it easy to relate to
- # an HTML checkbox. This should be set to +true+ if you are validating
+ # an HTML checkbox. This should be set to +true+ if you are validating
# a database column, since the attribute is typecast from "1" to +true+
# before validation.
# * <tt>:if</tt> - Specifies a method, proc or string to call to determine
# if the validation should occur (e.g. <tt>:if => :allow_validation</tt>,
# or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The
- # method, proc or string should return or evaluate to a true or false
+ # method, proc or string should return or evaluate to a true or false
# value.
- # * <tt>:unless</tt> - Specifies a method, proc or string to call to
- # determine if the validation should not occur (for example,
- # <tt>:unless => :skip_validation</tt>, or
+ # * <tt>:unless</tt> - Specifies a method, proc or string to call to
+ # determine if the validation should not occur (for example,
+ # <tt>:unless => :skip_validation</tt>, or
# <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>).
- # The method, proc or string should return or evaluate to a true or
+ # The method, proc or string should return or evaluate to a true or
# false value.
def validates_acceptance_of(*attr_names)
validates_with AcceptanceValidator, _merge_attributes(attr_names)
diff --git a/activemodel/lib/active_model/validations/confirmation.rb b/activemodel/lib/active_model/validations/confirmation.rb
index 3a80893866..a31966d0c2 100644
--- a/activemodel/lib/active_model/validations/confirmation.rb
+++ b/activemodel/lib/active_model/validations/confirmation.rb
@@ -15,13 +15,13 @@ module ActiveModel
end
module HelperMethods
- # Encapsulates the pattern of wanting to validate a password or email
+ # Encapsulates the pattern of wanting to validate a password or email
# address field with a confirmation. For example:
#
# Model:
# class Person < ActiveRecord::Base
# validates_confirmation_of :user_name, :password
- # validates_confirmation_of :email_address,
+ # validates_confirmation_of :email_address,
# :message => "should match confirmation"
# end
#
@@ -29,12 +29,12 @@ module ActiveModel
# <%= password_field "person", "password" %>
# <%= password_field "person", "password_confirmation" %>
#
- # The added +password_confirmation+ attribute is virtual; it exists only
+ # The added +password_confirmation+ attribute is virtual; it exists only
# as an in-memory attribute for validating the password. To achieve this,
- # the validation adds accessors to the model for the confirmation
+ # the validation adds accessors to the model for the confirmation
# attribute.
- #
- # NOTE: This check is performed only if +password_confirmation+ is not
+ #
+ # NOTE: This check is performed only if +password_confirmation+ is not
# +nil+, and by default only on save. To require confirmation, make sure
# to add a presence check for the confirmation attribute:
#
@@ -48,11 +48,11 @@ module ActiveModel
# * <tt>:if</tt> - Specifies a method, proc or string to call to determine
# if the validation should occur (e.g. <tt>:if => :allow_validation</tt>,
# or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>). The
- # method, proc or string should return or evaluate to a true or false
+ # method, proc or string should return or evaluate to a true or false
# value.
- # * <tt>:unless</tt> - Specifies a method, proc or string to call to
- # determine if the validation should not occur (e.g.
- # <tt>:unless => :skip_validation</tt>, or
+ # * <tt>:unless</tt> - Specifies a method, proc or string to call to
+ # determine if the validation should not occur (e.g.
+ # <tt>:unless => :skip_validation</tt>, or
# <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The
# method, proc or string should return or evaluate to a true or false value.
def validates_confirmation_of(*attr_names)
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb
index ecae73a66e..5a46ecb4ac 100644
--- a/activemodel/lib/active_model/validations/length.rb
+++ b/activemodel/lib/active_model/validations/length.rb
@@ -34,7 +34,7 @@ module ActiveModel
end
end
end
-
+
def validate_each(record, attribute, value)
value = options[:tokenizer].call(value) if value.kind_of?(String)
diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb
index 3260e6bc5a..3242e49269 100644
--- a/activemodel/lib/active_model/validations/validates.rb
+++ b/activemodel/lib/active_model/validations/validates.rb
@@ -9,7 +9,7 @@ module ActiveModel
# validator classes ending in 'Validator'. Note that Rails default
# validators can be overridden inside specific classes by creating
# custom validator classes in their place such as PresenceValidator.
- #
+ #
# Examples of using the default rails validators:
#
# validates :terms, :acceptance => true
@@ -21,7 +21,7 @@ module ActiveModel
# validates :age, :numericality => true
# validates :username, :presence => true
# validates :username, :uniqueness => true
- #
+ #
# The power of the +validates+ method comes when using custom validators
# and default validators in one call for a given attribute e.g.
#
@@ -31,15 +31,15 @@ module ActiveModel
# value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
# end
# end
- #
+ #
# class Person
# include ActiveModel::Validations
# attr_accessor :name, :email
- #
+ #
# validates :name, :presence => true, :uniqueness => true, :length => { :maximum => 100 }
# validates :email, :presence => true, :email => true
# end
- #
+ #
# Validator classes may also exist within the class being validated
# allowing custom modules of validators to be included as needed e.g.
#
diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb
index 163124d531..1262d305d1 100644
--- a/activemodel/lib/active_model/validator.rb
+++ b/activemodel/lib/active_model/validator.rb
@@ -5,8 +5,8 @@ require 'active_support/core_ext/object/blank'
module ActiveModel #:nodoc:
# == Active Model Validator
- #
- # A simple base class that can be used along with
+ #
+ # A simple base class that can be used along with
# +ActiveModel::Validations::ClassMethods.validates_with+
#
# class Person
@@ -61,31 +61,31 @@ module ActiveModel #:nodoc:
# @my_custom_field = options[:field_name] || :first_name
# end
# end
- #
+ #
# The easiest way to add custom validators for validating individual attributes
# is with the convenient ActiveModel::EachValidator for example:
- #
+ #
# class TitleValidator < ActiveModel::EachValidator
# def validate_each(record, attribute, value)
# record.errors[attribute] << 'must be Mr. Mrs. or Dr.' unless ['Mr.', 'Mrs.', 'Dr.'].include?(value)
# end
# end
- #
+ #
# This can now be used in combination with the +validates+ method
# (see ActiveModel::Validations::ClassMethods.validates for more on this)
- #
+ #
# class Person
# include ActiveModel::Validations
# attr_accessor :title
- #
+ #
# validates :title, :presence => true, :title => true
# end
- #
+ #
# Validator may also define a +setup+ instance method which will get called
# with the class that using that validator as it's argument. This can be
# useful when there are prerequisites such as an attr_accessor being present
# for example:
- #
+ #
# class MyValidator < ActiveModel::Validator
# def setup(klass)
# klass.send :attr_accessor, :custom_attribute
@@ -94,7 +94,7 @@ module ActiveModel #:nodoc:
#
# This setup method is only called when used with validation macros or the
# class level <tt>validates_with</tt> method.
- #
+ #
class Validator
attr_reader :options
@@ -133,7 +133,7 @@ module ActiveModel #:nodoc:
# All Active Model validations are built on top of this Validator.
class EachValidator < Validator
attr_reader :attributes
-
+
# Returns a new validator instance. All options will be available via the
# +options+ reader, however the <tt>:attributes</tt> option will be removed
# and instead be made available through the +attributes+ reader.
diff --git a/activemodel/test/cases/attribute_methods_test.rb b/activemodel/test/cases/attribute_methods_test.rb
index c60caf90d7..54cf8380ab 100644
--- a/activemodel/test/cases/attribute_methods_test.rb
+++ b/activemodel/test/cases/attribute_methods_test.rb
@@ -2,7 +2,7 @@ require 'cases/helper'
class ModelWithAttributes
include ActiveModel::AttributeMethods
-
+
attribute_method_suffix ''
def attributes
@@ -17,7 +17,7 @@ end
class ModelWithAttributes2
include ActiveModel::AttributeMethods
-
+
attribute_method_suffix '_test'
end
diff --git a/activemodel/test/cases/serializeration/json_serialization_test.rb b/activemodel/test/cases/serializeration/json_serialization_test.rb
index 1ac991a8f1..91e123e655 100644
--- a/activemodel/test/cases/serializeration/json_serialization_test.rb
+++ b/activemodel/test/cases/serializeration/json_serialization_test.rb
@@ -105,15 +105,15 @@ class JsonSerializationTest < ActiveModel::TestCase
test "should return OrderedHash for errors" do
car = Automobile.new
-
+
# run the validation
- car.valid?
-
+ car.valid?
+
hash = ActiveSupport::OrderedHash.new
hash[:make] = "can't be blank"
hash[:model] = "is too short (minimum is 2 characters)"
assert_equal hash.to_json, car.errors.to_json
end
-
-
+
+
end
diff --git a/activemodel/test/cases/translation_test.rb b/activemodel/test/cases/translation_test.rb
index e25d308ca1..d6942a5475 100644
--- a/activemodel/test/cases/translation_test.rb
+++ b/activemodel/test/cases/translation_test.rb
@@ -6,7 +6,7 @@ class ActiveModelI18nTests < ActiveModel::TestCase
def setup
I18n.backend = I18n::Backend::Simple.new
end
-
+
def test_translated_model_attributes
I18n.backend.store_translations 'en', :activemodel => {:attributes => {:person => {:name => 'person name attribute'} } }
assert_equal 'person name attribute', Person.human_attribute_name('name')
@@ -16,7 +16,7 @@ class ActiveModelI18nTests < ActiveModel::TestCase
I18n.backend.store_translations 'en', :attributes => { :name => 'name default attribute' }
assert_equal 'name default attribute', Person.human_attribute_name('name')
end
-
+
def test_translated_model_attributes_with_symbols
I18n.backend.store_translations 'en', :activemodel => {:attributes => {:person => {:name => 'person name attribute'} } }
assert_equal 'person name attribute', Person.human_attribute_name(:name)
diff --git a/activemodel/test/cases/validations/validates_test.rb b/activemodel/test/cases/validations/validates_test.rb
index b85e491a9c..db023f6169 100644
--- a/activemodel/test/cases/validations/validates_test.rb
+++ b/activemodel/test/cases/validations/validates_test.rb
@@ -26,7 +26,7 @@ class ValidatesTest < ActiveModel::TestCase
person.valid?
assert_equal ['my custom message'], person.errors[:salary]
end
-
+
def test_validates_with_validator_class
Person.validates :karma, :email => true
person = Person.new
@@ -93,18 +93,18 @@ class ValidatesTest < ActiveModel::TestCase
person.valid?
assert_equal ['my custom message'], person.errors[:karma]
end
-
+
def test_validates_with_unknown_validator
assert_raise(ArgumentError) { Person.validates :karma, :unknown => true }
end
-
+
def test_validates_with_included_validator
PersonWithValidator.validates :title, :presence => true
person = PersonWithValidator.new
person.valid?
assert_equal ['Local validator'], person.errors[:title]
end
-
+
def test_validates_with_included_validator_and_options
PersonWithValidator.validates :title, :presence => { :custom => ' please' }
person = PersonWithValidator.new
diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb
index 8d6bdeb6a5..f9fc6613f4 100644
--- a/activemodel/test/cases/validations_test.rb
+++ b/activemodel/test/cases/validations_test.rb
@@ -170,7 +170,7 @@ class ValidationsTest < ActiveModel::TestCase
assert_match %r{<errors>}, xml
assert_match %r{<error>Title can't be blank</error>}, xml
assert_match %r{<error>Content can't be blank</error>}, xml
-
+
hash = ActiveSupport::OrderedHash.new
hash[:title] = "can't be blank"
hash[:content] = "can't be blank"
diff --git a/activemodel/test/models/custom_reader.rb b/activemodel/test/models/custom_reader.rb
index 14a8be9ebc..2fbcf79c3d 100644
--- a/activemodel/test/models/custom_reader.rb
+++ b/activemodel/test/models/custom_reader.rb
@@ -4,11 +4,11 @@ class CustomReader
def initialize(data = {})
@data = data
end
-
+
def []=(key, value)
@data[key] = value
end
-
+
def read_attribute_for_validation(key)
@data[key]
end
diff --git a/activemodel/test/models/person_with_validator.rb b/activemodel/test/models/person_with_validator.rb
index f9763ea853..f6f665ccee 100644
--- a/activemodel/test/models/person_with_validator.rb
+++ b/activemodel/test/models/person_with_validator.rb
@@ -1,6 +1,6 @@
class PersonWithValidator
include ActiveModel::Validations
-
+
class PresenceValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << "Local validator#{options[:custom]}" if value.blank?
diff --git a/activemodel/test/models/sheep.rb b/activemodel/test/models/sheep.rb
index 175dbe6477..7aba055c4f 100644
--- a/activemodel/test/models/sheep.rb
+++ b/activemodel/test/models/sheep.rb
@@ -1,4 +1,3 @@
class Sheep
extend ActiveModel::Naming
end
- \ No newline at end of file
diff --git a/activerecord/README.rdoc b/activerecord/README.rdoc
index 8dbd6c82b5..1a0db4691b 100644
--- a/activerecord/README.rdoc
+++ b/activerecord/README.rdoc
@@ -19,19 +19,19 @@ A short rundown of some of the major features:
class Product < ActiveRecord::Base
end
-
+
The Product class is automatically mapped to the table named "products",
which might look like this:
-
+
CREATE TABLE products (
id int(11) NOT NULL auto_increment,
name varchar(255),
PRIMARY KEY (id)
);
-
+
This would also define the following accessors: `Product#name` and
`Product#name=(new_name)`
-
+
{Learn more}[link:classes/ActiveRecord/Base.html]
@@ -51,7 +51,7 @@ A short rundown of some of the major features:
class Account < ActiveRecord::Base
composed_of :balance, :class_name => "Money",
:mapping => %w(balance amount)
- composed_of :address,
+ composed_of :address,
:mapping => [%w(address_street street), %w(address_city city)]
end
@@ -91,7 +91,7 @@ A short rundown of some of the major features:
{Learn more}[link:classes/ActiveRecord/Observer.html]
-* Inheritance hierarchies
+* Inheritance hierarchies
class Company < ActiveRecord::Base; end
class Firm < Company; end
@@ -170,7 +170,7 @@ A short rundown of some of the major features:
{Learn more}[link:classes/ActiveRecord/Migration.html]
-== Philosophy
+== Philosophy
Active Record is an implementation of the object-relational mapping (ORM)
pattern[http://www.martinfowler.com/eaaCatalog/activeRecord.html] by the same
@@ -179,7 +179,7 @@ name described by Martin Fowler:
"An object that wraps a row in a database table or view,
encapsulates the database access, and adds domain logic on that data."
-Active Record attempts to provide a coherent wrapper as a solution for the inconvenience that is
+Active Record attempts to provide a coherent wrapper as a solution for the inconvenience that is
object-relational mapping. The prime directive for this mapping has been to minimize
the amount of code needed to build a real-world domain model. This is made possible
by relying on a number of conventions that make it easy for Active Record to infer
@@ -188,7 +188,7 @@ complex relations and structures from a minimal amount of explicit direction.
Convention over Configuration:
* No XML-files!
* Lots of reflection and run-time extension
-* Magic is not inherently a bad word
+* Magic is not inherently a bad word
Admit the Database:
* Lets you drop down to SQL for odd cases and performance
diff --git a/activerecord/RUNNING_UNIT_TESTS b/activerecord/RUNNING_UNIT_TESTS
index 03e561a50b..324df2c025 100644
--- a/activerecord/RUNNING_UNIT_TESTS
+++ b/activerecord/RUNNING_UNIT_TESTS
@@ -1,13 +1,13 @@
== Creating the test database
-The default names for the test databases are "activerecord_unittest" and
-"activerecord_unittest2". If you want to use another database name then be sure
-to update the connection adapter setups you want to test with in
-test/connections/<your database>/connection.rb.
-When you have the database online, you can import the fixture tables with
+The default names for the test databases are "activerecord_unittest" and
+"activerecord_unittest2". If you want to use another database name then be sure
+to update the connection adapter setups you want to test with in
+test/connections/<your database>/connection.rb.
+When you have the database online, you can import the fixture tables with
the test/schema/*.sql files.
-Make sure that you create database objects with the same user that you specified in
+Make sure that you create database objects with the same user that you specified in
connection.rb otherwise (on Postgres, at least) tests for default values will fail.
== Running with Rake
@@ -22,11 +22,11 @@ Rake can be found at http://rake.rubyforge.org
== Running by hand
-Unit tests are located in test/cases directory. If you only want to run a single test suite,
+Unit tests are located in test/cases directory. If you only want to run a single test suite,
you can do so with:
rake test_mysql TEST=test/cases/base_test.rb
-
+
That'll run the base suite using the MySQL-Ruby adapter. Some tests rely on the schema
being initialized - you can initialize the schema with:
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb
index 83a9ab46c5..6d745c9ec2 100644
--- a/activerecord/lib/active_record/aggregations.rb
+++ b/activerecord/lib/active_record/aggregations.rb
@@ -9,12 +9,12 @@ module ActiveRecord
end unless self.new_record?
end
- # Active Record implements aggregation through a macro-like class method called +composed_of+
- # for representing attributes as value objects. It expresses relationships like "Account [is]
- # composed of Money [among other things]" or "Person [is] composed of [an] address". Each call
- # to the macro adds a description of how the value objects are created from the attributes of
- # the entity object (when the entity is initialized either as a new object or from finding an
- # existing object) and how it can be turned back into attributes (when the entity is saved to
+ # Active Record implements aggregation through a macro-like class method called +composed_of+
+ # for representing attributes as value objects. It expresses relationships like "Account [is]
+ # composed of Money [among other things]" or "Person [is] composed of [an] address". Each call
+ # to the macro adds a description of how the value objects are created from the attributes of
+ # the entity object (when the entity is initialized either as a new object or from finding an
+ # existing object) and how it can be turned back into attributes (when the entity is saved to
# the database).
#
# class Customer < ActiveRecord::Base
@@ -70,9 +70,9 @@ module ActiveRecord
# end
# end
#
- # Now it's possible to access attributes from the database through the value objects instead. If
- # you choose to name the composition the same as the attribute's name, it will be the only way to
- # access that attribute. That's the case with our +balance+ attribute. You interact with the value
+ # Now it's possible to access attributes from the database through the value objects instead. If
+ # you choose to name the composition the same as the attribute's name, it will be the only way to
+ # access that attribute. That's the case with our +balance+ attribute. You interact with the value
# objects just like you would any other attribute, though:
#
# customer.balance = Money.new(20) # sets the Money value object and the attribute
@@ -82,8 +82,8 @@ module ActiveRecord
# customer.balance == Money.new(20) # => true
# customer.balance < Money.new(5) # => false
#
- # Value objects can also be composed of multiple attributes, such as the case of Address. The order
- # of the mappings will determine the order of the parameters.
+ # Value objects can also be composed of multiple attributes, such as the case of Address. The order
+ # of the mappings will determine the order of the parameters.
#
# customer.address_street = "Hyancintvej"
# customer.address_city = "Copenhagen"
@@ -94,42 +94,42 @@ module ActiveRecord
#
# == Writing value objects
#
- # Value objects are immutable and interchangeable objects that represent a given value, such as
- # a Money object representing $5. Two Money objects both representing $5 should be equal (through
- # methods such as <tt>==</tt> and <tt><=></tt> from Comparable if ranking makes sense). This is
+ # Value objects are immutable and interchangeable objects that represent a given value, such as
+ # a Money object representing $5. Two Money objects both representing $5 should be equal (through
+ # methods such as <tt>==</tt> and <tt><=></tt> from Comparable if ranking makes sense). This is
# unlike entity objects where equality is determined by identity. An entity class such as Customer can
- # easily have two different objects that both have an address on Hyancintvej. Entity identity is
- # determined by object or relational unique identifiers (such as primary keys). Normal
+ # easily have two different objects that both have an address on Hyancintvej. Entity identity is
+ # determined by object or relational unique identifiers (such as primary keys). Normal
# ActiveRecord::Base classes are entity objects.
#
- # It's also important to treat the value objects as immutable. Don't allow the Money object to have
- # its amount changed after creation. Create a new Money object with the new value instead. This
- # is exemplified by the Money#exchange_to method that returns a new value object instead of changing
- # its own values. Active Record won't persist value objects that have been changed through means
+ # It's also important to treat the value objects as immutable. Don't allow the Money object to have
+ # its amount changed after creation. Create a new Money object with the new value instead. This
+ # is exemplified by the Money#exchange_to method that returns a new value object instead of changing
+ # its own values. Active Record won't persist value objects that have been changed through means
# other than the writer method.
#
- # The immutable requirement is enforced by Active Record by freezing any object assigned as a value
+ # The immutable requirement is enforced by Active Record by freezing any object assigned as a value
# object. Attempting to change it afterwards will result in a ActiveSupport::FrozenObjectError.
#
- # Read more about value objects on http://c2.com/cgi/wiki?ValueObject and on the dangers of not
+ # Read more about value objects on http://c2.com/cgi/wiki?ValueObject and on the dangers of not
# keeping value objects immutable on http://c2.com/cgi/wiki?ValueObjectsShouldBeImmutable
#
# == Custom constructors and converters
#
- # By default value objects are initialized by calling the <tt>new</tt> constructor of the value
- # class passing each of the mapped attributes, in the order specified by the <tt>:mapping</tt>
- # option, as arguments. If the value class doesn't support this convention then +composed_of+ allows
+ # By default value objects are initialized by calling the <tt>new</tt> constructor of the value
+ # class passing each of the mapped attributes, in the order specified by the <tt>:mapping</tt>
+ # option, as arguments. If the value class doesn't support this convention then +composed_of+ allows
# a custom constructor to be specified.
#
- # When a new value is assigned to the value object the default assumption is that the new value
- # is an instance of the value class. Specifying a custom converter allows the new value to be automatically
+ # When a new value is assigned to the value object the default assumption is that the new value
+ # is an instance of the value class. Specifying a custom converter allows the new value to be automatically
# converted to an instance of value class if necessary.
#
- # For example, the NetworkResource model has +network_address+ and +cidr_range+ attributes that
- # should be aggregated using the NetAddr::CIDR value class (http://netaddr.rubyforge.org). The constructor
- # for the value class is called +create+ and it expects a CIDR address string as a parameter. New
- # values can be assigned to the value object using either another NetAddr::CIDR object, a string
- # or an array. The <tt>:constructor</tt> and <tt>:converter</tt> options can be used to meet
+ # For example, the NetworkResource model has +network_address+ and +cidr_range+ attributes that
+ # should be aggregated using the NetAddr::CIDR value class (http://netaddr.rubyforge.org). The constructor
+ # for the value class is called +create+ and it expects a CIDR address string as a parameter. New
+ # values can be assigned to the value object using either another NetAddr::CIDR object, a string
+ # or an array. The <tt>:constructor</tt> and <tt>:converter</tt> options can be used to meet
# these requirements:
#
# class NetworkResource < ActiveRecord::Base
@@ -157,8 +157,8 @@ module ActiveRecord
#
# == Finding records by a value object
#
- # Once a +composed_of+ relationship is specified for a model, records can be loaded from the database
- # by specifying an instance of the value object in the conditions hash. The following example
+ # Once a +composed_of+ relationship is specified for a model, records can be loaded from the database
+ # by specifying an instance of the value object in the conditions hash. The following example
# finds all customers with +balance_amount+ equal to 20 and +balance_currency+ equal to "USD":
#
# Customer.find(:all, :conditions => {:balance => Money.new(20, "USD")})
@@ -168,27 +168,27 @@ module ActiveRecord
# <tt>composed_of :address</tt> adds <tt>address</tt> and <tt>address=(new_address)</tt> methods.
#
# Options are:
- # * <tt>:class_name</tt> - Specifies the class name of the association. Use it only if that name
- # can't be inferred from the part id. So <tt>composed_of :address</tt> will by default be linked
- # to the Address class, but if the real class name is CompanyAddress, you'll have to specify it
+ # * <tt>:class_name</tt> - Specifies the class name of the association. Use it only if that name
+ # can't be inferred from the part id. So <tt>composed_of :address</tt> will by default be linked
+ # to the Address class, but if the real class name is CompanyAddress, you'll have to specify it
# with this option.
- # * <tt>:mapping</tt> - Specifies the mapping of entity attributes to attributes of the value
- # object. Each mapping is represented as an array where the first item is the name of the
- # entity attribute and the second item is the name the attribute in the value object. The
- # order in which mappings are defined determine the order in which attributes are sent to the
+ # * <tt>:mapping</tt> - Specifies the mapping of entity attributes to attributes of the value
+ # object. Each mapping is represented as an array where the first item is the name of the
+ # entity attribute and the second item is the name the attribute in the value object. The
+ # order in which mappings are defined determine the order in which attributes are sent to the
# value class constructor.
# * <tt>:allow_nil</tt> - Specifies that the value object will not be instantiated when all mapped
- # attributes are +nil+. Setting the value object to +nil+ has the effect of writing +nil+ to all
+ # attributes are +nil+. Setting the value object to +nil+ has the effect of writing +nil+ to all
# mapped attributes.
# This defaults to +false+.
- # * <tt>:constructor</tt> - A symbol specifying the name of the constructor method or a Proc that
- # is called to initialize the value object. The constructor is passed all of the mapped attributes,
- # in the order that they are defined in the <tt>:mapping option</tt>, as arguments and uses them
+ # * <tt>:constructor</tt> - A symbol specifying the name of the constructor method or a Proc that
+ # is called to initialize the value object. The constructor is passed all of the mapped attributes,
+ # in the order that they are defined in the <tt>:mapping option</tt>, as arguments and uses them
# to instantiate a <tt>:class_name</tt> object.
# The default is <tt>:new</tt>.
- # * <tt>:converter</tt> - A symbol specifying the name of a class method of <tt>:class_name</tt>
- # or a Proc that is called when a new value is assigned to the value object. The converter is
- # passed the single value that is used in the assignment and is only called if the new value is
+ # * <tt>:converter</tt> - A symbol specifying the name of a class method of <tt>:class_name</tt>
+ # or a Proc that is called when a new value is assigned to the value object. The converter is
+ # passed the single value that is used in the assignment and is only called if the new value is
# not an instance of <tt>:class_name</tt>.
#
# Option examples:
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb
index 0f0fdc2e21..5ac89a93c2 100644
--- a/activerecord/lib/active_record/association_preload.rb
+++ b/activerecord/lib/active_record/association_preload.rb
@@ -110,7 +110,7 @@ module ActiveRecord
def preload_one_association(records, association, preload_options={})
class_to_reflection = {}
# Not all records have the same class, so group then preload
- # group on the reflection itself so that if various subclass share the same association then
+ # group on the reflection itself so that if various subclass share the same association then
# we do not split them unnecessarily
records.group_by { |record| class_to_reflection[record.class] ||= record.class.reflections[association]}.each do |reflection, _records|
raise ConfigurationError, "Association named '#{ association }' was not found; perhaps you misspelled it?" unless reflection
@@ -149,7 +149,7 @@ module ActiveRecord
seen_keys = {}
associated_records.each do |associated_record|
#this is a has_one or belongs_to: there should only be one record.
- #Unfortunately we can't (in portable way) ask the database for
+ #Unfortunately we can't (in portable way) ask the database for
#'all records where foo_id in (x,y,z), but please
# only one row per distinct foo_id' so this where we enforce that
next if seen_keys[associated_record[key].to_s]
@@ -163,7 +163,7 @@ module ActiveRecord
id_to_record_map.each do |id, records|
next if seen_keys.include?(id.to_s)
- records.each {|record| record.send("set_#{reflection_name}_target", nil) }
+ records.each {|record| record.send("set_#{reflection_name}_target", nil) }
end
end
@@ -305,7 +305,7 @@ module ActiveRecord
polymorph_type = options[:foreign_type]
klasses_and_ids = {}
- # Construct a mapping from klass to a list of ids to load and a mapping of those ids back
+ # Construct a mapping from klass to a list of ids to load and a mapping of those ids back
# to their parent_records
records.each do |record|
if klass = record.send(polymorph_type)
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 096709e166..0f4e9568ac 100644
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -136,12 +136,12 @@ module ActiveRecord
instance_variable_set("@#{name}", association)
end
- # Associations are a set of macro-like class methods for tying objects together through
- # foreign keys. They express relationships like "Project has one Project Manager"
- # or "Project belongs to a Portfolio". Each macro adds a number of methods to the
- # class which are specialized according to the collection or association symbol and the
+ # Associations are a set of macro-like class methods for tying objects together through
+ # foreign keys. They express relationships like "Project has one Project Manager"
+ # or "Project belongs to a Portfolio". Each macro adds a number of methods to the
+ # class which are specialized according to the collection or association symbol and the
# options hash. It works much the same way as Ruby's own <tt>attr*</tt>
- # methods.
+ # methods.
#
# class Project < ActiveRecord::Base
# belongs_to :portfolio
@@ -150,7 +150,7 @@ module ActiveRecord
# has_and_belongs_to_many :categories
# end
#
- # The project class now has the following methods (and more) to ease the traversal and
+ # The project class now has the following methods (and more) to ease the traversal and
# manipulation of its relationships:
# * <tt>Project#portfolio, Project#portfolio=(portfolio), Project#portfolio.nil?</tt>
# * <tt>Project#project_manager, Project#project_manager=(project_manager), Project#project_manager.nil?,</tt>
@@ -162,8 +162,8 @@ module ActiveRecord
#
# === A word of warning
#
- # Don't create associations that have the same name as instance methods of
- # <tt>ActiveRecord::Base</tt>. Since the association adds a method with that name to
+ # Don't create associations that have the same name as instance methods of
+ # <tt>ActiveRecord::Base</tt>. Since the association adds a method with that name to
# its model, it will override the inherited method and break things.
# For instance, +attributes+ and +connection+ would be bad choices for association names.
#
@@ -274,7 +274,7 @@ module ActiveRecord
#
# == Is it a +belongs_to+ or +has_one+ association?
#
- # Both express a 1-1 relationship. The difference is mostly where to place the foreign
+ # Both express a 1-1 relationship. The difference is mostly where to place the foreign
# key, which goes on the table for the class declaring the +belongs_to+ relationship.
#
# class User < ActiveRecord::Base
@@ -304,44 +304,44 @@ module ActiveRecord
#
# == Unsaved objects and associations
#
- # You can manipulate objects and associations before they are saved to the database, but
- # there is some special behavior you should be aware of, mostly involving the saving of
+ # You can manipulate objects and associations before they are saved to the database, but
+ # there is some special behavior you should be aware of, mostly involving the saving of
# associated objects.
#
# You can set the :autosave option on a <tt>has_one</tt>, <tt>belongs_to</tt>,
# <tt>has_many</tt>, or <tt>has_and_belongs_to_many</tt> association. Setting it
# to +true+ will _always_ save the members, whereas setting it to +false+ will
# _never_ save the members. More details about :autosave option is available at
- # autosave_association.rb .
+ # autosave_association.rb .
#
# === One-to-one associations
#
- # * Assigning an object to a +has_one+ association automatically saves that object and
- # the object being replaced (if there is one), in order to update their primary
+ # * Assigning an object to a +has_one+ association automatically saves that object and
+ # the object being replaced (if there is one), in order to update their primary
# keys - except if the parent object is unsaved (<tt>new_record? == true</tt>).
- # * If either of these saves fail (due to one of the objects being invalid) the assignment
+ # * If either of these saves fail (due to one of the objects being invalid) the assignment
# statement returns +false+ and the assignment is cancelled.
- # * If you wish to assign an object to a +has_one+ association without saving it,
+ # * If you wish to assign an object to a +has_one+ association without saving it,
# use the <tt>association.build</tt> method (documented below).
- # * Assigning an object to a +belongs_to+ association does not save the object, since
+ # * Assigning an object to a +belongs_to+ association does not save the object, since
# the foreign key field belongs on the parent. It does not save the parent either.
#
# === Collections
#
- # * Adding an object to a collection (+has_many+ or +has_and_belongs_to_many+) automatically
- # saves that object, except if the parent object (the owner of the collection) is not yet
+ # * Adding an object to a collection (+has_many+ or +has_and_belongs_to_many+) automatically
+ # saves that object, except if the parent object (the owner of the collection) is not yet
# stored in the database.
- # * If saving any of the objects being added to a collection (via <tt>push</tt> or similar)
+ # * If saving any of the objects being added to a collection (via <tt>push</tt> or similar)
# fails, then <tt>push</tt> returns +false+.
- # * You can add an object to a collection without automatically saving it by using the
+ # * You can add an object to a collection without automatically saving it by using the
# <tt>collection.build</tt> method (documented below).
- # * All unsaved (<tt>new_record? == true</tt>) members of the collection are automatically
+ # * All unsaved (<tt>new_record? == true</tt>) members of the collection are automatically
# saved when the parent is saved.
#
# === Association callbacks
#
- # Similar to the normal callbacks that hook into the lifecycle of an Active Record object,
- # you can also define callbacks that get triggered when you add an object to or remove an
+ # Similar to the normal callbacks that hook into the lifecycle of an Active Record object,
+ # you can also define callbacks that get triggered when you add an object to or remove an
# object from an association collection.
#
# class Project
@@ -355,20 +355,20 @@ module ActiveRecord
# It's possible to stack callbacks by passing them as an array. Example:
#
# class Project
- # has_and_belongs_to_many :developers,
+ # has_and_belongs_to_many :developers,
# :after_add => [:evaluate_velocity, Proc.new { |p, d| p.shipping_date = Time.now}]
# end
#
# Possible callbacks are: +before_add+, +after_add+, +before_remove+ and +after_remove+.
#
- # Should any of the +before_add+ callbacks throw an exception, the object does not get
- # added to the collection. Same with the +before_remove+ callbacks; if an exception is
+ # Should any of the +before_add+ callbacks throw an exception, the object does not get
+ # added to the collection. Same with the +before_remove+ callbacks; if an exception is
# thrown the object doesn't get removed.
#
# === Association extensions
#
- # The proxy objects that control the access to associations can be extended through anonymous
- # modules. This is especially beneficial for adding new finders, creators, and other
+ # The proxy objects that control the access to associations can be extended through anonymous
+ # modules. This is especially beneficial for adding new finders, creators, and other
# factory-type methods that are only used as part of this association.
#
# class Account < ActiveRecord::Base
@@ -384,8 +384,8 @@ module ActiveRecord
# person.first_name # => "David"
# person.last_name # => "Heinemeier Hansson"
#
- # If you need to share the same extensions between many associations, you can use a named
- # extension module.
+ # If you need to share the same extensions between many associations, you can use a named
+ # extension module.
#
# module FindOrCreateByNameExtension
# def find_or_create_by_name(name)
@@ -402,10 +402,10 @@ module ActiveRecord
# has_many :people, :extend => FindOrCreateByNameExtension
# end
#
- # If you need to use multiple named extension modules, you can specify an array of modules
+ # If you need to use multiple named extension modules, you can specify an array of modules
# with the <tt>:extend</tt> option.
- # In the case of name conflicts between methods in the modules, methods in modules later
- # in the array supercede those earlier in the array.
+ # In the case of name conflicts between methods in the modules, methods in modules later
+ # in the array supercede those earlier in the array.
#
# class Account < ActiveRecord::Base
# has_many :people, :extend => [FindOrCreateByNameExtension, FindRecentExtension]
@@ -416,13 +416,13 @@ module ActiveRecord
#
# * +proxy_owner+ - Returns the object the association is part of.
# * +proxy_reflection+ - Returns the reflection object that describes the association.
- # * +proxy_target+ - Returns the associated object for +belongs_to+ and +has_one+, or
+ # * +proxy_target+ - Returns the associated object for +belongs_to+ and +has_one+, or
# the collection of associated objects for +has_many+ and +has_and_belongs_to_many+.
#
# === Association Join Models
#
- # Has Many associations can be configured with the <tt>:through</tt> option to use an
- # explicit join model to retrieve the data. This operates similarly to a
+ # Has Many associations can be configured with the <tt>:through</tt> option to use an
+ # explicit join model to retrieve the data. This operates similarly to a
# +has_and_belongs_to_many+ association. The advantage is that you're able to add validations,
# callbacks, and extra attributes on the join model. Consider the following schema:
#
@@ -480,8 +480,8 @@ module ActiveRecord
# @group.users.collect { |u| u.avatar }.flatten # select all avatars for all users in the group
# @group.avatars # selects all avatars by going through the User join model.
#
- # An important caveat with going through +has_one+ or +has_many+ associations on the
- # join model is that these associations are *read-only*. For example, the following
+ # An important caveat with going through +has_one+ or +has_many+ associations on the
+ # join model is that these associations are *read-only*. For example, the following
# would not work following the previous example:
#
# @group.avatars << Avatar.new # this would work if User belonged_to Avatar rather than the other way around
@@ -489,8 +489,8 @@ module ActiveRecord
#
# === Polymorphic Associations
#
- # Polymorphic associations on models are not restricted on what types of models they
- # can be associated with. Rather, they specify an interface that a +has_many+ association
+ # Polymorphic associations on models are not restricted on what types of models they
+ # can be associated with. Rather, they specify an interface that a +has_many+ association
# must adhere to.
#
# class Asset < ActiveRecord::Base
@@ -503,15 +503,15 @@ module ActiveRecord
#
# @asset.attachable = @post
#
- # This works by using a type column in addition to a foreign key to specify the associated
- # record. In the Asset example, you'd need an +attachable_id+ integer column and an
+ # This works by using a type column in addition to a foreign key to specify the associated
+ # record. In the Asset example, you'd need an +attachable_id+ integer column and an
# +attachable_type+ string column.
#
- # Using polymorphic associations in combination with single table inheritance (STI) is
- # a little tricky. In order for the associations to work as expected, ensure that you
- # store the base model for the STI models in the type column of the polymorphic
+ # Using polymorphic associations in combination with single table inheritance (STI) is
+ # a little tricky. In order for the associations to work as expected, ensure that you
+ # store the base model for the STI models in the type column of the polymorphic
# association. To continue with the asset example above, suppose there are guest posts
- # and member posts that use the posts table for STI. In this case, there must be a +type+
+ # and member posts that use the posts table for STI. In this case, there must be a +type+
# column in the posts table.
#
# class Asset < ActiveRecord::Base
@@ -535,8 +535,8 @@ module ActiveRecord
#
# == Caching
#
- # All of the methods are built on a simple caching principle that will keep the result
- # of the last query around unless specifically instructed not to. The cache is even
+ # All of the methods are built on a simple caching principle that will keep the result
+ # of the last query around unless specifically instructed not to. The cache is even
# shared across methods to make it even cheaper to use the macro-added methods without
# worrying too much about performance at the first go.
#
@@ -548,9 +548,9 @@ module ActiveRecord
#
# == Eager loading of associations
#
- # Eager loading is a way to find objects of a certain class and a number of named associations.
- # This is one of the easiest ways of to prevent the dreaded 1+N problem in which fetching 100
- # posts that each need to display their author triggers 101 database queries. Through the
+ # Eager loading is a way to find objects of a certain class and a number of named associations.
+ # This is one of the easiest ways of to prevent the dreaded 1+N problem in which fetching 100
+ # posts that each need to display their author triggers 101 database queries. Through the
# use of eager loading, the 101 queries can be reduced to 2.
#
# class Post < ActiveRecord::Base
@@ -566,54 +566,54 @@ module ActiveRecord
# puts "Last comment on: " + post.comments.first.created_on
# end
#
- # To iterate over these one hundred posts, we'll generate 201 database queries. Let's
+ # To iterate over these one hundred posts, we'll generate 201 database queries. Let's
# first just optimize it for retrieving the author:
#
# for post in Post.find(:all, :include => :author)
#
- # This references the name of the +belongs_to+ association that also used the <tt>:author</tt>
- # symbol. After loading the posts, find will collect the +author_id+ from each one and load
- # all the referenced authors with one query. Doing so will cut down the number of queries
+ # This references the name of the +belongs_to+ association that also used the <tt>:author</tt>
+ # symbol. After loading the posts, find will collect the +author_id+ from each one and load
+ # all the referenced authors with one query. Doing so will cut down the number of queries
# from 201 to 102.
#
# We can improve upon the situation further by referencing both associations in the finder with:
#
# for post in Post.find(:all, :include => [ :author, :comments ])
#
- # This will load all comments with a single query. This reduces the total number of queries
- # to 3. More generally the number of queries will be 1 plus the number of associations
+ # This will load all comments with a single query. This reduces the total number of queries
+ # to 3. More generally the number of queries will be 1 plus the number of associations
# named (except if some of the associations are polymorphic +belongs_to+ - see below).
#
# To include a deep hierarchy of associations, use a hash:
#
# for post in Post.find(:all, :include => [ :author, { :comments => { :author => :gravatar } } ])
#
- # That'll grab not only all the comments but all their authors and gravatar pictures.
- # You can mix and match symbols, arrays and hashes in any combination to describe the
+ # That'll grab not only all the comments but all their authors and gravatar pictures.
+ # You can mix and match symbols, arrays and hashes in any combination to describe the
# associations you want to load.
#
- # All of this power shouldn't fool you into thinking that you can pull out huge amounts
- # of data with no performance penalty just because you've reduced the number of queries.
- # The database still needs to send all the data to Active Record and it still needs to
- # be processed. So it's no catch-all for performance problems, but it's a great way to
+ # All of this power shouldn't fool you into thinking that you can pull out huge amounts
+ # of data with no performance penalty just because you've reduced the number of queries.
+ # The database still needs to send all the data to Active Record and it still needs to
+ # be processed. So it's no catch-all for performance problems, but it's a great way to
# cut down on the number of queries in a situation as the one described above.
#
- # Since only one table is loaded at a time, conditions or orders cannot reference tables
- # other than the main one. If this is the case Active Record falls back to the previously
+ # Since only one table is loaded at a time, conditions or orders cannot reference tables
+ # other than the main one. If this is the case Active Record falls back to the previously
# used LEFT OUTER JOIN based strategy. For example
#
# Post.find(:all, :include => [ :author, :comments ], :conditions => ['comments.approved = ?', true])
#
- # This will result in a single SQL query with joins along the lines of:
+ # This will result in a single SQL query with joins along the lines of:
# <tt>LEFT OUTER JOIN comments ON comments.post_id = posts.id</tt> and
- # <tt>LEFT OUTER JOIN authors ON authors.id = posts.author_id</tt>. Note that using conditions
+ # <tt>LEFT OUTER JOIN authors ON authors.id = posts.author_id</tt>. Note that using conditions
# like this can have unintended consequences.
- # In the above example posts with no approved comments are not returned at all, because
- # the conditions apply to the SQL statement as a whole and not just to the association.
+ # In the above example posts with no approved comments are not returned at all, because
+ # the conditions apply to the SQL statement as a whole and not just to the association.
# You must disambiguate column references for this fallback to happen, for example
# <tt>:order => "author.name DESC"</tt> will work but <tt>:order => "name DESC"</tt> will not.
#
- # If you do want eager load only some members of an association it is usually more natural
+ # If you do want eager load only some members of an association it is usually more natural
# to <tt>:include</tt> an association which has conditions defined on it:
#
# class Post < ActiveRecord::Base
@@ -622,10 +622,10 @@ module ActiveRecord
#
# Post.find(:all, :include => :approved_comments)
#
- # This will load posts and eager load the +approved_comments+ association, which contains
+ # This will load posts and eager load the +approved_comments+ association, which contains
# only those comments that have been approved.
#
- # If you eager load an association with a specified <tt>:limit</tt> option, it will be ignored,
+ # If you eager load an association with a specified <tt>:limit</tt> option, it will be ignored,
# returning all the associated objects:
#
# class Picture < ActiveRecord::Base
@@ -634,7 +634,7 @@ module ActiveRecord
#
# Picture.find(:first, :include => :most_recent_comments).most_recent_comments # => returns all associated comments.
#
- # When eager loaded, conditions are interpolated in the context of the model class, not
+ # When eager loaded, conditions are interpolated in the context of the model class, not
# the model instance. Conditions are lazily interpolated before the actual model exists.
#
# Eager loading is supported with polymorphic associations.
@@ -647,20 +647,20 @@ module ActiveRecord
#
# Address.find(:all, :include => :addressable)
#
- # This will execute one query to load the addresses and load the addressables with one
+ # This will execute one query to load the addresses and load the addressables with one
# query per addressable type.
- # For example if all the addressables are either of class Person or Company then a total
- # of 3 queries will be executed. The list of addressable types to load is determined on
+ # For example if all the addressables are either of class Person or Company then a total
+ # of 3 queries will be executed. The list of addressable types to load is determined on
# the back of the addresses loaded. This is not supported if Active Record has to fallback
- # to the previous implementation of eager loading and will raise ActiveRecord::EagerLoadPolymorphicError.
- # The reason is that the parent model's type is a column value so its corresponding table
+ # to the previous implementation of eager loading and will raise ActiveRecord::EagerLoadPolymorphicError.
+ # The reason is that the parent model's type is a column value so its corresponding table
# name cannot be put in the +FROM+/+JOIN+ clauses of that query.
#
# == Table Aliasing
#
- # Active Record uses table aliasing in the case that a table is referenced multiple times
- # in a join. If a table is referenced only once, the standard table name is used. The
- # second time, the table is aliased as <tt>#{reflection_name}_#{parent_table_name}</tt>.
+ # Active Record uses table aliasing in the case that a table is referenced multiple times
+ # in a join. If a table is referenced only once, the standard table name is used. The
+ # second time, the table is aliased as <tt>#{reflection_name}_#{parent_table_name}</tt>.
# Indexes are appended for any more successive uses of the table name.
#
# Post.find :all, :joins => :comments
@@ -694,7 +694,7 @@ module ActiveRecord
# INNER JOIN categories_posts posts_categories_join INNER JOIN posts posts_categories
# INNER JOIN categories_posts categories_posts_join INNER JOIN categories categories_posts_2
#
- # If you wish to specify your own custom joins using a <tt>:joins</tt> option, those table
+ # If you wish to specify your own custom joins using a <tt>:joins</tt> option, those table
# names will take precedence over the eager associations:
#
# Post.find :all, :joins => :comments, :joins => "inner join comments ..."
@@ -704,7 +704,7 @@ module ActiveRecord
# INNER JOIN comments special_comments_posts ...
# INNER JOIN comments ...
#
- # Table aliases are automatically truncated according to the maximum length of table identifiers
+ # Table aliases are automatically truncated according to the maximum length of table identifiers
# according to the specific database.
#
# == Modules
@@ -721,9 +721,9 @@ module ActiveRecord
# end
# end
#
- # When <tt>Firm#clients</tt> is called, it will in turn call
+ # When <tt>Firm#clients</tt> is called, it will in turn call
# <tt>MyApplication::Business::Client.find_all_by_firm_id(firm.id)</tt>.
- # If you want to associate with a class in another module scope, this can be done by
+ # If you want to associate with a class in another module scope, this can be done by
# specifying the complete class name.
#
# module MyApplication
@@ -740,7 +740,7 @@ module ActiveRecord
#
# == Bi-directional associations
#
- # When you specify an association there is usually an association on the associated model
+ # When you specify an association there is usually an association on the associated model
# that specifies the same relationship in reverse. For example, with the following models:
#
# class Dungeon < ActiveRecord::Base
@@ -756,10 +756,10 @@ module ActiveRecord
# belongs_to :dungeon
# end
#
- # The +traps+ association on +Dungeon+ and the the +dungeon+ association on +Trap+ are
- # the inverse of each other and the inverse of the +dungeon+ association on +EvilWizard+
+ # The +traps+ association on +Dungeon+ and the the +dungeon+ association on +Trap+ are
+ # the inverse of each other and the inverse of the +dungeon+ association on +EvilWizard+
# is the +evil_wizard+ association on +Dungeon+ (and vice-versa). By default,
- # Active Record doesn't know anything about these inverse relationships and so no object
+ # Active Record doesn't know anything about these inverse relationships and so no object
# loading optimisation is possible. For example:
#
# d = Dungeon.first
@@ -768,10 +768,10 @@ module ActiveRecord
# d.level = 10
# d.level == t.dungeon.level # => false
#
- # The +Dungeon+ instances +d+ and <tt>t.dungeon</tt> in the above example refer to
- # the same object data from the database, but are actually different in-memory copies
+ # The +Dungeon+ instances +d+ and <tt>t.dungeon</tt> in the above example refer to
+ # the same object data from the database, but are actually different in-memory copies
# of that data. Specifying the <tt>:inverse_of</tt> option on associations lets you tell
- # Active Record about inverse relationships and it will optimise object loading. For
+ # Active Record about inverse relationships and it will optimise object loading. For
# example, if we changed our model definitions to:
#
# class Dungeon < ActiveRecord::Base
@@ -787,7 +787,7 @@ module ActiveRecord
# belongs_to :dungeon, :inverse_of => :evil_wizard
# end
#
- # Then, from our code snippet above, +d+ and <tt>t.dungeon</tt> are actually the same
+ # Then, from our code snippet above, +d+ and <tt>t.dungeon</tt> are actually the same
# in-memory instance and our final <tt>d.level == t.dungeon.level</tt> will return +true+.
#
# There are limitations to <tt>:inverse_of</tt> support:
@@ -798,12 +798,12 @@ module ActiveRecord
#
# == Type safety with <tt>ActiveRecord::AssociationTypeMismatch</tt>
#
- # If you attempt to assign an object to an association that doesn't match the inferred
+ # If you attempt to assign an object to an association that doesn't match the inferred
# or specified <tt>:class_name</tt>, you'll get an <tt>ActiveRecord::AssociationTypeMismatch</tt>.
#
# == Options
#
- # All of the association macros can be specialized through options. This makes cases
+ # All of the association macros can be specialized through options. This makes cases
# more complex than the simple and guessable ones possible.
module ClassMethods
# Specifies a one-to-many association. The following methods for retrieval and query of
@@ -814,7 +814,7 @@ module ActiveRecord
# An empty array is returned if none are found.
# [collection<<(object, ...)]
# Adds one or more objects to the collection by setting their foreign keys to the collection's primary key.
- # Note that this operation instantly fires update sql without waiting for the save or update call on the
+ # Note that this operation instantly fires update sql without waiting for the save or update call on the
# parent object.
# [collection.delete(object, ...)]
# Removes one or more objects from the collection by setting their foreign keys to +NULL+.
@@ -878,21 +878,21 @@ module ActiveRecord
# === Supported options
# [:class_name]
# Specify the class name of the association. Use it only if that name can't be inferred
- # from the association name. So <tt>has_many :products</tt> will by default be linked
- # to the Product class, but if the real class name is SpecialProduct, you'll have to
+ # from the association name. So <tt>has_many :products</tt> will by default be linked
+ # to the Product class, but if the real class name is SpecialProduct, you'll have to
# specify it with this option.
# [:conditions]
# Specify the conditions that the associated objects must meet in order to be included as a +WHERE+
- # SQL fragment, such as <tt>price > 5 AND name LIKE 'B%'</tt>. Record creations from
- # the association are scoped if a hash is used.
- # <tt>has_many :posts, :conditions => {:published => true}</tt> will create published
+ # SQL fragment, such as <tt>price > 5 AND name LIKE 'B%'</tt>. Record creations from
+ # the association are scoped if a hash is used.
+ # <tt>has_many :posts, :conditions => {:published => true}</tt> will create published
# posts with <tt>@blog.posts.create</tt> or <tt>@blog.posts.build</tt>.
# [:order]
# Specify the order in which the associated objects are returned as an <tt>ORDER BY</tt> SQL fragment,
# such as <tt>last_name, first_name DESC</tt>.
# [:foreign_key]
# Specify the foreign key used for the association. By default this is guessed to be the name
- # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_many+
+ # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_many+
# association will use "person_id" as the default <tt>:foreign_key</tt>.
# [:primary_key]
# Specify the method that returns the primary key used for the association. By default this is +id+.
@@ -907,11 +907,11 @@ module ActiveRecord
#
# [:finder_sql]
# Specify a complete SQL statement to fetch the association. This is a good way to go for complex
- # associations that depend on multiple tables. Note: When this option is used, +find_in_collection+
+ # associations that depend on multiple tables. Note: When this option is used, +find_in_collection+
# is _not_ added.
# [:counter_sql]
# Specify a complete SQL statement to fetch the size of the association. If <tt>:finder_sql</tt> is
- # specified but not <tt>:counter_sql</tt>, <tt>:counter_sql</tt> will be generated by
+ # specified but not <tt>:counter_sql</tt>, <tt>:counter_sql</tt> will be generated by
# replacing <tt>SELECT ... FROM</tt> with <tt>SELECT COUNT(*) FROM</tt>.
# [:extend]
# Specify a named module for extending the proxy. See "Association extensions".
@@ -920,30 +920,30 @@ module ActiveRecord
# [:group]
# An attribute name by which the result should be grouped. Uses the <tt>GROUP BY</tt> SQL-clause.
# [:having]
- # Combined with +:group+ this can be used to filter the records that a <tt>GROUP BY</tt>
+ # Combined with +:group+ this can be used to filter the records that a <tt>GROUP BY</tt>
# returns. Uses the <tt>HAVING</tt> SQL-clause.
# [:limit]
# An integer determining the limit on the number of rows that should be returned.
# [:offset]
- # An integer determining the offset from where the rows should be fetched. So at 5,
+ # An integer determining the offset from where the rows should be fetched. So at 5,
# it would skip the first 4 rows.
# [:select]
- # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if
- # you, for example, want to do a join but not include the joined columns. Do not forget
+ # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if
+ # you, for example, want to do a join but not include the joined columns. Do not forget
# to include the primary and foreign keys, otherwise it will raise an error.
# [:as]
# Specifies a polymorphic interface (See <tt>belongs_to</tt>).
# [:through]
- # Specifies a join model through which to perform the query. Options for <tt>:class_name</tt>
- # and <tt>:foreign_key</tt> are ignored, as the association uses the source reflection. You
- # can only use a <tt>:through</tt> query through a <tt>belongs_to</tt>, <tt>has_one</tt>
- # or <tt>has_many</tt> association on the join model. The collection of join models
- # can be managed via the collection API. For example, new join models are created for
+ # Specifies a join model through which to perform the query. Options for <tt>:class_name</tt>
+ # and <tt>:foreign_key</tt> are ignored, as the association uses the source reflection. You
+ # can only use a <tt>:through</tt> query through a <tt>belongs_to</tt>, <tt>has_one</tt>
+ # or <tt>has_many</tt> association on the join model. The collection of join models
+ # can be managed via the collection API. For example, new join models are created for
# newly associated objects, and if some are gone their rows are deleted (directly,
# no destroy callbacks are triggered).
# [:source]
- # Specifies the source association name used by <tt>has_many :through</tt> queries.
- # Only use it if the name cannot be inferred from the association.
+ # Specifies the source association name used by <tt>has_many :through</tt> queries.
+ # Only use it if the name cannot be inferred from the association.
# <tt>has_many :subscribers, :through => :subscriptions</tt> will look for either <tt>:subscribers</tt> or
# <tt>:subscriber</tt> on Subscription, unless a <tt>:source</tt> is given.
# [:source_type]
@@ -956,12 +956,12 @@ module ActiveRecord
# [:validate]
# If +false+, don't validate the associated objects when saving the parent object. true by default.
# [:autosave]
- # If true, always save the associated objects or destroy them if marked for destruction,
+ # If true, always save the associated objects or destroy them if marked for destruction,
# when saving the parent object. If false, never save or destroy the associated objects.
# By default, only save associated objects that are new records.
# [:inverse_of]
- # Specifies the name of the <tt>belongs_to</tt> association on the associated object
- # that is the inverse of this <tt>has_many</tt> association. Does not work in combination
+ # Specifies the name of the <tt>belongs_to</tt> association on the associated object
+ # that is the inverse of this <tt>has_many</tt> association. Does not work in combination
# with <tt>:through</tt> or <tt>:as</tt> options.
# See ActiveRecord::Associations::ClassMethods's overview on Bi-directional associations for more detail.
#
@@ -1036,19 +1036,19 @@ module ActiveRecord
# [:conditions]
# Specify the conditions that the associated object must meet in order to be included as a +WHERE+
# SQL fragment, such as <tt>rank = 5</tt>. Record creation from the association is scoped if a hash
- # is used. <tt>has_one :account, :conditions => {:enabled => true}</tt> will create
+ # is used. <tt>has_one :account, :conditions => {:enabled => true}</tt> will create
# an enabled account with <tt>@company.create_account</tt> or <tt>@company.build_account</tt>.
# [:order]
# Specify the order in which the associated objects are returned as an <tt>ORDER BY</tt> SQL fragment,
# such as <tt>last_name, first_name DESC</tt>.
# [:dependent]
# If set to <tt>:destroy</tt>, the associated object is destroyed when this object is. If set to
- # <tt>:delete</tt>, the associated object is deleted *without* calling its destroy method.
- # If set to <tt>:nullify</tt>, the associated object's foreign key is set to +NULL+.
+ # <tt>:delete</tt>, the associated object is deleted *without* calling its destroy method.
+ # If set to <tt>:nullify</tt>, the associated object's foreign key is set to +NULL+.
# Also, association is assigned.
# [:foreign_key]
# Specify the foreign key used for the association. By default this is guessed to be the name
- # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_one+ association
+ # of this class in lower-case and "_id" suffixed. So a Person class that makes a +has_one+ association
# will use "person_id" as the default <tt>:foreign_key</tt>.
# [:primary_key]
# Specify the method that returns the primary key used for the association. By default this is +id+.
@@ -1057,17 +1057,17 @@ module ActiveRecord
# [:as]
# Specifies a polymorphic interface (See <tt>belongs_to</tt>).
# [:select]
- # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if, for example,
- # you want to do a join but not include the joined columns. Do not forget to include the
+ # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if, for example,
+ # you want to do a join but not include the joined columns. Do not forget to include the
# primary and foreign keys, otherwise it will raise an error.
# [:through]
- # Specifies a Join Model through which to perform the query. Options for <tt>:class_name</tt>
- # and <tt>:foreign_key</tt> are ignored, as the association uses the source reflection. You
- # can only use a <tt>:through</tt> query through a <tt>has_one</tt> or <tt>belongs_to</tt>
+ # Specifies a Join Model through which to perform the query. Options for <tt>:class_name</tt>
+ # and <tt>:foreign_key</tt> are ignored, as the association uses the source reflection. You
+ # can only use a <tt>:through</tt> query through a <tt>has_one</tt> or <tt>belongs_to</tt>
# association on the join model.
# [:source]
- # Specifies the source association name used by <tt>has_one :through</tt> queries.
- # Only use it if the name cannot be inferred from the association.
+ # Specifies the source association name used by <tt>has_one :through</tt> queries.
+ # Only use it if the name cannot be inferred from the association.
# <tt>has_one :favorite, :through => :favorites</tt> will look for a
# <tt>:favorite</tt> on Favorite, unless a <tt>:source</tt> is given.
# [:source_type]
@@ -1078,18 +1078,18 @@ module ActiveRecord
# [:validate]
# If +false+, don't validate the associated object when saving the parent object. +false+ by default.
# [:autosave]
- # If true, always save the associated object or destroy it if marked for destruction,
+ # If true, always save the associated object or destroy it if marked for destruction,
# when saving the parent object. If false, never save or destroy the associated object.
# By default, only save the associated object if it's a new record.
# [:inverse_of]
- # Specifies the name of the <tt>belongs_to</tt> association on the associated object
- # that is the inverse of this <tt>has_one</tt> association. Does not work in combination
+ # Specifies the name of the <tt>belongs_to</tt> association on the associated object
+ # that is the inverse of this <tt>has_one</tt> association. Does not work in combination
# with <tt>:through</tt> or <tt>:as</tt> options.
# See ActiveRecord::Associations::ClassMethods's overview on Bi-directional associations for more detail.
#
# Option examples:
# has_one :credit_card, :dependent => :destroy # destroys the associated credit card
- # has_one :credit_card, :dependent => :nullify # updates the associated records foreign
+ # has_one :credit_card, :dependent => :nullify # updates the associated records foreign
# # key value to NULL rather than destroying it
# has_one :last_comment, :class_name => "Comment", :order => "posted_on"
# has_one :project_manager, :class_name => "Person", :conditions => "role = 'project_manager'"
@@ -1152,33 +1152,33 @@ module ActiveRecord
# Specify the conditions that the associated object must meet in order to be included as a +WHERE+
# SQL fragment, such as <tt>authorized = 1</tt>.
# [:select]
- # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed
- # if, for example, you want to do a join but not include the joined columns. Do not
+ # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed
+ # if, for example, you want to do a join but not include the joined columns. Do not
# forget to include the primary and foreign keys, otherwise it will raise an error.
# [:foreign_key]
# Specify the foreign key used for the association. By default this is guessed to be the name
- # of the association with an "_id" suffix. So a class that defines a <tt>belongs_to :person</tt>
- # association will use "person_id" as the default <tt>:foreign_key</tt>. Similarly,
- # <tt>belongs_to :favorite_person, :class_name => "Person"</tt> will use a foreign key
+ # of the association with an "_id" suffix. So a class that defines a <tt>belongs_to :person</tt>
+ # association will use "person_id" as the default <tt>:foreign_key</tt>. Similarly,
+ # <tt>belongs_to :favorite_person, :class_name => "Person"</tt> will use a foreign key
# of "favorite_person_id".
# [:primary_key]
- # Specify the method that returns the primary key of associated object used for the association.
+ # Specify the method that returns the primary key of associated object used for the association.
# By default this is id.
# [:dependent]
# If set to <tt>:destroy</tt>, the associated object is destroyed when this object is. If set to
- # <tt>:delete</tt>, the associated object is deleted *without* calling its destroy method.
- # This option should not be specified when <tt>belongs_to</tt> is used in conjunction with
+ # <tt>:delete</tt>, the associated object is deleted *without* calling its destroy method.
+ # This option should not be specified when <tt>belongs_to</tt> is used in conjunction with
# a <tt>has_many</tt> relationship on another class because of the potential to leave
# orphaned records behind.
# [:counter_cache]
# Caches the number of belonging objects on the associate class through the use of +increment_counter+
- # and +decrement_counter+. The counter cache is incremented when an object of this
- # class is created and decremented when it's destroyed. This requires that a column
+ # and +decrement_counter+. The counter cache is incremented when an object of this
+ # class is created and decremented when it's destroyed. This requires that a column
# named <tt>#{table_name}_count</tt> (such as +comments_count+ for a belonging Comment class)
- # is used on the associate class (such as a Post class). You can also specify a custom counter
- # cache column by providing a column name instead of a +true+/+false+ value to this
+ # is used on the associate class (such as a Post class). You can also specify a custom counter
+ # cache column by providing a column name instead of a +true+/+false+ value to this
# option (e.g., <tt>:counter_cache => :my_custom_counter</tt>.)
- # Note: Specifying a counter cache will add it to that model's list of readonly attributes
+ # Note: Specifying a counter cache will add it to that model's list of readonly attributes
# using +attr_readonly+.
# [:include]
# Specify second-order associations that should be eager loaded when this object is loaded.
@@ -1191,17 +1191,17 @@ module ActiveRecord
# [:validate]
# If +false+, don't validate the associated objects when saving the parent object. +false+ by default.
# [:autosave]
- # If true, always save the associated object or destroy it if marked for destruction, when
+ # If true, always save the associated object or destroy it if marked for destruction, when
# saving the parent object.
# If false, never save or destroy the associated object.
# By default, only save the associated object if it's a new record.
# [:touch]
- # If true, the associated object will be touched (the updated_at/on attributes set to now)
- # when this record is either saved or destroyed. If you specify a symbol, that attribute
+ # If true, the associated object will be touched (the updated_at/on attributes set to now)
+ # when this record is either saved or destroyed. If you specify a symbol, that attribute
# will be updated with the current time instead of the updated_at/on attribute.
# [:inverse_of]
- # Specifies the name of the <tt>has_one</tt> or <tt>has_many</tt> association on the associated
- # object that is the inverse of this <tt>belongs_to</tt> association. Does not work in
+ # Specifies the name of the <tt>has_one</tt> or <tt>has_many</tt> association on the associated
+ # object that is the inverse of this <tt>belongs_to</tt> association. Does not work in
# combination with the <tt>:polymorphic</tt> options.
# See ActiveRecord::Associations::ClassMethods's overview on Bi-directional associations for more detail.
#
@@ -1236,9 +1236,9 @@ module ActiveRecord
# Specifies a many-to-many relationship with another class. This associates two classes via an
# intermediate join table. Unless the join table is explicitly specified as an option, it is
# guessed using the lexical order of the class names. So a join between Developer and Project
- # will give the default join table name of "developers_projects" because "D" outranks "P".
- # Note that this precedence is calculated using the <tt><</tt> operator for String. This
- # means that if the strings are of different lengths, and the strings are equal when compared
+ # will give the default join table name of "developers_projects" because "D" outranks "P".
+ # Note that this precedence is calculated using the <tt><</tt> operator for String. This
+ # means that if the strings are of different lengths, and the strings are equal when compared
# up to the shortest length, then the longer string is considered of higher
# lexical precedence than the shorter one. For example, one would expect the tables "paper_boxes" and "papers"
# to generate a join table name of "papers_paper_boxes" because of the length of the name "paper_boxes",
@@ -1261,9 +1261,9 @@ module ActiveRecord
# end
# end
#
- # Deprecated: Any additional fields added to the join table will be placed as attributes when
- # pulling records out through +has_and_belongs_to_many+ associations. Records returned from join
- # tables with additional attributes will be marked as readonly (because we can't save changes
+ # Deprecated: Any additional fields added to the join table will be placed as attributes when
+ # pulling records out through +has_and_belongs_to_many+ associations. Records returned from join
+ # tables with additional attributes will be marked as readonly (because we can't save changes
# to the additional attributes). It's strongly recommended that you upgrade any
# associations with attributes to a real join model (see introduction).
#
@@ -1275,7 +1275,7 @@ module ActiveRecord
# [collection<<(object, ...)]
# Adds one or more objects to the collection by creating associations in the join table
# (<tt>collection.push</tt> and <tt>collection.concat</tt> are aliases to this method).
- # Note that this operation instantly fires update sql without waiting for the save or update call on the
+ # Note that this operation instantly fires update sql without waiting for the save or update call on the
# parent object.
# [collection.delete(object, ...)]
# Removes one or more objects from the collection by removing their associations from the join table.
@@ -1304,7 +1304,7 @@ module ActiveRecord
# with +attributes+ and linked to this object through the join table, but has not yet been saved.
# [collection.create(attributes = {})]
# Returns a new object of the collection type that has been instantiated
- # with +attributes+, linked to this object through the join table, and that has already been
+ # with +attributes+, linked to this object through the join table, and that has already been
# saved (if it passed the validation).
#
# (+collection+ is replaced with the symbol passed as the first argument, so
@@ -1340,8 +1340,8 @@ module ActiveRecord
# MUST be declared underneath any +has_and_belongs_to_many+ declaration in order to work.
# [:foreign_key]
# Specify the foreign key used for the association. By default this is guessed to be the name
- # of this class in lower-case and "_id" suffixed. So a Person class that makes
- # a +has_and_belongs_to_many+ association to Project will use "person_id" as the
+ # of this class in lower-case and "_id" suffixed. So a Person class that makes
+ # a +has_and_belongs_to_many+ association to Project will use "person_id" as the
# default <tt>:foreign_key</tt>.
# [:association_foreign_key]
# Specify the foreign key used for the association on the receiving side of the association.
@@ -1350,7 +1350,7 @@ module ActiveRecord
# the association will use "project_id" as the default <tt>:association_foreign_key</tt>.
# [:conditions]
# Specify the conditions that the associated object must meet in order to be included as a +WHERE+
- # SQL fragment, such as <tt>authorized = 1</tt>. Record creations from the association are
+ # SQL fragment, such as <tt>authorized = 1</tt>. Record creations from the association are
# scoped if a hash is used.
# <tt>has_many :posts, :conditions => {:published => true}</tt> will create published posts with <tt>@blog.posts.create</tt>
# or <tt>@blog.posts.build</tt>.
@@ -1363,7 +1363,7 @@ module ActiveRecord
# Overwrite the default generated SQL statement used to fetch the association with a manual statement
# [:counter_sql]
# Specify a complete SQL statement to fetch the size of the association. If <tt>:finder_sql</tt> is
- # specified but not <tt>:counter_sql</tt>, <tt>:counter_sql</tt> will be generated by
+ # specified but not <tt>:counter_sql</tt>, <tt>:counter_sql</tt> will be generated by
# replacing <tt>SELECT ... FROM</tt> with <tt>SELECT COUNT(*) FROM</tt>.
# [:delete_sql]
# Overwrite the default generated SQL statement used to remove links between the associated
@@ -1378,23 +1378,23 @@ module ActiveRecord
# [:group]
# An attribute name by which the result should be grouped. Uses the <tt>GROUP BY</tt> SQL-clause.
# [:having]
- # Combined with +:group+ this can be used to filter the records that a <tt>GROUP BY</tt> returns.
+ # Combined with +:group+ this can be used to filter the records that a <tt>GROUP BY</tt> returns.
# Uses the <tt>HAVING</tt> SQL-clause.
# [:limit]
# An integer determining the limit on the number of rows that should be returned.
# [:offset]
- # An integer determining the offset from where the rows should be fetched. So at 5,
+ # An integer determining the offset from where the rows should be fetched. So at 5,
# it would skip the first 4 rows.
# [:select]
- # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if, for example,
- # you want to do a join but not include the joined columns. Do not forget to include the primary
+ # By default, this is <tt>*</tt> as in <tt>SELECT * FROM</tt>, but can be changed if, for example,
+ # you want to do a join but not include the joined columns. Do not forget to include the primary
# and foreign keys, otherwise it will raise an error.
# [:readonly]
# If true, all the associated objects are readonly through the association.
# [:validate]
# If +false+, don't validate the associated objects when saving the parent object. +true+ by default.
# [:autosave]
- # If true, always save the associated objects or destroy them if marked for destruction, when
+ # If true, always save the associated objects or destroy them if marked for destruction, when
# saving the parent object.
# If false, never save or destroy the associated objects.
# By default, only save associated objects that are new records.
@@ -1463,7 +1463,7 @@ module ActiveRecord
association = association_instance_get(reflection.name)
association && association.loaded?
end
-
+
redefine_method("#{reflection.name}=") do |new_value|
association = association_instance_get(reflection.name)
@@ -1474,7 +1474,7 @@ module ActiveRecord
association.replace(new_value)
association_instance_set(reflection.name, new_value.nil? ? nil : association)
end
-
+
redefine_method("set_#{reflection.name}_target") do |target|
return if target.nil? and association_proxy_class == BelongsToAssociation
association = association_proxy_class.new(self, reflection)
@@ -1597,7 +1597,7 @@ module ActiveRecord
# See HasManyAssociation#delete_records for more information. In general
# - delete children if the option is set to :destroy or :delete_all
# - set the foreign key to NULL if the option is set to :nullify
- # - do not delete the parent record if there is any child record if the
+ # - do not delete the parent record if there is any child record if the
# option is set to :restrict
#
# The +extra_conditions+ parameter, which is not used within the main
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
index 4f9bd8f679..862a19587d 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -106,9 +106,9 @@ module ActiveRecord
:limit => @reflection.options[:limit] } }
end
- # Join tables with additional columns on top of the two foreign keys must be considered
- # ambiguous unless a select clause has been explicitly defined. Otherwise you can get
- # broken records back, if, for example, the join column also has an id column. This will
+ # Join tables with additional columns on top of the two foreign keys must be considered
+ # ambiguous unless a select clause has been explicitly defined. Otherwise you can get
+ # broken records back, if, for example, the join column also has an id column. This will
# then overwrite the id column of the records coming back.
def finding_with_ambiguous_select?(select_clause)
!select_clause && columns.size != 2
diff --git a/activerecord/lib/active_record/associations/has_many_association.rb b/activerecord/lib/active_record/associations/has_many_association.rb
index ccc01d2b57..978fc74560 100644
--- a/activerecord/lib/active_record/associations/has_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_association.rb
@@ -110,10 +110,10 @@ module ActiveRecord
create_scoping = {}
set_belongs_to_association_for(create_scoping)
{
- :find => { :conditions => @finder_sql,
- :readonly => false,
- :order => @reflection.options[:order],
- :limit => @reflection.options[:limit],
+ :find => { :conditions => @finder_sql,
+ :readonly => false,
+ :order => @reflection.options[:order],
+ :limit => @reflection.options[:limit],
:include => @reflection.options[:include]},
:create => create_scoping
}
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb
index 608b1c741a..97883d8393 100644
--- a/activerecord/lib/active_record/associations/has_many_through_association.rb
+++ b/activerecord/lib/active_record/associations/has_many_through_association.rb
@@ -24,9 +24,9 @@ module ActiveRecord
end
end
- # Returns the size of the collection by executing a SELECT COUNT(*) query if the collection hasn't been
- # loaded and calling collection.size if it has. If it's more likely than not that the collection does
- # have a size larger than zero, and you need to fetch that collection afterwards, it'll take one fewer
+ # Returns the size of the collection by executing a SELECT COUNT(*) query if the collection hasn't been
+ # loaded and calling collection.size if it has. If it's more likely than not that the collection does
+ # have a size larger than zero, and you need to fetch that collection afterwards, it'll take one fewer
# SELECT query if you use #length.
def size
return @owner.send(:read_attribute, cached_counter_attribute_name) if has_cached_counter?
diff --git a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
index 8f0aacba42..a258b3f431 100644
--- a/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
+++ b/activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
@@ -14,7 +14,7 @@ module ActiveRecord
module ClassMethods
protected
# Defined for all +datetime+ and +timestamp+ attributes when +time_zone_aware_attributes+ are enabled.
- # This enhanced read method automatically converts the UTC time stored in the database to the time
+ # This enhanced read method automatically converts the UTC time stored in the database to the time
# zone stored in Time.zone.
def define_method_attribute(attr_name)
if create_time_zone_conversion_attribute?(attr_name, columns_hash[attr_name])
diff --git a/activerecord/lib/active_record/attribute_methods/write.rb b/activerecord/lib/active_record/attribute_methods/write.rb
index 7a2de3bf80..6a593a7e0e 100644
--- a/activerecord/lib/active_record/attribute_methods/write.rb
+++ b/activerecord/lib/active_record/attribute_methods/write.rb
@@ -14,7 +14,7 @@ module ActiveRecord
end
end
- # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+. Empty strings
+ # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+. Empty strings
# for fixnum and float columns are turned into +nil+.
def write_attribute(attr_name, value)
attr_name = attr_name.to_s
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index 5a35dc2a3b..21a9a1f2cb 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -2,7 +2,7 @@ require 'active_support/core_ext/array/wrap'
module ActiveRecord
# = Active Record Autosave Association
- #
+ #
# +AutosaveAssociation+ is a module that takes care of automatically saving
# associacted records when their parent is saved. In addition to saving, it
# also destroys any associated records that were marked for destruction.
@@ -79,7 +79,7 @@ module ActiveRecord
# post = Post.create(:title => 'ruby rocks')
# post.comments.create(:body => 'hello world')
# post.save # => saves both post and comment
- #
+ #
# When <tt>:autosave</tt> is true all children is saved, no matter whether they are new records:
#
# class Post
@@ -190,7 +190,7 @@ module ActiveRecord
end
# Marks this record to be destroyed as part of the parents save transaction.
- # This does _not_ actually destroy the record instantly, rather child record will be destroyed
+ # This does _not_ actually destroy the record instantly, rather child record will be destroyed
# when <tt>parent.save</tt> is called.
#
# Only useful if the <tt>:autosave</tt> option on the parent is enabled for this associated model.
@@ -210,7 +210,7 @@ module ActiveRecord
def changed_for_autosave?
new_record? || changed? || marked_for_destruction? || nested_records_changed_for_autosave?
end
-
+
private
# Returns the record for an association collection that should be validated
@@ -234,7 +234,7 @@ module ActiveRecord
association && Array.wrap(association.target).any? { |a| a.changed_for_autosave? }
end
end
-
+
# Validate the association if <tt>:validate</tt> or <tt>:autosave</tt> is
# turned on for the association.
def validate_single_association(reflection)
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 15af7b4376..9d3ee9528a 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -26,9 +26,9 @@ require 'active_record/log_subscriber'
module ActiveRecord #:nodoc:
# = Active Record
#
- # Active Record objects don't specify their attributes directly, but rather infer them from
- # the table definition with which they're linked. Adding, removing, and changing attributes
- # and their type is done directly in the database. Any change is instantly reflected in the
+ # Active Record objects don't specify their attributes directly, but rather infer them from
+ # the table definition with which they're linked. Adding, removing, and changing attributes
+ # and their type is done directly in the database. Any change is instantly reflected in the
# Active Record objects. The mapping that binds a given Active Record class to a certain
# database table will happen automatically in most common cases, but can be overwritten for the uncommon ones.
#
@@ -36,8 +36,8 @@ module ActiveRecord #:nodoc:
#
# == Creation
#
- # Active Records accept constructor parameters either in a hash or as a block. The hash
- # method is especially useful when you're receiving the data from somewhere else, like an
+ # Active Records accept constructor parameters either in a hash or as a block. The hash
+ # method is especially useful when you're receiving the data from somewhere else, like an
# HTTP request. It works like this:
#
# user = User.new(:name => "David", :occupation => "Code Artist")
@@ -77,16 +77,16 @@ module ActiveRecord #:nodoc:
# end
# end
#
- # The <tt>authenticate_unsafely</tt> method inserts the parameters directly into the query
- # and is thus susceptible to SQL-injection attacks if the <tt>user_name</tt> and +password+
+ # The <tt>authenticate_unsafely</tt> method inserts the parameters directly into the query
+ # and is thus susceptible to SQL-injection attacks if the <tt>user_name</tt> and +password+
# parameters come directly from an HTTP request. The <tt>authenticate_safely</tt> and
- # <tt>authenticate_safely_simply</tt> both will sanitize the <tt>user_name</tt> and +password+
- # before inserting them in the query, which will ensure that an attacker can't escape the
+ # <tt>authenticate_safely_simply</tt> both will sanitize the <tt>user_name</tt> and +password+
+ # before inserting them in the query, which will ensure that an attacker can't escape the
# query and fake the login (or worse).
#
- # When using multiple parameters in the conditions, it can easily become hard to read exactly
- # what the fourth or fifth question mark is supposed to represent. In those cases, you can
- # resort to named bind variables instead. That's done by replacing the question marks with
+ # When using multiple parameters in the conditions, it can easily become hard to read exactly
+ # what the fourth or fifth question mark is supposed to represent. In those cases, you can
+ # resort to named bind variables instead. That's done by replacing the question marks with
# symbols and supplying a hash with values for the matching symbol keys:
#
# Company.where(
@@ -108,7 +108,7 @@ module ActiveRecord #:nodoc:
#
# Student.where(:grade => [9,11,12])
#
- # When joining tables, nested hashes or keys written in the form 'table_name.column_name'
+ # When joining tables, nested hashes or keys written in the form 'table_name.column_name'
# can be used to qualify the table name of a particular condition. For instance:
#
# Student.joins(:schools).where(:schools => { :type => 'public' })
@@ -116,10 +116,10 @@ module ActiveRecord #:nodoc:
#
# == Overwriting default accessors
#
- # All column values are automatically available through basic accessors on the Active Record
- # object, but sometimes you want to specialize this behavior. This can be done by overwriting
- # the default accessors (using the same name as the attribute) and calling
- # <tt>read_attribute(attr_name)</tt> and <tt>write_attribute(attr_name, value)</tt> to actually
+ # All column values are automatically available through basic accessors on the Active Record
+ # object, but sometimes you want to specialize this behavior. This can be done by overwriting
+ # the default accessors (using the same name as the attribute) and calling
+ # <tt>read_attribute(attr_name)</tt> and <tt>write_attribute(attr_name, value)</tt> to actually
# change things.
#
# class Song < ActiveRecord::Base
@@ -134,7 +134,7 @@ module ActiveRecord #:nodoc:
# end
# end
#
- # You can alternatively use <tt>self[:attribute]=(value)</tt> and <tt>self[:attribute]</tt>
+ # You can alternatively use <tt>self[:attribute]=(value)</tt> and <tt>self[:attribute]</tt>
# instead of <tt>write_attribute(:attribute, value)</tt> and <tt>read_attribute(:attribute)</tt>.
#
# == Attribute query methods
@@ -153,31 +153,31 @@ module ActiveRecord #:nodoc:
#
# == Accessing attributes before they have been typecasted
#
- # Sometimes you want to be able to read the raw attribute data without having the column-determined
- # typecast run its course first. That can be done by using the <tt><attribute>_before_type_cast</tt>
- # accessors that all attributes have. For example, if your Account model has a <tt>balance</tt> attribute,
+ # Sometimes you want to be able to read the raw attribute data without having the column-determined
+ # typecast run its course first. That can be done by using the <tt><attribute>_before_type_cast</tt>
+ # accessors that all attributes have. For example, if your Account model has a <tt>balance</tt> attribute,
# you can call <tt>account.balance_before_type_cast</tt> or <tt>account.id_before_type_cast</tt>.
#
- # This is especially useful in validation situations where the user might supply a string for an
- # integer field and you want to display the original string back in an error message. Accessing the
+ # This is especially useful in validation situations where the user might supply a string for an
+ # integer field and you want to display the original string back in an error message. Accessing the
# attribute normally would typecast the string to 0, which isn't what you want.
#
# == Dynamic attribute-based finders
#
- # Dynamic attribute-based finders are a cleaner way of getting (and/or creating) objects
- # by simple queries without turning to SQL. They work by appending the name of an attribute
- # to <tt>find_by_</tt>, <tt>find_last_by_</tt>, or <tt>find_all_by_</tt> and thus produces finders
- # like <tt>Person.find_by_user_name</tt>, <tt>Person.find_all_by_last_name</tt>, and
- # <tt>Payment.find_by_transaction_id</tt>. Instead of writing
+ # Dynamic attribute-based finders are a cleaner way of getting (and/or creating) objects
+ # by simple queries without turning to SQL. They work by appending the name of an attribute
+ # to <tt>find_by_</tt>, <tt>find_last_by_</tt>, or <tt>find_all_by_</tt> and thus produces finders
+ # like <tt>Person.find_by_user_name</tt>, <tt>Person.find_all_by_last_name</tt>, and
+ # <tt>Payment.find_by_transaction_id</tt>. Instead of writing
# <tt>Person.where(:user_name => user_name).first</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>.
- # And instead of writing <tt>Person.where(:last_name => last_name).all</tt>, you just do
+ # And instead of writing <tt>Person.where(:last_name => last_name).all</tt>, you just do
# <tt>Person.find_all_by_last_name(last_name)</tt>.
#
# It's also possible to use multiple attributes in the same find by separating them with "_and_".
- #
+ #
# Person.where(:user_name => user_name, :password => password).first
# Person.find_by_user_name_and_password #with dynamic finder
- #
+ #
# Person.where(:user_name => user_name, :password => password, :gender => 'male').first
# Payment.find_by_user_name_and_password_and_gender
#
@@ -186,10 +186,10 @@ module ActiveRecord #:nodoc:
# Payment.order("created_on").find_all_by_amount(50)
# Payment.pending.find_last_by_amount(100)
#
- # The same dynamic finder style can be used to create the object if it doesn't already exist.
- # This dynamic finder is called with <tt>find_or_create_by_</tt> and will return the object if
- # it already exists and otherwise creates it, then returns it. Protected attributes won't be set
- # unless they are given in a block.
+ # The same dynamic finder style can be used to create the object if it doesn't already exist.
+ # This dynamic finder is called with <tt>find_or_create_by_</tt> and will return the object if
+ # it already exists and otherwise creates it, then returns it. Protected attributes won't be set
+ # unless they are given in a block.
#
# # No 'Summer' tag exists
# Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer")
@@ -200,7 +200,7 @@ module ActiveRecord #:nodoc:
# # Now 'Bob' exist and is an 'admin'
# User.find_or_create_by_name('Bob', :age => 40) { |u| u.admin = true }
#
- # Use the <tt>find_or_initialize_by_</tt> finder if you want to return a new record without
+ # Use the <tt>find_or_initialize_by_</tt> finder if you want to return a new record without
# saving it first. Protected attributes won't be set unless they are given in a block.
#
# # No 'Winter' tag exists
@@ -212,21 +212,21 @@ module ActiveRecord #:nodoc:
#
# Tag.find_or_create_by_name(:name => "rails", :creator => current_user)
#
- # That will either find an existing tag named "rails", or create a new one while setting the
+ # That will either find an existing tag named "rails", or create a new one while setting the
# user that created it.
#
# Just like <tt>find_by_*</tt>, you can also use <tt>scoped_by_*</tt> to retrieve data. The good thing about
# using this feature is that the very first time result is returned using <tt>method_missing</tt> technique
# but after that the method is declared on the class. Henceforth <tt>method_missing</tt> will not be hit.
#
- # User.scoped_by_user_name('David')
+ # User.scoped_by_user_name('David')
#
# == Saving arrays, hashes, and other non-mappable objects in text columns
#
- # Active Record can serialize any object in text columns using YAML. To do so, you must
+ # Active Record can serialize any object in text columns using YAML. To do so, you must
# specify this with a call to the class method +serialize+.
- # This makes it possible to store arrays, hashes, and other non-mappable objects without doing
- # any additional work.
+ # This makes it possible to store arrays, hashes, and other non-mappable objects without doing
+ # any additional work.
#
# class User < ActiveRecord::Base
# serialize :preferences
@@ -235,7 +235,7 @@ module ActiveRecord #:nodoc:
# user = User.create(:preferences => { "background" => "black", "display" => large })
# User.find(user.id).preferences # => { "background" => "black", "display" => large }
#
- # You can also specify a class option as the second parameter that'll raise an exception
+ # You can also specify a class option as the second parameter that'll raise an exception
# if a serialized object is retrieved as a descendant of a class not in the hierarchy.
#
# class User < ActiveRecord::Base
@@ -247,8 +247,8 @@ module ActiveRecord #:nodoc:
#
# == Single table inheritance
#
- # Active Record allows inheritance by storing the name of the class in a column that by
- # default is named "type" (can be changed by overwriting <tt>Base.inheritance_column</tt>).
+ # Active Record allows inheritance by storing the name of the class in a column that by
+ # default is named "type" (can be changed by overwriting <tt>Base.inheritance_column</tt>).
# This means that an inheritance looking like this:
#
# class Company < ActiveRecord::Base; end
@@ -256,12 +256,12 @@ module ActiveRecord #:nodoc:
# class Client < Company; end
# class PriorityClient < Client; end
#
- # When you do <tt>Firm.create(:name => "37signals")</tt>, this record will be saved in
- # the companies table with type = "Firm". You can then fetch this row again using
+ # When you do <tt>Firm.create(:name => "37signals")</tt>, this record will be saved in
+ # the companies table with type = "Firm". You can then fetch this row again using
# <tt>Company.where(:name => '37signals').first</tt> and it will return a Firm object.
#
- # If you don't have a type column defined in your table, single-table inheritance won't
- # be triggered. In that case, it'll work just like normal subclasses with no special magic
+ # If you don't have a type column defined in your table, single-table inheritance won't
+ # be triggered. In that case, it'll work just like normal subclasses with no special magic
# for differentiating between them or reloading the right type with find.
#
# Note, all the attributes for all the cases are kept in the same table. Read more:
@@ -269,14 +269,14 @@ module ActiveRecord #:nodoc:
#
# == Connection to multiple databases in different models
#
- # Connections are usually created through ActiveRecord::Base.establish_connection and retrieved
- # by ActiveRecord::Base.connection. All classes inheriting from ActiveRecord::Base will use this
- # connection. But you can also set a class-specific connection. For example, if Course is an
+ # Connections are usually created through ActiveRecord::Base.establish_connection and retrieved
+ # by ActiveRecord::Base.connection. All classes inheriting from ActiveRecord::Base will use this
+ # connection. But you can also set a class-specific connection. For example, if Course is an
# ActiveRecord::Base, but resides in a different database, you can just say <tt>Course.establish_connection</tt>
# and Course and all of its subclasses will use this connection instead.
#
- # This feature is implemented by keeping a connection pool in ActiveRecord::Base that is
- # a Hash indexed by the class. If a connection is requested, the retrieve_connection method
+ # This feature is implemented by keeping a connection pool in ActiveRecord::Base that is
+ # a Hash indexed by the class. If a connection is requested, the retrieve_connection method
# will go up the class-hierarchy until a connection is found in the connection pool.
#
# == Exceptions
@@ -284,25 +284,25 @@ module ActiveRecord #:nodoc:
# * ActiveRecordError - Generic error class and superclass of all other errors raised by Active Record.
# * AdapterNotSpecified - The configuration hash used in <tt>establish_connection</tt> didn't include an
# <tt>:adapter</tt> key.
- # * AdapterNotFound - The <tt>:adapter</tt> key used in <tt>establish_connection</tt> specified a
+ # * AdapterNotFound - The <tt>:adapter</tt> key used in <tt>establish_connection</tt> specified a
# non-existent adapter
# (or a bad spelling of an existing one).
- # * AssociationTypeMismatch - The object assigned to the association wasn't of the type
+ # * AssociationTypeMismatch - The object assigned to the association wasn't of the type
# specified in the association definition.
# * SerializationTypeMismatch - The serialized object wasn't of the class specified as the second parameter.
- # * ConnectionNotEstablished+ - No connection has been established. Use <tt>establish_connection</tt>
+ # * ConnectionNotEstablished+ - No connection has been established. Use <tt>establish_connection</tt>
# before querying.
# * RecordNotFound - No record responded to the +find+ method. Either the row with the given ID doesn't exist
# or the row didn't meet the additional restrictions. Some +find+ calls do not raise this exception to signal
# nothing was found, please check its documentation for further details.
# * StatementInvalid - The database server rejected the SQL statement. The precise error is added in the message.
# * MultiparameterAssignmentErrors - Collection of errors that occurred during a mass assignment using the
- # <tt>attributes=</tt> method. The +errors+ property of this exception contains an array of
+ # <tt>attributes=</tt> method. The +errors+ property of this exception contains an array of
# AttributeAssignmentError
# objects that should be inspected to determine which attributes triggered the errors.
- # * AttributeAssignmentError - An error occurred while doing a mass assignment through the
+ # * AttributeAssignmentError - An error occurred while doing a mass assignment through the
# <tt>attributes=</tt> method.
- # You can inspect the +attribute+ property of the exception object to determine which attribute
+ # You can inspect the +attribute+ property of the exception object to determine which attribute
# triggered the error.
#
# *Note*: The attributes listed are class-level attributes (accessible from both the class and instance level).
@@ -311,8 +311,8 @@ module ActiveRecord #:nodoc:
class Base
##
# :singleton-method:
- # Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class,
- # which is then passed on to any new database connections made and which can be retrieved on both
+ # Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class,
+ # which is then passed on to any new database connections made and which can be retrieved on both
# a class and instance level by calling +logger+.
cattr_accessor :logger, :instance_writer => false
@@ -360,9 +360,9 @@ module ActiveRecord #:nodoc:
##
# :singleton-method:
- # Accessor for the prefix type that will be prepended to every primary key column name.
- # The options are :table_name and :table_name_with_underscore. If the first is specified,
- # the Product class will look for "productid" instead of "id" as the primary column. If the
+ # Accessor for the prefix type that will be prepended to every primary key column name.
+ # The options are :table_name and :table_name_with_underscore. If the first is specified,
+ # the Product class will look for "productid" instead of "id" as the primary column. If the
# latter is specified, the Product class will look for "product_id" instead of "id". Remember
# that this is a global setting for all Active Records.
cattr_accessor :primary_key_prefix_type, :instance_writer => false
@@ -370,13 +370,13 @@ module ActiveRecord #:nodoc:
##
# :singleton-method:
- # Accessor for the name of the prefix string to prepend to every table name. So if set
- # to "basecamp_", all table names will be named like "basecamp_projects", "basecamp_people",
- # etc. This is a convenient way of creating a namespace for tables in a shared database.
+ # Accessor for the name of the prefix string to prepend to every table name. So if set
+ # to "basecamp_", all table names will be named like "basecamp_projects", "basecamp_people",
+ # etc. This is a convenient way of creating a namespace for tables in a shared database.
# By default, the prefix is the empty string.
#
- # If you are organising your models within modules you can add a prefix to the models within
- # a namespace by defining a singleton method in the parent module called table_name_prefix which
+ # If you are organising your models within modules you can add a prefix to the models within
+ # a namespace by defining a singleton method in the parent module called table_name_prefix which
# returns your chosen prefix.
class_attribute :table_name_prefix, :instance_writer => false
self.table_name_prefix = ""
@@ -398,7 +398,7 @@ module ActiveRecord #:nodoc:
##
# :singleton-method:
- # Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling
+ # Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling
# dates and times from the database. This is set to :local by default.
cattr_accessor :default_timezone, :instance_writer => false
@@default_timezone = :local
@@ -546,17 +546,17 @@ module ActiveRecord #:nodoc:
serialized_attributes[attr_name.to_s] = class_name
end
- # Returns a hash of all the attributes that have been specified for serialization as
+ # Returns a hash of all the attributes that have been specified for serialization as
# keys and their class restriction as values.
def serialized_attributes
read_inheritable_attribute(:attr_serialized) or write_inheritable_attribute(:attr_serialized, {})
end
- # Guesses the table name (in forced lower-case) based on the name of the class in the
- # inheritance hierarchy descending directly from ActiveRecord::Base. So if the hierarchy
+ # Guesses the table name (in forced lower-case) based on the name of the class in the
+ # inheritance hierarchy descending directly from ActiveRecord::Base. So if the hierarchy
# looks like: Reply < Message < ActiveRecord::Base, then Message is used
- # to guess the table name even when called on Reply. The rules used to do the guess
- # are handled by the Inflector class in Active Support, which knows almost all common
+ # to guess the table name even when called on Reply. The rules used to do the guess
+ # are handled by the Inflector class in Active Support, which knows almost all common
# English inflections. You can add new inflections in config/initializers/inflections.rb.
#
# Nested classes are given table names prefixed by the singular form of
@@ -605,7 +605,7 @@ module ActiveRecord #:nodoc:
(parents.detect{ |p| p.respond_to?(:table_name_prefix) } || self).table_name_prefix
end
- # Defines the column name for use with single table inheritance. Use
+ # Defines the column name for use with single table inheritance. Use
# <tt>set_inheritance_column</tt> to set a different value.
def inheritance_column
@inheritance_column ||= "type".freeze
@@ -623,7 +623,7 @@ module ActiveRecord #:nodoc:
default
end
- # Sets the table name. If the value is nil or false then the value returned by the given
+ # Sets the table name. If the value is nil or false then the value returned by the given
# block is used.
#
# class Project < ActiveRecord::Base
@@ -967,14 +967,14 @@ module ActiveRecord #:nodoc:
end
end
- # Enables dynamic finders like <tt>User.find_by_user_name(user_name)</tt> and
+ # Enables dynamic finders like <tt>User.find_by_user_name(user_name)</tt> and
# <tt>User.scoped_by_user_name(user_name). Refer to Dynamic attribute-based finders
# section at the top of this file for more detailed information.
#
- # It's even possible to use all the additional parameters to +find+. For example, the
+ # It's even possible to use all the additional parameters to +find+. For example, the
# full interface for +find_all_by_amount+ is actually <tt>find_all_by_amount(amount, options)</tt>.
#
- # Each dynamic finder using <tt>scoped_by_*</tt> is also defined in the class after it
+ # Each dynamic finder using <tt>scoped_by_*</tt> is also defined in the class after it
# is first invoked, so that future attempts to use it do not run through method_missing.
def method_missing(method_id, *arguments, &block)
if match = DynamicFinderMatch.match(method_id)
@@ -1155,8 +1155,8 @@ MSG
# default_scope where(:published => true)
# end
#
- # Article.new.published # => true
- # Article.create.published # => true
+ # Article.new.published # => true
+ # Article.create.published # => true
def default_scope(options = {})
self.default_scoping << construct_finder_arel(options, default_scoping.pop)
end
@@ -1660,10 +1660,10 @@ MSG
private
- # Sets the attribute used for single table inheritance to this class name if this is not the
+ # Sets the attribute used for single table inheritance to this class name if this is not the
# ActiveRecord::Base descendant.
- # Considering the hierarchy Reply < Message < ActiveRecord::Base, this makes it possible to
- # do Reply.new without having to set <tt>Reply[Reply.inheritance_column] = "Reply"</tt> yourself.
+ # Considering the hierarchy Reply < Message < ActiveRecord::Base, this makes it possible to
+ # do Reply.new without having to set <tt>Reply[Reply.inheritance_column] = "Reply"</tt> yourself.
# No such attribute would be set for objects of the Message class in that example.
def ensure_proper_type
unless self.class.descends_from_active_record?
@@ -1713,8 +1713,8 @@ MSG
# by calling new on the column type or aggregation type (through composed_of) object with these parameters.
# So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate
# written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the
- # parentheses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum,
- # f for Float, s for String, and a for Array. If all the values for a given attribute are empty, the
+ # parentheses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum,
+ # f for Float, s for String, and a for Array. If all the values for a given attribute are empty, the
# attribute will be set to nil.
def assign_multiparameter_attributes(pairs)
execute_callstack_for_multiparameter_attributes(
diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb
index aa92bf999f..c203581735 100644
--- a/activerecord/lib/active_record/callbacks.rb
+++ b/activerecord/lib/active_record/callbacks.rb
@@ -2,7 +2,7 @@ require 'active_support/core_ext/array/wrap'
module ActiveRecord
# = Active Record Callbacks
- #
+ #
# Callbacks are hooks into the lifecycle of an Active Record object that allow you to trigger logic
# before or after an alteration of the object state. This can be used to make sure that associated and
# dependent objects are deleted when +destroy+ is called (by overwriting +before_destroy+) or to massage attributes
@@ -26,7 +26,7 @@ module ActiveRecord
# <tt>after_rollback</tt>.
#
# That's a total of ten callbacks, which gives you immense power to react and prepare for each state in the
- # Active Record lifecycle. The sequence for calling <tt>Base#save</tt> for an existing record is similar,
+ # Active Record lifecycle. The sequence for calling <tt>Base#save</tt> for an existing record is similar,
# except that each <tt>_on_create</tt> callback is replaced by the corresponding <tt>_on_update</tt> callback.
#
# Examples:
@@ -55,8 +55,8 @@ module ActiveRecord
#
# == Inheritable callback queues
#
- # Besides the overwritable callback methods, it's also possible to register callbacks through the
- # use of the callback macros. Their main advantage is that the macros add behavior into a callback
+ # Besides the overwritable callback methods, it's also possible to register callbacks through the
+ # use of the callback macros. Their main advantage is that the macros add behavior into a callback
# queue that is kept intact down through an inheritance hierarchy.
#
# class Topic < ActiveRecord::Base
@@ -67,8 +67,8 @@ module ActiveRecord
# before_destroy :destroy_readers
# end
#
- # Now, when <tt>Topic#destroy</tt> is run only +destroy_author+ is called. When <tt>Reply#destroy</tt> is
- # run, both +destroy_author+ and +destroy_readers+ are called. Contrast this to the following situation
+ # Now, when <tt>Topic#destroy</tt> is run only +destroy_author+ is called. When <tt>Reply#destroy</tt> is
+ # run, both +destroy_author+ and +destroy_readers+ are called. Contrast this to the following situation
# where the +before_destroy+ methis is overriden:
#
# class Topic < ActiveRecord::Base
@@ -79,20 +79,20 @@ module ActiveRecord
# def before_destroy() destroy_readers end
# end
#
- # In that case, <tt>Reply#destroy</tt> would only run +destroy_readers+ and _not_ +destroy_author+.
- # So, use the callback macros when you want to ensure that a certain callback is called for the entire
- # hierarchy, and use the regular overwriteable methods when you want to leave it up to each descendant
+ # In that case, <tt>Reply#destroy</tt> would only run +destroy_readers+ and _not_ +destroy_author+.
+ # So, use the callback macros when you want to ensure that a certain callback is called for the entire
+ # hierarchy, and use the regular overwriteable methods when you want to leave it up to each descendant
# to decide whether they want to call +super+ and trigger the inherited callbacks.
#
- # *IMPORTANT:* In order for inheritance to work for the callback queues, you must specify the
- # callbacks before specifying the associations. Otherwise, you might trigger the loading of a
+ # *IMPORTANT:* In order for inheritance to work for the callback queues, you must specify the
+ # callbacks before specifying the associations. Otherwise, you might trigger the loading of a
# child before the parent has registered the callbacks and they won't be inherited.
#
# == Types of callbacks
#
# There are four types of callbacks accepted by the callback macros: Method references (symbol), callback objects,
- # inline methods (using a proc), and inline eval methods (using a string). Method references and callback objects
- # are the recommended approaches, inline methods using a proc are sometimes appropriate (such as for
+ # inline methods (using a proc), and inline eval methods (using a string). Method references and callback objects
+ # are the recommended approaches, inline methods using a proc are sometimes appropriate (such as for
# creating mix-ins), and inline eval methods are deprecated.
#
# The method reference callbacks work by specifying a protected or private method available in the object, like this:
@@ -170,14 +170,14 @@ module ActiveRecord
# end
# end
#
- # The callback macros usually accept a symbol for the method they're supposed to run, but you can also
+ # The callback macros usually accept a symbol for the method they're supposed to run, but you can also
# pass a "method string", which will then be evaluated within the binding of the callback. Example:
#
# class Topic < ActiveRecord::Base
# before_destroy 'self.class.delete_all "parent_id = #{id}"'
# end
#
- # Notice that single quotes (') are used so the <tt>#{id}</tt> part isn't evaluated until the callback
+ # Notice that single quotes (') are used so the <tt>#{id}</tt> part isn't evaluated until the callback
# is triggered. Also note that these inline callbacks can be stacked just like the regular ones:
#
# class Topic < ActiveRecord::Base
@@ -187,23 +187,23 @@ module ActiveRecord
#
# == The +after_find+ and +after_initialize+ exceptions
#
- # Because +after_find+ and +after_initialize+ are called for each object found and instantiated by a finder,
- # such as <tt>Base.find(:all)</tt>, we've had to implement a simple performance constraint (50% more speed
- # on a simple test case). Unlike all the other callbacks, +after_find+ and +after_initialize+ will only be
+ # Because +after_find+ and +after_initialize+ are called for each object found and instantiated by a finder,
+ # such as <tt>Base.find(:all)</tt>, we've had to implement a simple performance constraint (50% more speed
+ # on a simple test case). Unlike all the other callbacks, +after_find+ and +after_initialize+ will only be
# run if an explicit implementation is defined (<tt>def after_find</tt>). In that case, all of the
# callback types will be called.
#
# == <tt>before_validation*</tt> returning statements
#
- # If the returning value of a +before_validation+ callback can be evaluated to +false+, the process will be
- # aborted and <tt>Base#save</tt> will return +false+. If Base#save! is called it will raise a
+ # If the returning value of a +before_validation+ callback can be evaluated to +false+, the process will be
+ # aborted and <tt>Base#save</tt> will return +false+. If Base#save! is called it will raise a
# ActiveRecord::RecordInvalid exception. Nothing will be appended to the errors object.
#
# == Canceling callbacks
#
- # If a <tt>before_*</tt> callback returns +false+, all the later callbacks and the associated action are
- # cancelled. If an <tt>after_*</tt> callback returns +false+, all the later callbacks are cancelled.
- # Callbacks are generally run in the order they are defined, with the exception of callbacks defined as
+ # If a <tt>before_*</tt> callback returns +false+, all the later callbacks and the associated action are
+ # cancelled. If an <tt>after_*</tt> callback returns +false+, all the later callbacks are cancelled.
+ # Callbacks are generally run in the order they are defined, with the exception of callbacks defined as
# methods on the model, which are called last.
#
# == Transactions
@@ -220,7 +220,7 @@ module ActiveRecord
#
# == Debugging callbacks
#
- # To list the methods and procs registered with a particular callback, append <tt>_callback_chain</tt> to
+ # To list the methods and procs registered with a particular callback, append <tt>_callback_chain</tt> to
# the callback name that you wish to list and send that to your class from the Rails console:
#
# >> Topic.after_save_callback_chain
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
index 02a8f4e214..288ce5aebb 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -109,7 +109,7 @@ module ActiveRecord
end
# If a connection already exists yield it to the block. If no connection
- # exists checkout a connection, yield it to the block, and checkin the
+ # exists checkout a connection, yield it to the block, and checkin the
# connection when finished.
def with_connection
connection_id = current_connection_id
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index 2472403282..84fc4c03f9 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -23,7 +23,7 @@ module ActiveRecord
#
# +name+ is the column's name, such as <tt>supplier_id</tt> in <tt>supplier_id int(11)</tt>.
# +default+ is the type-casted default value, such as +new+ in <tt>sales_stage varchar(20) default 'new'</tt>.
- # +sql_type+ is used to extract the column's length, if necessary. For example +60+ in
+ # +sql_type+ is used to extract the column's length, if necessary. For example +60+ in
# <tt>company_name varchar(60)</tt>.
# It will be mapped to one of the standard Rails SQL types in the <tt>type</tt> attribute.
# +null+ determines if this column allows +NULL+ values.
@@ -360,7 +360,7 @@ module ActiveRecord
#
# Available options are (none of these exists by default):
# * <tt>:limit</tt> -
- # Requests a maximum column length. This is number of characters for <tt>:string</tt> and
+ # Requests a maximum column length. This is number of characters for <tt>:string</tt> and
# <tt>:text</tt> columns and number of bytes for :binary and :integer columns.
# * <tt>:default</tt> -
# The column's default value. Use nil for NULL.
@@ -464,7 +464,7 @@ module ActiveRecord
# TableDefinition#timestamps that'll add created_at and +updated_at+ as datetimes.
#
# TableDefinition#references will add an appropriately-named _id column, plus a corresponding _type
- # column if the <tt>:polymorphic</tt> option is supplied. If <tt>:polymorphic</tt> is a hash of
+ # column if the <tt>:polymorphic</tt> option is supplied. If <tt>:polymorphic</tt> is a hash of
# options, these will be used when creating the <tt>_type</tt> column. So what can be written like this:
#
# create_table :taggings do |t|
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 214038848f..0245e63294 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -110,8 +110,8 @@ module ActiveRecord
#
# Also note that this just sets the primary key in the table. You additionally
# need to configure the primary key in the model via the +set_primary_key+ macro.
- # Models do NOT auto-detect the primary key from their table definition.
- #
+ # Models do NOT auto-detect the primary key from their table definition.
+ #
# [<tt>:options</tt>]
# Any extra options you want appended to the table definition.
# [<tt>:temporary</tt>]
diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
index 568759775b..96cf2d09db 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
@@ -277,7 +277,7 @@ module ActiveRecord
# return r
# end
# end
- #
+ #
# # Returns a single value from a record
# def select_value(sql, name = nil)
# result = execute(sql, name)
@@ -285,7 +285,7 @@ module ActiveRecord
# first.first
# end
# end
- #
+ #
# # Returns an array of the values of the first column in a select:
# # select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]
# def select_values(sql, name = nil)
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
index ba0051de05..802921e181 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -278,7 +278,7 @@ module ActiveRecord
rows
end
- # Executes an SQL query and returns a MySQL::Result object. Note that you have to free
+ # Executes an SQL query and returns a MySQL::Result object. Note that you have to free
# the Result object after you're done using it.
def execute(sql, name = nil) #:nodoc:
if name == :skip_logging
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 5046c2f5f6..0a2bacdb84 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -183,13 +183,13 @@ module ActiveRecord
# * <tt>:username</tt> - Defaults to nothing.
# * <tt>:password</tt> - Defaults to nothing.
# * <tt>:database</tt> - The name of the database. No default, must be provided.
- # * <tt>:schema_search_path</tt> - An optional schema search path for the connection given
+ # * <tt>:schema_search_path</tt> - An optional schema search path for the connection given
# as a string of comma-separated schema names. This is backward-compatible with the <tt>:schema_order</tt> option.
- # * <tt>:encoding</tt> - An optional client encoding that is used in a <tt>SET client_encoding TO
+ # * <tt>:encoding</tt> - An optional client encoding that is used in a <tt>SET client_encoding TO
# <encoding></tt> call on the connection.
- # * <tt>:min_messages</tt> - An optional client min messages that is used in a
+ # * <tt>:min_messages</tt> - An optional client min messages that is used in a
# <tt>SET client_min_messages TO <min_messages></tt> call on the connection.
- # * <tt>:allow_concurrency</tt> - If true, use async query methods so Ruby threads don't deadlock;
+ # * <tt>:allow_concurrency</tt> - If true, use async query methods so Ruby threads don't deadlock;
# otherwise, use blocking query methods.
class PostgreSQLAdapter < AbstractAdapter
ADAPTER_NAME = 'PostgreSQL'.freeze
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
index 0de73c4cbc..0571e0cd14 100644
--- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
@@ -29,7 +29,7 @@ module ActiveRecord
end
end
- # The SQLite adapter works with both the 2.x and 3.x series of SQLite with the sqlite-ruby
+ # The SQLite adapter works with both the 2.x and 3.x series of SQLite with the sqlite-ruby
# drivers (available both as gems and from http://rubyforge.org/projects/sqlite-ruby/).
#
# Options:
diff --git a/activerecord/lib/active_record/dynamic_finder_match.rb b/activerecord/lib/active_record/dynamic_finder_match.rb
index 0dc965bd26..533bc331ae 100644
--- a/activerecord/lib/active_record/dynamic_finder_match.rb
+++ b/activerecord/lib/active_record/dynamic_finder_match.rb
@@ -1,7 +1,7 @@
module ActiveRecord
# = Active Record Dynamic Finder Match
- #
+ #
# Refer to ActiveRecord::Base documentation for Dynamic attribute-based finders for detailed info
#
class DynamicFinderMatch
diff --git a/activerecord/lib/active_record/dynamic_scope_match.rb b/activerecord/lib/active_record/dynamic_scope_match.rb
index 15f65be6bc..61c3ea0e7f 100644
--- a/activerecord/lib/active_record/dynamic_scope_match.rb
+++ b/activerecord/lib/active_record/dynamic_scope_match.rb
@@ -1,7 +1,7 @@
module ActiveRecord
# = Active Record Dynamic Scope Match
- #
+ #
# Provides dynamic attribute-based scopes such as <tt>scoped_by_price(4.99)</tt>
# if, for example, the <tt>Product</tt> has an attribute with that name. You can
# chain more <tt>scoped_by_* </tt> methods after the other. It acts like a named
diff --git a/activerecord/lib/active_record/errors.rb b/activerecord/lib/active_record/errors.rb
index e9ac5516ec..ea1709cb1f 100644
--- a/activerecord/lib/active_record/errors.rb
+++ b/activerecord/lib/active_record/errors.rb
@@ -30,7 +30,7 @@ module ActiveRecord
class SerializationTypeMismatch < ActiveRecordError
end
- # Raised when adapter not specified on connection (or configuration file <tt>config/database.yml</tt>
+ # Raised when adapter not specified on connection (or configuration file <tt>config/database.yml</tt>
# misses adapter field).
class AdapterNotSpecified < ActiveRecordError
end
@@ -39,7 +39,7 @@ module ActiveRecord
class AdapterNotFound < ActiveRecordError
end
- # Raised when connection to the database could not been established (for example when <tt>connection=</tt>
+ # Raised when connection to the database could not been established (for example when <tt>connection=</tt>
# is given a nil object).
class ConnectionNotEstablished < ActiveRecordError
end
@@ -53,7 +53,7 @@ module ActiveRecord
class RecordNotSaved < ActiveRecordError
end
- # Raised when SQL statement cannot be executed by the database (for example, it's often the case for
+ # Raised when SQL statement cannot be executed by the database (for example, it's often the case for
# MySQL when Ruby driver used is too old).
class StatementInvalid < ActiveRecordError
end
@@ -81,7 +81,7 @@ module ActiveRecord
class InvalidForeignKey < WrappedDatabaseException
end
- # Raised when number of bind variables in statement given to <tt>:condition</tt> key (for example,
+ # Raised when number of bind variables in statement given to <tt>:condition</tt> key (for example,
# when using +find+ method)
# does not match number of expected variables.
#
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb
index 7cec560a86..666d18215e 100644
--- a/activerecord/lib/active_record/fixtures.rb
+++ b/activerecord/lib/active_record/fixtures.rb
@@ -41,9 +41,9 @@ class FixturesFileNotFound < StandardError; end
# This type of fixture is in YAML format and the preferred default. YAML is a file format which describes data structures
# in a non-verbose, human-readable format. It ships with Ruby 1.8.1+.
#
-# Unlike single-file fixtures, YAML fixtures are stored in a single file per model, which are placed
-# in the directory appointed by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is
-# automatically configured for Rails, so you can just put your files in <tt><your-rails-app>/test/fixtures/</tt>).
+# Unlike single-file fixtures, YAML fixtures are stored in a single file per model, which are placed
+# in the directory appointed by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is
+# automatically configured for Rails, so you can just put your files in <tt><your-rails-app>/test/fixtures/</tt>).
# The fixture file ends with the <tt>.yml</tt> file extension (Rails example:
# <tt><your-rails-app>/test/fixtures/web_sites.yml</tt>). The format of a YAML fixture file looks like this:
#
@@ -61,7 +61,7 @@ class FixturesFileNotFound < StandardError; end
# indented list of key/value pairs in the "key: value" format. Records are separated by a blank line for your viewing
# pleasure.
#
-# Note that YAML fixtures are unordered. If you want ordered fixtures, use the omap YAML type.
+# Note that YAML fixtures are unordered. If you want ordered fixtures, use the omap YAML type.
# See http://yaml.org/type/omap.html
# for the specification. You will need ordered fixtures when you have foreign key constraints on keys in the same table.
# This is commonly needed for tree structures. Example:
@@ -83,7 +83,7 @@ class FixturesFileNotFound < StandardError; end
# (Rails example: <tt><your-rails-app>/test/fixtures/web_sites.csv</tt>).
#
# The format of this type of fixture file is much more compact than the others, but also a little harder to read by us
-# humans. The first line of the CSV file is a comma-separated list of field names. The rest of the
+# humans. The first line of the CSV file is a comma-separated list of field names. The rest of the
# file is then comprised
# of the actual data (1 per line). Here's an example:
#
@@ -104,15 +104,15 @@ class FixturesFileNotFound < StandardError; end
#
# == Single-file fixtures
#
-# This type of fixture was the original format for Active Record that has since been deprecated in
+# This type of fixture was the original format for Active Record that has since been deprecated in
# favor of the YAML and CSV formats.
-# Fixtures for this format are created by placing text files in a sub-directory (with the name of the model)
-# to the directory appointed by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically
+# Fixtures for this format are created by placing text files in a sub-directory (with the name of the model)
+# to the directory appointed by <tt>ActiveSupport::TestCase.fixture_path=(path)</tt> (this is automatically
# configured for Rails, so you can just put your files in <tt><your-rails-app>/test/fixtures/<your-model-name>/</tt> --
# like <tt><your-rails-app>/test/fixtures/web_sites/</tt> for the WebSite model).
#
# Each text file placed in this directory represents a "record". Usually these types of fixtures are named without
-# extensions, but if you are on a Windows machine, you might consider adding <tt>.txt</tt> as the extension.
+# extensions, but if you are on a Windows machine, you might consider adding <tt>.txt</tt> as the extension.
# Here's what the above example might look like:
#
# web_sites/google
@@ -139,7 +139,7 @@ class FixturesFileNotFound < StandardError; end
# end
# end
#
-# By default, the <tt>test_helper module</tt> will load all of your fixtures into your test database,
+# By default, the <tt>test_helper module</tt> will load all of your fixtures into your test database,
# so this test will succeed.
# The testing environment will automatically load the all fixtures into the database before each test.
# To ensure consistent data, the environment deletes the fixtures before running the load.
@@ -189,14 +189,14 @@ class FixturesFileNotFound < StandardError; end
# This will create 1000 very simple YAML fixtures.
#
# Using ERb, you can also inject dynamic values into your fixtures with inserts like <tt><%= Date.today.strftime("%Y-%m-%d") %></tt>.
-# This is however a feature to be used with some caution. The point of fixtures are that they're
-# stable units of predictable sample data. If you feel that you need to inject dynamic values, then
-# perhaps you should reexamine whether your application is properly testable. Hence, dynamic values
+# This is however a feature to be used with some caution. The point of fixtures are that they're
+# stable units of predictable sample data. If you feel that you need to inject dynamic values, then
+# perhaps you should reexamine whether your application is properly testable. Hence, dynamic values
# in fixtures are to be considered a code smell.
#
# = Transactional fixtures
#
-# TestCases can use begin+rollback to isolate their changes to the database instead of having to
+# TestCases can use begin+rollback to isolate their changes to the database instead of having to
# delete+insert for every test case.
#
# class FooTest < ActiveSupport::TestCase
@@ -214,17 +214,17 @@ class FixturesFileNotFound < StandardError; end
# end
#
# If you preload your test database with all fixture data (probably in the Rakefile task) and use transactional fixtures,
-# then you may omit all fixtures declarations in your test cases since all the data's already there
+# then you may omit all fixtures declarations in your test cases since all the data's already there
# and every case rolls back its changes.
#
# In order to use instantiated fixtures with preloaded data, set +self.pre_loaded_fixtures+ to true. This will provide
-# access to fixture data for every table that has been loaded through fixtures (depending on the
+# access to fixture data for every table that has been loaded through fixtures (depending on the
# value of +use_instantiated_fixtures+)
#
# When *not* to use transactional fixtures:
#
-# 1. You're testing whether a transaction works correctly. Nested transactions don't commit until
-# all parent transactions commit, particularly, the fixtures transaction which is begun in setup
+# 1. You're testing whether a transaction works correctly. Nested transactions don't commit until
+# all parent transactions commit, particularly, the fixtures transaction which is begun in setup
# and rolled back in teardown. Thus, you won't be able to verify
# the results of your transaction until Active Record supports nested transactions or savepoints (in progress).
# 2. Your database does not support transactions. Every Active Record database supports transactions except MySQL MyISAM.
diff --git a/activerecord/lib/active_record/locale/en.yml b/activerecord/lib/active_record/locale/en.yml
index a0e94cbec1..44328f63b6 100644
--- a/activerecord/lib/active_record/locale/en.yml
+++ b/activerecord/lib/active_record/locale/en.yml
@@ -22,7 +22,7 @@ en:
# attributes:
# login:
# blank: "This is a custom blank message for User login"
- # Will define custom blank validation message for User model and
+ # Will define custom blank validation message for User model and
# custom blank validation message for login attribute of User model.
#models:
@@ -31,7 +31,7 @@ en:
# For example,
# user: "Dude"
# will translate User model name to "Dude"
-
+
# Translate model attribute names. Used in Model.human_attribute_name(attribute).
#attributes:
# For example,
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index 7f26aa3f52..198f0a18cb 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/migration.rb
@@ -31,13 +31,13 @@ module ActiveRecord
end
# = Active Record Migrations
- #
- # Migrations can manage the evolution of a schema used by several physical
+ #
+ # Migrations can manage the evolution of a schema used by several physical
# databases. It's a solution to the common problem of adding a field to make
# a new feature work in your local database, but being unsure of how to
- # push that change to other developers and to the production server. With
+ # push that change to other developers and to the production server. With
# migrations, you can describe the transformations in self-contained classes
- # that can be checked into version control systems and executed against
+ # that can be checked into version control systems and executed against
# another database that might be one, two, or five versions behind.
#
# Example of a simple migration:
@@ -52,12 +52,12 @@ module ActiveRecord
# end
# end
#
- # This migration will add a boolean flag to the accounts table and remove it
- # if you're backing out of the migration. It shows how all migrations have
- # two class methods +up+ and +down+ that describes the transformations
+ # This migration will add a boolean flag to the accounts table and remove it
+ # if you're backing out of the migration. It shows how all migrations have
+ # two class methods +up+ and +down+ that describes the transformations
# required to implement or remove the migration. These methods can consist
# of both the migration specific methods like add_column and remove_column,
- # but may also contain regular Ruby code for generating data needed for the
+ # but may also contain regular Ruby code for generating data needed for the
# transformations.
#
# Example of a more complex migration that also needs to initialize data:
@@ -72,8 +72,8 @@ module ActiveRecord
# t.integer :position
# end
#
- # SystemSetting.create :name => "notice",
- # :label => "Use notice?",
+ # SystemSetting.create :name => "notice",
+ # :label => "Use notice?",
# :value => 1
# end
#
@@ -82,48 +82,48 @@ module ActiveRecord
# end
# end
#
- # This migration first adds the system_settings table, then creates the very
+ # This migration first adds the system_settings table, then creates the very
# first row in it using the Active Record model that relies on the table. It
- # also uses the more advanced create_table syntax where you can specify a
+ # also uses the more advanced create_table syntax where you can specify a
# complete table schema in one block call.
#
# == Available transformations
#
- # * <tt>create_table(name, options)</tt> Creates a table called +name+ and
+ # * <tt>create_table(name, options)</tt> Creates a table called +name+ and
# makes the table object available to a block that can then add columns to it,
- # following the same format as add_column. See example above. The options hash
- # is for fragments like "DEFAULT CHARSET=UTF-8" that are appended to the create
+ # following the same format as add_column. See example above. The options hash
+ # is for fragments like "DEFAULT CHARSET=UTF-8" that are appended to the create
# table definition.
# * <tt>drop_table(name)</tt>: Drops the table called +name+.
- # * <tt>rename_table(old_name, new_name)</tt>: Renames the table called +old_name+
+ # * <tt>rename_table(old_name, new_name)</tt>: Renames the table called +old_name+
# to +new_name+.
- # * <tt>add_column(table_name, column_name, type, options)</tt>: Adds a new column
+ # * <tt>add_column(table_name, column_name, type, options)</tt>: Adds a new column
# to the table called +table_name+
# named +column_name+ specified to be one of the following types:
- # <tt>:string</tt>, <tt>:text</tt>, <tt>:integer</tt>, <tt>:float</tt>,
+ # <tt>:string</tt>, <tt>:text</tt>, <tt>:integer</tt>, <tt>:float</tt>,
# <tt>:decimal</tt>, <tt>:datetime</tt>, <tt>:timestamp</tt>, <tt>:time</tt>,
# <tt>:date</tt>, <tt>:binary</tt>, <tt>:boolean</tt>. A default value can be
- # specified by passing an +options+ hash like <tt>{ :default => 11 }</tt>.
- # Other options include <tt>:limit</tt> and <tt>:null</tt> (e.g.
- # <tt>{ :limit => 50, :null => false }</tt>) -- see
+ # specified by passing an +options+ hash like <tt>{ :default => 11 }</tt>.
+ # Other options include <tt>:limit</tt> and <tt>:null</tt> (e.g.
+ # <tt>{ :limit => 50, :null => false }</tt>) -- see
# ActiveRecord::ConnectionAdapters::TableDefinition#column for details.
# * <tt>rename_column(table_name, column_name, new_column_name)</tt>: Renames
# a column but keeps the type and content.
- # * <tt>change_column(table_name, column_name, type, options)</tt>: Changes
+ # * <tt>change_column(table_name, column_name, type, options)</tt>: Changes
# the column to a different type using the same parameters as add_column.
- # * <tt>remove_column(table_name, column_name)</tt>: Removes the column named
+ # * <tt>remove_column(table_name, column_name)</tt>: Removes the column named
# +column_name+ from the table called +table_name+.
- # * <tt>add_index(table_name, column_names, options)</tt>: Adds a new index
+ # * <tt>add_index(table_name, column_names, options)</tt>: Adds a new index
# with the name of the column. Other options include
- # <tt>:name</tt> and <tt>:unique</tt> (e.g.
+ # <tt>:name</tt> and <tt>:unique</tt> (e.g.
# <tt>{ :name => "users_name_index", :unique => true }</tt>).
- # * <tt>remove_index(table_name, index_name)</tt>: Removes the index specified
+ # * <tt>remove_index(table_name, index_name)</tt>: Removes the index specified
# by +index_name+.
#
# == Irreversible transformations
#
- # Some transformations are destructive in a manner that cannot be reversed.
- # Migrations of that kind should raise an <tt>ActiveRecord::IrreversibleMigration</tt>
+ # Some transformations are destructive in a manner that cannot be reversed.
+ # Migrations of that kind should raise an <tt>ActiveRecord::IrreversibleMigration</tt>
# exception in their +down+ method.
#
# == Running migrations from within Rails
@@ -134,8 +134,8 @@ module ActiveRecord
# rails generate migration MyNewMigration
#
# where MyNewMigration is the name of your migration. The generator will
- # create an empty migration file <tt>timestamp_my_new_migration.rb</tt>
- # in the <tt>db/migrate/</tt> directory where <tt>timestamp</tt> is the
+ # create an empty migration file <tt>timestamp_my_new_migration.rb</tt>
+ # in the <tt>db/migrate/</tt> directory where <tt>timestamp</tt> is the
# UTC formatted date and time that the migration was generated.
#
# You may then edit the <tt>self.up</tt> and <tt>self.down</tt> methods of
@@ -217,9 +217,9 @@ module ActiveRecord
#
# == Using a model after changing its table
#
- # Sometimes you'll want to add a column in a migration and populate it
- # immediately after. In that case, you'll need to make a call to
- # <tt>Base#reset_column_information</tt> in order to ensure that the model has the
+ # Sometimes you'll want to add a column in a migration and populate it
+ # immediately after. In that case, you'll need to make a call to
+ # <tt>Base#reset_column_information</tt> in order to ensure that the model has the
# latest column data from after the new column was added. Example:
#
# class AddPeopleSalary < ActiveRecord::Migration
diff --git a/activerecord/lib/active_record/named_scope.rb b/activerecord/lib/active_record/named_scope.rb
index bffc450f8e..3de4c40977 100644
--- a/activerecord/lib/active_record/named_scope.rb
+++ b/activerecord/lib/active_record/named_scope.rb
@@ -20,10 +20,10 @@ module ActiveRecord
# fruits = fruits.limit(10) if limited?
#
# Anonymous \scopes tend to be useful when procedurally generating complex
- # queries, where passing intermediate values (\scopes) around as first-class
+ # queries, where passing intermediate values (\scopes) around as first-class
# objects is convenient.
#
- # You can define a \scope that applies to all finders using
+ # You can define a \scope that applies to all finders using
# ActiveRecord::Base.default_scope.
def scoped(options = nil)
if options
@@ -48,20 +48,20 @@ module ActiveRecord
# The above calls to <tt>scope</tt> define class methods Shirt.red and Shirt.dry_clean_only. Shirt.red,
# in effect, represents the query <tt>Shirt.where(:color => 'red')</tt>.
#
- # Unlike <tt>Shirt.find(...)</tt>, however, the object returned by Shirt.red is not an Array; it
- # resembles the association object constructed by a <tt>has_many</tt> declaration. For instance,
- # you can invoke <tt>Shirt.red.first</tt>, <tt>Shirt.red.count</tt>, <tt>Shirt.red.where(:size => 'small')</tt>.
- # Also, just as with the association objects, named \scopes act like an Array, implementing Enumerable;
+ # Unlike <tt>Shirt.find(...)</tt>, however, the object returned by Shirt.red is not an Array; it
+ # resembles the association object constructed by a <tt>has_many</tt> declaration. For instance,
+ # you can invoke <tt>Shirt.red.first</tt>, <tt>Shirt.red.count</tt>, <tt>Shirt.red.where(:size => 'small')</tt>.
+ # Also, just as with the association objects, named \scopes act like an Array, implementing Enumerable;
# <tt>Shirt.red.each(&block)</tt>, <tt>Shirt.red.first</tt>, and <tt>Shirt.red.inject(memo, &block)</tt>
# all behave as if Shirt.red really was an Array.
#
- # These named \scopes are composable. For instance, <tt>Shirt.red.dry_clean_only</tt> will produce
+ # These named \scopes are composable. For instance, <tt>Shirt.red.dry_clean_only</tt> will produce
# all shirts that are both red and dry clean only.
- # Nested finds and calculations also work with these compositions: <tt>Shirt.red.dry_clean_only.count</tt>
- # returns the number of garments for which these criteria obtain. Similarly with
+ # Nested finds and calculations also work with these compositions: <tt>Shirt.red.dry_clean_only.count</tt>
+ # returns the number of garments for which these criteria obtain. Similarly with
# <tt>Shirt.red.dry_clean_only.average(:thread_count)</tt>.
#
- # All \scopes are available as class methods on the ActiveRecord::Base descendant upon which
+ # All \scopes are available as class methods on the ActiveRecord::Base descendant upon which
# the \scopes were defined. But they are also available to <tt>has_many</tt> associations. If,
#
# class Person < ActiveRecord::Base
@@ -95,8 +95,8 @@ module ActiveRecord
# scope :published, where(:published => true)
# end
#
- # Article.published.new.published # => true
- # Article.published.create.published # => true
+ # Article.published.new.published # => true
+ # Article.published.create.published # => true
def scope(name, scope_options = {}, &block)
name = name.to_sym
valid_scope_name?(name)
diff --git a/activerecord/lib/active_record/nested_attributes.rb b/activerecord/lib/active_record/nested_attributes.rb
index e652296e2c..520969adbb 100644
--- a/activerecord/lib/active_record/nested_attributes.rb
+++ b/activerecord/lib/active_record/nested_attributes.rb
@@ -25,7 +25,7 @@ module ActiveRecord
#
# The attribute writer is named after the association, which means that
# in the following example, two new methods are added to your model:
- #
+ #
# <tt>author_attributes=(attributes)</tt> and
# <tt>pages_attributes=(attributes)</tt>.
#
diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb
index e7fe9c39e0..32221f65ce 100644
--- a/activerecord/lib/active_record/observer.rb
+++ b/activerecord/lib/active_record/observer.rb
@@ -67,7 +67,7 @@ module ActiveRecord
#
# == Configuration
#
- # In order to activate an observer, list it in the <tt>config.active_record.observers</tt> configuration
+ # In order to activate an observer, list it in the <tt>config.active_record.observers</tt> configuration
# setting in your <tt>config/application.rb</tt> file.
#
# config.active_record.observers = :comment_observer, :signup_observer
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 8295fd68b3..db18fb7c0f 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -4,7 +4,7 @@ module ActiveRecord
extend ActiveSupport::Concern
# Reflection enables to interrogate Active Record classes and objects
- # about their associations and aggregations. This information can,
+ # about their associations and aggregations. This information can,
# for example, be used in a form builder that takes an Active Record object
# and creates input fields for all of the attributes depending on their type
# and displays the associations to other objects.
@@ -39,7 +39,7 @@ module ActiveRecord
reflections.values.select { |reflection| reflection.is_a?(AggregateReflection) }
end
- # Returns the AggregateReflection object for the named +aggregation+ (use the symbol).
+ # Returns the AggregateReflection object for the named +aggregation+ (use the symbol).
#
# Account.reflect_on_aggregation(:balance) # => the balance AggregateReflection
#
@@ -47,9 +47,9 @@ module ActiveRecord
reflections[aggregation].is_a?(AggregateReflection) ? reflections[aggregation] : nil
end
- # Returns an array of AssociationReflection objects for all the
- # associations in the class. If you only want to reflect on a certain
- # association type, pass in the symbol (<tt>:has_many</tt>, <tt>:has_one</tt>,
+ # Returns an array of AssociationReflection objects for all the
+ # associations in the class. If you only want to reflect on a certain
+ # association type, pass in the symbol (<tt>:has_many</tt>, <tt>:has_one</tt>,
# <tt>:belongs_to</tt>) as the first parameter.
#
# Example:
@@ -78,7 +78,7 @@ module ActiveRecord
end
- # Abstract base class for AggregateReflection and AssociationReflection. Objects of
+ # Abstract base class for AggregateReflection and AssociationReflection. Objects of
# AggregateReflection and AssociationReflection are returned by the Reflection::ClassMethods.
class MacroReflection
attr_reader :active_record
@@ -89,23 +89,23 @@ module ActiveRecord
# Returns the name of the macro.
#
- # <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>:balance</tt>
+ # <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>:balance</tt>
# <tt>has_many :clients</tt> returns <tt>:clients</tt>
attr_reader :name
- # Returns the macro type.
+ # Returns the macro type.
#
# <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>:composed_of</tt>
# <tt>has_many :clients</tt> returns <tt>:has_many</tt>
attr_reader :macro
- # Returns the hash of options used for the macro.
+ # Returns the hash of options used for the macro.
#
# <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>{ :class_name => "Money" }</tt>
# <tt>has_many :clients</tt> returns +{}+
attr_reader :options
- # Returns the class for the macro.
+ # Returns the class for the macro.
#
# <tt>composed_of :balance, :class_name => 'Money'</tt> returns the Money class
# <tt>has_many :clients</tt> returns the Client class
@@ -113,7 +113,7 @@ module ActiveRecord
@klass ||= class_name.constantize
end
- # Returns the class name for the macro.
+ # Returns the class name for the macro.
#
# <tt>composed_of :balance, :class_name => 'Money'</tt> returns <tt>'Money'</tt>
# <tt>has_many :clients</tt> returns <tt>'Client'</tt>
@@ -138,12 +138,12 @@ module ActiveRecord
end
- # Holds all the meta-data about an aggregation as it was specified in the
+ # Holds all the meta-data about an aggregation as it was specified in the
# Active Record class.
class AggregateReflection < MacroReflection #:nodoc:
end
- # Holds all the meta-data about an association as it was specified in the
+ # Holds all the meta-data about an association as it was specified in the
# Active Record class.
class AssociationReflection < MacroReflection #:nodoc:
# Returns the target association's class.
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 1db7f2abec..cfe4d23965 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -67,7 +67,7 @@ module ActiveRecord
preload += @includes_values unless eager_loading?
preload.each {|associations| @klass.send(:preload_associations, @records, associations) }
- # @readonly_value is true only if set explicitly. @implicit_readonly is true if there
+ # @readonly_value is true only if set explicitly. @implicit_readonly is true if there
# are JOINS and no explicit SELECT.
readonly = @readonly_value.nil? ? @implicit_readonly : @readonly_value
@records.each { |record| record.readonly! } if readonly
@@ -131,7 +131,7 @@ module ActiveRecord
# ==== Parameters
#
# * +updates+ - A string, array, or hash representing the SET part of an SQL statement.
- # * +conditions+ - A string, array, or hash representing the WHERE part of an SQL statement.
+ # * +conditions+ - A string, array, or hash representing the WHERE part of an SQL statement.
# See conditions in the intro.
# * +options+ - Additional options are <tt>:limit</tt> and <tt>:order</tt>, see the examples for usage.
#
@@ -264,8 +264,8 @@ module ActiveRecord
# Post.delete_all("person_id = 5 AND (category = 'Something' OR category = 'Else')")
# Post.delete_all(["person_id = ? AND (category = ? OR category = ?)", 5, 'Something', 'Else'])
#
- # Both calls delete the affected posts all at once with a single DELETE statement.
- # If you need to destroy dependent associations or call your <tt>before_*</tt> or
+ # Both calls delete the affected posts all at once with a single DELETE statement.
+ # If you need to destroy dependent associations or call your <tt>before_*</tt> or
# +after_destroy+ callbacks, use the +destroy_all+ method instead.
def delete_all(conditions = nil)
conditions ? where(conditions).delete_all : arel.delete.tap { reset }
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index a679c444cf..64edcc1ef3 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -6,32 +6,32 @@ module ActiveRecord
# Count operates using three different approaches.
#
# * Count all: By not passing any parameters to count, it will return a count of all the rows for the model.
- # * Count using column: By passing a column name to count, it will return a count of all the
+ # * Count using column: By passing a column name to count, it will return a count of all the
# rows for the model with supplied column present
# * Count using options will find the row count matched by the options used.
#
# The third approach, count using options, accepts an option hash as the only parameter. The options are:
#
- # * <tt>:conditions</tt>: An SQL fragment like "administrator = 1" or [ "user_name = ?", username ].
+ # * <tt>:conditions</tt>: An SQL fragment like "administrator = 1" or [ "user_name = ?", username ].
# See conditions in the intro to ActiveRecord::Base.
# * <tt>:joins</tt>: Either an SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id" (rarely needed)
- # or named associations in the same form used for the <tt>:include</tt> option, which will
+ # or named associations in the same form used for the <tt>:include</tt> option, which will
# perform an INNER JOIN on the associated table(s).
- # If the value is a string, then the records will be returned read-only since they will have
+ # If the value is a string, then the records will be returned read-only since they will have
# attributes that do not correspond to the table's columns.
# Pass <tt>:readonly => false</tt> to override.
- # * <tt>:include</tt>: Named associations that should be loaded alongside using LEFT OUTER JOINs.
- # The symbols named refer to already defined associations. When using named associations, count
+ # * <tt>:include</tt>: Named associations that should be loaded alongside using LEFT OUTER JOINs.
+ # The symbols named refer to already defined associations. When using named associations, count
# returns the number of DISTINCT items for the model you're counting.
# See eager loading under Associations.
# * <tt>:order</tt>: An SQL fragment like "created_at DESC, name" (really only used with GROUP BY calculations).
# * <tt>:group</tt>: An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause.
- # * <tt>:select</tt>: By default, this is * as in SELECT * FROM, but can be changed if you, for example,
+ # * <tt>:select</tt>: By default, this is * as in SELECT * FROM, but can be changed if you, for example,
# want to do a join but not
# include the joined columns.
- # * <tt>:distinct</tt>: Set this to true to make this a distinct calculation, such as
+ # * <tt>:distinct</tt>: Set this to true to make this a distinct calculation, such as
# SELECT COUNT(DISTINCT posts.id) ...
- # * <tt>:from</tt> - By default, this is the table name of the class, but can be changed to an
+ # * <tt>:from</tt> - By default, this is the table name of the class, but can be changed to an
# alternate table name (or even the name of a database view).
#
# Examples for counting all:
@@ -44,16 +44,16 @@ module ActiveRecord
# Person.count(:conditions => "age > 26")
#
# # because of the named association, it finds the DISTINCT count using LEFT OUTER JOIN.
- # Person.count(:conditions => "age > 26 AND job.salary > 60000", :include => :job)
+ # Person.count(:conditions => "age > 26 AND job.salary > 60000", :include => :job)
#
# # finds the number of rows matching the conditions and joins.
- # Person.count(:conditions => "age > 26 AND job.salary > 60000",
- # :joins => "LEFT JOIN jobs on jobs.person_id = person.id")
+ # Person.count(:conditions => "age > 26 AND job.salary > 60000",
+ # :joins => "LEFT JOIN jobs on jobs.person_id = person.id")
#
# Person.count('id', :conditions => "age > 26") # Performs a COUNT(id)
# Person.count(:all, :conditions => "age > 26") # Performs a COUNT(*) (:all is an alias for '*')
#
- # Note: <tt>Person.count(:all)</tt> will not work because it will use <tt>:all</tt> as the condition.
+ # Note: <tt>Person.count(:all)</tt> will not work because it will use <tt>:all</tt> as the condition.
# Use Person.count instead.
def count(column_name = nil, options = {})
column_name, options = nil, column_name if column_name.is_a?(Hash)
@@ -95,14 +95,14 @@ module ActiveRecord
calculate(:sum, column_name, options)
end
- # This calculates aggregate values in the given column. Methods for count, sum, average,
- # minimum, and maximum have been added as shortcuts. Options such as <tt>:conditions</tt>,
+ # This calculates aggregate values in the given column. Methods for count, sum, average,
+ # minimum, and maximum have been added as shortcuts. Options such as <tt>:conditions</tt>,
# <tt>:order</tt>, <tt>:group</tt>, <tt>:having</tt>, and <tt>:joins</tt> can be passed to customize the query.
#
# There are two basic forms of output:
- # * Single aggregate value: The single value is type cast to Fixnum for COUNT, Float
+ # * Single aggregate value: The single value is type cast to Fixnum for COUNT, Float
# for AVG, and the given column's type for everything else.
- # * Grouped values: This returns an ordered hash of the values and groups them by the
+ # * Grouped values: This returns an ordered hash of the values and groups them by the
# <tt>:group</tt> option. It takes either a column name, or the name of a belongs_to association.
#
# values = Person.maximum(:age, :group => 'last_name')
@@ -119,29 +119,29 @@ module ActiveRecord
# end
#
# Options:
- # * <tt>:conditions</tt> - An SQL fragment like "administrator = 1" or [ "user_name = ?", username ].
+ # * <tt>:conditions</tt> - An SQL fragment like "administrator = 1" or [ "user_name = ?", username ].
# See conditions in the intro to ActiveRecord::Base.
- # * <tt>:include</tt>: Eager loading, see Associations for details. Since calculations don't load anything,
+ # * <tt>:include</tt>: Eager loading, see Associations for details. Since calculations don't load anything,
# the purpose of this is to access fields on joined tables in your conditions, order, or group clauses.
- # * <tt>:joins</tt> - An SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id".
+ # * <tt>:joins</tt> - An SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id".
# (Rarely needed).
- # The records will be returned read-only since they will have attributes that do not correspond to the
+ # The records will be returned read-only since they will have attributes that do not correspond to the
# table's columns.
# * <tt>:order</tt> - An SQL fragment like "created_at DESC, name" (really only used with GROUP BY calculations).
# * <tt>:group</tt> - An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause.
- # * <tt>:select</tt> - By default, this is * as in SELECT * FROM, but can be changed if you for example
+ # * <tt>:select</tt> - By default, this is * as in SELECT * FROM, but can be changed if you for example
# want to do a join, but not include the joined columns.
- # * <tt>:distinct</tt> - Set this to true to make this a distinct calculation, such as
+ # * <tt>:distinct</tt> - Set this to true to make this a distinct calculation, such as
# SELECT COUNT(DISTINCT posts.id) ...
#
# Examples:
# Person.calculate(:count, :all) # The same as Person.count
# Person.average(:age) # SELECT AVG(age) FROM people...
- # Person.minimum(:age, :conditions => ['last_name != ?', 'Drake']) # Selects the minimum age for
+ # Person.minimum(:age, :conditions => ['last_name != ?', 'Drake']) # Selects the minimum age for
# # everyone with a last name other than 'Drake'
#
# # Selects the minimum age for any family without any minors
- # Person.minimum(:age, :having => 'min(age) > 17', :group => :last_name)
+ # Person.minimum(:age, :having => 'min(age) > 17', :group => :last_name)
#
# Person.sum("2 * age")
def calculate(operation, column_name, options = {})
@@ -282,7 +282,7 @@ module ActiveRecord
def select_for_count
if @select_values.present?
- select = @select_values.join(", ")
+ select = @select_values.join(", ")
select if select !~ /(,|\*)/
end
end
diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb
index fc6728bd18..bae31517c6 100644
--- a/activerecord/lib/active_record/relation/finder_methods.rb
+++ b/activerecord/lib/active_record/relation/finder_methods.rb
@@ -21,27 +21,27 @@ module ActiveRecord
#
# ==== Parameters
#
- # * <tt>:conditions</tt> - An SQL fragment like "administrator = 1", <tt>[ "user_name = ?", username ]</tt>,
+ # * <tt>:conditions</tt> - An SQL fragment like "administrator = 1", <tt>[ "user_name = ?", username ]</tt>,
# or <tt>["user_name = :user_name", { :user_name => user_name }]</tt>. See conditions in the intro.
# * <tt>:order</tt> - An SQL fragment like "created_at DESC, name".
# * <tt>:group</tt> - An attribute name by which the result should be grouped. Uses the <tt>GROUP BY</tt> SQL-clause.
- # * <tt>:having</tt> - Combined with +:group+ this can be used to filter the records that a
+ # * <tt>:having</tt> - Combined with +:group+ this can be used to filter the records that a
# <tt>GROUP BY</tt> returns. Uses the <tt>HAVING</tt> SQL-clause.
# * <tt>:limit</tt> - An integer determining the limit on the number of rows that should be returned.
- # * <tt>:offset</tt> - An integer determining the offset from where the rows should be fetched. So at 5,
+ # * <tt>:offset</tt> - An integer determining the offset from where the rows should be fetched. So at 5,
# it would skip rows 0 through 4.
# * <tt>:joins</tt> - Either an SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id" (rarely needed),
- # named associations in the same form used for the <tt>:include</tt> option, which will perform an
+ # named associations in the same form used for the <tt>:include</tt> option, which will perform an
# <tt>INNER JOIN</tt> on the associated table(s),
# or an array containing a mixture of both strings and named associations.
- # If the value is a string, then the records will be returned read-only since they will
+ # If the value is a string, then the records will be returned read-only since they will
# have attributes that do not correspond to the table's columns.
# Pass <tt>:readonly => false</tt> to override.
# * <tt>:include</tt> - Names associations that should be loaded alongside. The symbols named refer
# to already defined associations. See eager loading under Associations.
- # * <tt>:select</tt> - By default, this is "*" as in "SELECT * FROM", but can be changed if you,
+ # * <tt>:select</tt> - By default, this is "*" as in "SELECT * FROM", but can be changed if you,
# for example, want to do a join but not include the joined columns. Takes a string with the SELECT SQL fragment (e.g. "id, name").
- # * <tt>:from</tt> - By default, this is the table name of the class, but can be changed
+ # * <tt>:from</tt> - By default, this is the table name of the class, but can be changed
# to an alternate table name (or even the name of a database view).
# * <tt>:readonly</tt> - Mark the returned records read-only so they cannot be saved or updated.
# * <tt>:lock</tt> - An SQL fragment like "FOR UPDATE" or "LOCK IN SHARE MODE".
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index b4da8e4d1b..05b26cd0c4 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -12,7 +12,7 @@ module ActiveRecord
if method == :includes
merged_relation = merged_relation.includes(value)
else
- merged_relation.send(:"#{method}_values=", value)
+ merged_relation.send(:"#{method}_values=", value)
end
end
end
diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb
index 4566410206..6faa88ab78 100644
--- a/activerecord/lib/active_record/schema_dumper.rb
+++ b/activerecord/lib/active_record/schema_dumper.rb
@@ -41,11 +41,11 @@ module ActiveRecord
define_params = @version ? ":version => #{@version}" : ""
stream.puts <<HEADER
-# This file is auto-generated from the current state of the database. Instead
+# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
-# Note that this schema.rb definition is the authoritative source for your
+# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
diff --git a/activerecord/lib/active_record/serialization.rb b/activerecord/lib/active_record/serialization.rb
index 2d8bd184f3..6ec406316a 100644
--- a/activerecord/lib/active_record/serialization.rb
+++ b/activerecord/lib/active_record/serialization.rb
@@ -23,7 +23,7 @@ module ActiveRecord #:nodoc:
private
# Add associations specified via the <tt>:includes</tt> option.
- #
+ #
# Expects a block that takes as arguments:
# +association+ - name of the association
# +records+ - the association record(s) to be serialized
diff --git a/activerecord/lib/active_record/serializers/xml_serializer.rb b/activerecord/lib/active_record/serializers/xml_serializer.rb
index b2d4a48945..15abf8bac7 100644
--- a/activerecord/lib/active_record/serializers/xml_serializer.rb
+++ b/activerecord/lib/active_record/serializers/xml_serializer.rb
@@ -80,7 +80,7 @@ module ActiveRecord #:nodoc:
# closure created by a Proc, to_xml can be used to add elements that normally fall
# outside of the scope of the model -- for example, generating and appending URLs
# associated with models.
- #
+ #
# proc = Proc.new { |options, record| options[:builder].tag!('name-reverse', record.name.reverse) }
# firm.to_xml :procs => [ proc ]
#
diff --git a/activerecord/lib/active_record/session_store.rb b/activerecord/lib/active_record/session_store.rb
index becde0fbfd..1c4ecda5b5 100644
--- a/activerecord/lib/active_record/session_store.rb
+++ b/activerecord/lib/active_record/session_store.rb
@@ -9,7 +9,7 @@ module ActiveRecord
# +id+ (numeric primary key),
# +session_id+ (text, or longtext if your session data exceeds 65K), and
# +data+ (text or longtext; careful if your session data exceeds 65KB).
- #
+ #
# The +session_id+ column should always be indexed for speedy lookups.
# Session data is marshaled to the +data+ column in Base64 format.
# If the data you write is larger than the column's size limit,
diff --git a/activerecord/lib/active_record/test_case.rb b/activerecord/lib/active_record/test_case.rb
index ec529ef79d..31b5a8651b 100644
--- a/activerecord/lib/active_record/test_case.rb
+++ b/activerecord/lib/active_record/test_case.rb
@@ -1,6 +1,6 @@
module ActiveRecord
# = Active Record Test Case
- #
+ #
# Defines some test assertions to test against SQL queries.
class TestCase < ActiveSupport::TestCase #:nodoc:
def assert_date_from_db(expected, actual, message = nil)
diff --git a/activerecord/lib/active_record/validations/associated.rb b/activerecord/lib/active_record/validations/associated.rb
index 15b587de45..183acd73b8 100644
--- a/activerecord/lib/active_record/validations/associated.rb
+++ b/activerecord/lib/active_record/validations/associated.rb
@@ -27,8 +27,8 @@ module ActiveRecord
#
# this would specify a circular dependency and cause infinite recursion.
#
- # NOTE: This validation will not fail if the association hasn't been assigned. If you want to
- # ensure that the association is both present and guaranteed to be valid, you also need to
+ # NOTE: This validation will not fail if the association hasn't been assigned. If you want to
+ # ensure that the association is both present and guaranteed to be valid, you also need to
# use +validates_presence_of+.
#
# Configuration options:
diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb
index bf863c7063..cc3d123cea 100644
--- a/activerecord/lib/active_record/validations/uniqueness.rb
+++ b/activerecord/lib/active_record/validations/uniqueness.rb
@@ -78,7 +78,7 @@ module ActiveRecord
end
module ClassMethods
- # Validates whether the value of the specified attributes are unique across the system.
+ # Validates whether the value of the specified attributes are unique across the system.
# Useful for making sure that only one user
# can be named "davidhh".
#
@@ -86,16 +86,16 @@ module ActiveRecord
# validates_uniqueness_of :user_name, :scope => :account_id
# end
#
- # It can also validate whether the value of the specified attributes are unique based on multiple
- # scope parameters. For example, making sure that a teacher can only be on the schedule once
+ # It can also validate whether the value of the specified attributes are unique based on multiple
+ # scope parameters. For example, making sure that a teacher can only be on the schedule once
# per semester for a particular class.
#
# class TeacherSchedule < ActiveRecord::Base
# validates_uniqueness_of :teacher_id, :scope => [:semester_id, :class_id]
# 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,
+ # 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.
#
# Configuration options:
@@ -105,11 +105,11 @@ module ActiveRecord
# * <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+).
# * <tt>:if</tt> - Specifies a method, proc or string to call to determine if the validation should
- # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>).
+ # occur (e.g. <tt>:if => :allow_validation</tt>, or <tt>:if => Proc.new { |user| user.signup_step > 2 }</tt>).
# The method, proc or string should return or evaluate to a true or false value.
# * <tt>:unless</tt> - Specifies a method, proc or string to call to determine if the validation should
- # not occur (e.g. <tt>:unless => :skip_validation</tt>, or
- # <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The method, proc or string should
+ # not occur (e.g. <tt>:unless => :skip_validation</tt>, or
+ # <tt>:unless => Proc.new { |user| user.signup_step <= 2 }</tt>). The method, proc or string should
# return or evaluate to a true or false value.
#
# === Concurrency and integrity
@@ -162,7 +162,7 @@ module ActiveRecord
# ActiveRecord::ConnectionAdapters::SchemaStatements#add_index. In the
# rare case that a race condition occurs, the database will guarantee
# the field's uniqueness.
- #
+ #
# When the database catches such a duplicate insertion,
# ActiveRecord::Base#save will raise an ActiveRecord::StatementInvalid
# exception. You can either choose to let this error propagate (which
@@ -171,7 +171,7 @@ module ActiveRecord
# that the title already exists, and asking him to re-enter the title).
# This technique is also known as optimistic concurrency control:
# http://en.wikipedia.org/wiki/Optimistic_concurrency_control
- #
+ #
# Active Record currently provides no way to distinguish unique
# index constraint errors from other types of database errors, so you
# will have to parse the (database-specific) exception message to detect
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb
index 0eaadac5ae..45f8bd64eb 100644
--- a/activerecord/test/cases/associations/has_many_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb
@@ -19,8 +19,8 @@ require 'models/book'
require 'models/subscription'
class HasManyThroughAssociationsTest < ActiveRecord::TestCase
- fixtures :posts, :readers, :people, :comments, :authors,
- :owners, :pets, :toys, :jobs, :references, :companies,
+ fixtures :posts, :readers, :people, :comments, :authors,
+ :owners, :pets, :toys, :jobs, :references, :companies,
:subscribers, :books, :subscriptions, :developers
# Dummies to force column loads so query counts are clean.
diff --git a/activerecord/test/cases/associations/has_one_through_associations_test.rb b/activerecord/test/cases/associations/has_one_through_associations_test.rb
index 3fcd150422..5d153147f5 100644
--- a/activerecord/test/cases/associations/has_one_through_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_through_associations_test.rb
@@ -12,7 +12,7 @@ require 'models/speedometer'
class HasOneThroughAssociationsTest < ActiveRecord::TestCase
fixtures :member_types, :members, :clubs, :memberships, :sponsors, :organizations, :minivans, :dashboards, :speedometers
-
+
def setup
@member = members(:groucho)
end
@@ -24,7 +24,7 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase
def test_has_one_through_with_has_many
assert_equal clubs(:moustache_club), @member.favourite_club
end
-
+
def test_creating_association_creates_through_record
new_member = Member.create(:name => "Chris")
new_member.club = Club.create(:name => "LRUG")
@@ -41,19 +41,19 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase
assert new_member.save
assert_equal clubs(:moustache_club), new_member.club
end
-
+
def test_replace_target_record
new_club = Club.create(:name => "Marx Bros")
@member.club = new_club
@member.reload
assert_equal new_club, @member.club
end
-
+
def test_replacing_target_record_deletes_old_association
assert_no_difference "Membership.count" do
new_club = Club.create(:name => "Bananarama")
@member.club = new_club
- @member.reload
+ @member.reload
end
end
@@ -81,7 +81,7 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase
Member.find(:all, :include => :sponsor_club, :conditions => ["name = ?", "Groucho Marx"])
end
assert_equal 1, members.size
- assert_not_nil assert_no_queries {members[0].sponsor_club}
+ assert_not_nil assert_no_queries {members[0].sponsor_club}
end
def test_has_one_through_polymorphic_with_source_type
@@ -205,7 +205,7 @@ class HasOneThroughAssociationsTest < ActiveRecord::TestCase
Club.find(@club.id, :include => :sponsored_member).save!
end
end
-
+
def test_value_is_properly_quoted
minivan = Minivan.find('m1')
assert_nothing_raised do
diff --git a/activerecord/test/cases/associations/join_model_test.rb b/activerecord/test/cases/associations/join_model_test.rb
index 447fe4d275..fcdb81e92e 100644
--- a/activerecord/test/cases/associations/join_model_test.rb
+++ b/activerecord/test/cases/associations/join_model_test.rb
@@ -43,11 +43,11 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase
assert_queries(1) { assert_equal 0, author.unique_categorized_posts.count(:title, :conditions => "title is NULL") }
assert !authors(:mary).unique_categorized_posts.loaded?
end
-
+
def test_has_many_uniq_through_find
assert_equal 1, authors(:mary).unique_categorized_posts.find(:all).size
end
-
+
def test_has_many_uniq_through_dynamic_find
assert_equal 1, authors(:mary).unique_categorized_posts.find_all_by_title("So I was thinking").size
end
@@ -297,7 +297,7 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase
assert_equal [], posts(:thinking).authors
assert_equal [authors(:mary)], posts(:authorless).authors
end
-
+
def test_both_scoped_and_explicit_joins_should_be_respected
assert_nothing_raised do
Post.send(:with_scope, :find => {:joins => "left outer join comments on comments.id = posts.id"}) do
@@ -575,7 +575,7 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase
def test_calculations_on_has_many_through_should_disambiguate_fields
assert_nothing_raised { authors(:david).categories.maximum(:id) }
end
-
+
def test_calculations_on_has_many_through_should_not_disambiguate_fields_unless_necessary
assert_nothing_raised { authors(:david).categories.maximum("categories.id") }
end
@@ -675,7 +675,7 @@ class AssociationsJoinModelTest < ActiveRecord::TestCase
end
assert ! david.categories.loaded?
end
-
+
def test_has_many_through_include_returns_false_for_non_matching_record_to_verify_scoping
david = authors(:david)
category = Category.create!(:name => 'Not Associated')
diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb
index b31611e27a..dd8152b219 100644
--- a/activerecord/test/cases/associations_test.rb
+++ b/activerecord/test/cases/associations_test.rb
@@ -70,7 +70,7 @@ class AssociationsTest < ActiveRecord::TestCase
ship.parts.send(:load_target)
assert_equal 'Deck', ship.parts[0].name
end
-
+
def test_include_with_order_works
assert_nothing_raised {Account.find(:first, :order => 'id', :include => :firm)}
@@ -107,7 +107,7 @@ class AssociationsTest < ActiveRecord::TestCase
assert !firm.clients(true).empty?, "New firm should have reloaded client objects"
assert_equal 1, firm.clients(true).size, "New firm should have reloaded clients count"
end
-
+
def test_using_limitable_reflections_helper
using_limitable_reflections = lambda { |reflections| Tagging.scoped.send :using_limitable_reflections?, reflections }
belongs_to_reflections = [Tagging.reflect_on_association(:tag), Tagging.reflect_on_association(:super_tag)]
@@ -117,7 +117,7 @@ class AssociationsTest < ActiveRecord::TestCase
assert !using_limitable_reflections.call(has_many_reflections), "All has many style associations are not limitable"
assert !using_limitable_reflections.call(mixed_reflections), "No collection associations (has many style) should pass"
end
-
+
def test_force_reload_is_uncached
firm = Firm.create!("name" => "A New Firm, Inc")
client = Client.create!("name" => "TheClient.com", :firm => firm)
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb
index 2c069cd8a5..d9e5efa8da 100644
--- a/activerecord/test/cases/attribute_methods_test.rb
+++ b/activerecord/test/cases/attribute_methods_test.rb
@@ -10,7 +10,7 @@ require 'models/reply'
class AttributeMethodsTest < ActiveRecord::TestCase
fixtures :topics, :developers, :companies, :computers
-
+
def setup
@old_matchers = ActiveRecord::Base.send(:attribute_method_matchers).dup
@target = Class.new(ActiveRecord::Base)
@@ -534,9 +534,9 @@ class AttributeMethodsTest < ActiveRecord::TestCase
def test_setting_time_zone_conversion_for_attributes_should_write_value_on_class_variable
Topic.skip_time_zone_conversion_for_attributes = [:field_a]
Minimalistic.skip_time_zone_conversion_for_attributes = [:field_b]
-
- assert_equal [:field_a], Topic.skip_time_zone_conversion_for_attributes
- assert_equal [:field_b], Minimalistic.skip_time_zone_conversion_for_attributes
+
+ assert_equal [:field_a], Topic.skip_time_zone_conversion_for_attributes
+ assert_equal [:field_b], Minimalistic.skip_time_zone_conversion_for_attributes
end
def test_read_attributes_respect_access_control
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 49e7147773..4693cb45fc 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -685,7 +685,7 @@ class TestDestroyAsPartOfAutosaveAssociation < ActiveRecord::TestCase
end
assert_difference("#{association_name.classify}.count", -2) { @pirate.save! }
end
-
+
define_method("test_should_skip_validation_on_the_#{association_name}_association_if_destroyed") do
@pirate.send(association_name).create!(:name => "#{association_name}_1")
children = @pirate.send(association_name)
diff --git a/activerecord/test/cases/counter_cache_test.rb b/activerecord/test/cases/counter_cache_test.rb
index 137236255d..3ed96a3ec8 100644
--- a/activerecord/test/cases/counter_cache_test.rb
+++ b/activerecord/test/cases/counter_cache_test.rb
@@ -43,7 +43,7 @@ class CounterCacheTest < ActiveRecord::TestCase
Topic.reset_counters(@topic.id, :replies)
end
end
-
+
test "reset counters with string argument" do
Topic.increment_counter('replies_count', @topic.id)
diff --git a/activerecord/test/cases/defaults_test.rb b/activerecord/test/cases/defaults_test.rb
index 0e90128907..deaf5252db 100644
--- a/activerecord/test/cases/defaults_test.rb
+++ b/activerecord/test/cases/defaults_test.rb
@@ -29,7 +29,7 @@ class DefaultTest < ActiveRecord::TestCase
assert_equal BigDecimal.new("2.78"), default.decimal_number
end
end
-
+
if current_adapter?(:PostgreSQLAdapter)
def test_multiline_default_text
# older postgres versions represent the default with escapes ("\\012" for a newline)
@@ -50,7 +50,7 @@ if current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter)
#
# We don't want that to happen, so we disable transactional fixtures here.
self.use_transactional_fixtures = false
-
+
# MySQL 5 and higher is quirky with not null text/blob columns.
# With MySQL Text/blob columns cannot have defaults. If the column is not
# null MySQL will report that the column has a null default
@@ -80,7 +80,7 @@ if current_adapter?(:MysqlAdapter) or current_adapter?(:Mysql2Adapter)
ensure
klass.connection.drop_table(klass.table_name) rescue nil
end
-
+
# MySQL uses an implicit default 0 rather than NULL unless in strict mode.
# We use an implicit NULL so schema.rb is compatible with other databases.
def test_mysql_integer_not_null_defaults
diff --git a/activerecord/test/cases/dirty_test.rb b/activerecord/test/cases/dirty_test.rb
index 75f7453aa9..bde93d1c85 100644
--- a/activerecord/test/cases/dirty_test.rb
+++ b/activerecord/test/cases/dirty_test.rb
@@ -408,11 +408,11 @@ class DirtyTest < ActiveRecord::TestCase
def test_previous_changes
# original values should be in previous_changes
pirate = Pirate.new
-
+
assert_equal Hash.new, pirate.previous_changes
pirate.catchphrase = "arrr"
pirate.save!
-
+
assert_equal 4, pirate.previous_changes.size
assert_equal [nil, "arrr"], pirate.previous_changes['catchphrase']
assert_equal [nil, pirate.id], pirate.previous_changes['id']
@@ -421,21 +421,21 @@ class DirtyTest < ActiveRecord::TestCase
assert_nil pirate.previous_changes['created_on'][0]
assert_not_nil pirate.previous_changes['created_on'][1]
assert !pirate.previous_changes.key?('parrot_id')
-
+
# original values should be in previous_changes
pirate = Pirate.new
-
+
assert_equal Hash.new, pirate.previous_changes
pirate.catchphrase = "arrr"
pirate.save
-
+
assert_equal 4, pirate.previous_changes.size
assert_equal [nil, "arrr"], pirate.previous_changes['catchphrase']
assert_equal [nil, pirate.id], pirate.previous_changes['id']
assert pirate.previous_changes.include?('updated_on')
assert pirate.previous_changes.include?('created_on')
assert !pirate.previous_changes.key?('parrot_id')
-
+
pirate.catchphrase = "Yar!!"
pirate.reload
assert_equal Hash.new, pirate.previous_changes
@@ -480,7 +480,7 @@ class DirtyTest < ActiveRecord::TestCase
assert_not_nil pirate.previous_changes['updated_on'][0]
assert_not_nil pirate.previous_changes['updated_on'][1]
assert !pirate.previous_changes.key?('parrot_id')
- assert !pirate.previous_changes.key?('created_on')
+ assert !pirate.previous_changes.key?('created_on')
end
private
diff --git a/activerecord/test/cases/fixtures_test.rb b/activerecord/test/cases/fixtures_test.rb
index a8c1c04f8b..d5ef30e137 100644
--- a/activerecord/test/cases/fixtures_test.rb
+++ b/activerecord/test/cases/fixtures_test.rb
@@ -101,7 +101,7 @@ class FixturesTest < ActiveRecord::TestCase
second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_topics_suffix WHERE author_name = 'Mary'")
assert_nil(second_row["author_email_address"])
- # This checks for a caching problem which causes a bug in the fixtures
+ # This checks for a caching problem which causes a bug in the fixtures
# class-level configuration helper.
assert_not_nil topics, "Fixture data inserted, but fixture objects not returned from create"
ensure
@@ -267,7 +267,7 @@ class FixturesWithoutInstantiationTest < ActiveRecord::TestCase
def test_fixtures_from_root_yml_without_instantiation
assert !defined?(@unknown), "@unknown is not defined"
end
-
+
def test_visibility_of_accessor_method
assert_equal false, respond_to?(:topics, false), "should be private method"
assert_equal true, respond_to?(:topics, true), "confirm to respond surely"
@@ -382,7 +382,7 @@ end
class CheckSetTableNameFixturesTest < ActiveRecord::TestCase
set_fixture_class :funny_jokes => 'Joke'
fixtures :funny_jokes
- # Set to false to blow away fixtures cache and ensure our fixtures are loaded
+ # Set to false to blow away fixtures cache and ensure our fixtures are loaded
# and thus takes into account our set_fixture_class
self.use_transactional_fixtures = false
@@ -394,7 +394,7 @@ end
class FixtureNameIsNotTableNameFixturesTest < ActiveRecord::TestCase
set_fixture_class :items => Book
fixtures :items
- # Set to false to blow away fixtures cache and ensure our fixtures are loaded
+ # Set to false to blow away fixtures cache and ensure our fixtures are loaded
# and thus takes into account our set_fixture_class
self.use_transactional_fixtures = false
@@ -406,7 +406,7 @@ end
class FixtureNameIsNotTableNameMultipleFixturesTest < ActiveRecord::TestCase
set_fixture_class :items => Book, :funny_jokes => Joke
fixtures :items, :funny_jokes
- # Set to false to blow away fixtures cache and ensure our fixtures are loaded
+ # Set to false to blow away fixtures cache and ensure our fixtures are loaded
# and thus takes into account our set_fixture_class
self.use_transactional_fixtures = false
@@ -422,7 +422,7 @@ end
class CustomConnectionFixturesTest < ActiveRecord::TestCase
set_fixture_class :courses => Course
fixtures :courses
- # Set to false to blow away fixtures cache and ensure our fixtures are loaded
+ # Set to false to blow away fixtures cache and ensure our fixtures are loaded
# and thus takes into account our set_fixture_class
self.use_transactional_fixtures = false
@@ -434,7 +434,7 @@ end
class InvalidTableNameFixturesTest < ActiveRecord::TestCase
fixtures :funny_jokes
- # Set to false to blow away fixtures cache and ensure our fixtures are loaded
+ # Set to false to blow away fixtures cache and ensure our fixtures are loaded
# and thus takes into account our lack of set_fixture_class
self.use_transactional_fixtures = false
@@ -448,7 +448,7 @@ end
class CheckEscapedYamlFixturesTest < ActiveRecord::TestCase
set_fixture_class :funny_jokes => 'Joke'
fixtures :funny_jokes
- # Set to false to blow away fixtures cache and ensure our fixtures are loaded
+ # Set to false to blow away fixtures cache and ensure our fixtures are loaded
# and thus takes into account our set_fixture_class
self.use_transactional_fixtures = false
diff --git a/activerecord/test/cases/i18n_test.rb b/activerecord/test/cases/i18n_test.rb
index 3287626378..469f513e68 100644
--- a/activerecord/test/cases/i18n_test.rb
+++ b/activerecord/test/cases/i18n_test.rb
@@ -7,12 +7,12 @@ class ActiveRecordI18nTests < ActiveRecord::TestCase
def setup
I18n.backend = I18n::Backend::Simple.new
end
-
+
def test_translated_model_attributes
I18n.backend.store_translations 'en', :activerecord => {:attributes => {:topic => {:title => 'topic title attribute'} } }
assert_equal 'topic title attribute', Topic.human_attribute_name('title')
end
-
+
def test_translated_model_attributes_with_symbols
I18n.backend.store_translations 'en', :activerecord => {:attributes => {:topic => {:title => 'topic title attribute'} } }
assert_equal 'topic title attribute', Topic.human_attribute_name(:title)
diff --git a/activerecord/test/cases/json_serialization_test.rb b/activerecord/test/cases/json_serialization_test.rb
index 2bc746c0b8..a5736b227d 100644
--- a/activerecord/test/cases/json_serialization_test.rb
+++ b/activerecord/test/cases/json_serialization_test.rb
@@ -204,7 +204,7 @@ class DatabaseConnectedJsonEncodingTest < ActiveRecord::TestCase
def test_should_be_able_to_encode_relation
authors_relation = Author.where(:id => [@david.id, @mary.id])
-
+
json = ActiveSupport::JSON.encode authors_relation, :only => :name
assert_equal '[{"author":{"name":"David"}},{"author":{"name":"Mary"}}]', json
end
diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb
index 0cf3979694..8d35f26b30 100644
--- a/activerecord/test/cases/migration_test.rb
+++ b/activerecord/test/cases/migration_test.rb
@@ -1358,10 +1358,10 @@ if ActiveRecord::Base.connection.supports_migrations?
ActiveRecord::Migrator.forward(MIGRATIONS_ROOT + "/valid")
assert_equal(3, ActiveRecord::Migrator.current_version)
end
-
+
def test_get_all_versions
ActiveRecord::Migrator.migrate(MIGRATIONS_ROOT + "/valid")
- assert_equal([1,2,3], ActiveRecord::Migrator.get_all_versions)
+ assert_equal([1,2,3], ActiveRecord::Migrator.get_all_versions)
ActiveRecord::Migrator.rollback(MIGRATIONS_ROOT + "/valid")
assert_equal([1,2], ActiveRecord::Migrator.get_all_versions)
diff --git a/activerecord/test/cases/modules_test.rb b/activerecord/test/cases/modules_test.rb
index 4b635792c7..14870cb0e2 100644
--- a/activerecord/test/cases/modules_test.rb
+++ b/activerecord/test/cases/modules_test.rb
@@ -13,7 +13,7 @@ class ModulesTest < ActiveRecord::TestCase
[:Firm, :Client].each do |const|
@undefined_consts.merge! const => Object.send(:remove_const, const) if Object.const_defined?(const)
end
-
+
ActiveRecord::Base.store_full_sti_class = false
end
@@ -22,7 +22,7 @@ class ModulesTest < ActiveRecord::TestCase
@undefined_consts.each do |constant, value|
Object.send :const_set, constant, value unless value.nil?
end
-
+
ActiveRecord::Base.store_full_sti_class = true
end
diff --git a/activerecord/test/cases/nested_attributes_test.rb b/activerecord/test/cases/nested_attributes_test.rb
index dbe17a187f..01152b074f 100644
--- a/activerecord/test/cases/nested_attributes_test.rb
+++ b/activerecord/test/cases/nested_attributes_test.rb
@@ -39,7 +39,7 @@ class TestNestedAttributesInGeneral < ActiveRecord::TestCase
def test_should_add_a_proc_to_nested_attributes_options
assert_equal ActiveRecord::NestedAttributes::ClassMethods::REJECT_ALL_BLANK_PROC,
Pirate.nested_attributes_options[:birds_with_reject_all_blank][:reject_if]
-
+
[:parrots, :birds].each do |name|
assert_instance_of Proc, Pirate.nested_attributes_options[name][:reject_if]
end
@@ -817,29 +817,29 @@ class TestHasOneAutosaveAssociationWhichItselfHasAutosaveAssociations < ActiveRe
@part = @ship.parts.create!(:name => "Mast")
@trinket = @part.trinkets.create!(:name => "Necklace")
end
-
+
test "when great-grandchild changed in memory, saving parent should save great-grandchild" do
@trinket.name = "changed"
@pirate.save
assert_equal "changed", @trinket.reload.name
end
-
+
test "when great-grandchild changed via attributes, saving parent should save great-grandchild" do
@pirate.attributes = {:ship_attributes => {:id => @ship.id, :parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:id => @trinket.id, :name => "changed"}]}]}}
@pirate.save
assert_equal "changed", @trinket.reload.name
end
-
+
test "when great-grandchild marked_for_destruction via attributes, saving parent should destroy great-grandchild" do
@pirate.attributes = {:ship_attributes => {:id => @ship.id, :parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:id => @trinket.id, :_destroy => true}]}]}}
assert_difference('@part.trinkets.count', -1) { @pirate.save }
end
-
+
test "when great-grandchild added via attributes, saving parent should create great-grandchild" do
@pirate.attributes = {:ship_attributes => {:id => @ship.id, :parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:name => "created"}]}]}}
assert_difference('@part.trinkets.count', 1) { @pirate.save }
end
-
+
test "when extra records exist for associations, validate (which calls nested_records_changed_for_autosave?) should not load them up" do
@trinket.name = "changed"
Ship.create!(:pirate => @pirate, :name => "The Black Rock")
@@ -880,23 +880,23 @@ class TestHasManyAutosaveAssociationWhichItselfHasAutosaveAssociations < ActiveR
@ship.save
assert_equal "changed", @trinket.reload.name
end
-
+
test "when grandchild changed via attributes, saving parent should save grandchild" do
@ship.attributes = {:parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:id => @trinket.id, :name => "changed"}]}]}
@ship.save
assert_equal "changed", @trinket.reload.name
end
-
+
test "when grandchild marked_for_destruction via attributes, saving parent should destroy grandchild" do
@ship.attributes = {:parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:id => @trinket.id, :_destroy => true}]}]}
assert_difference('@part.trinkets.count', -1) { @ship.save }
end
-
+
test "when grandchild added via attributes, saving parent should create grandchild" do
@ship.attributes = {:parts_attributes => [{:id => @part.id, :trinkets_attributes => [{:name => "created"}]}]}
assert_difference('@part.trinkets.count', 1) { @ship.save }
end
-
+
test "when extra records exist for associations, validate (which calls nested_records_changed_for_autosave?) should not load them up" do
@trinket.name = "changed"
Ship.create!(:name => "The Black Rock")
diff --git a/activerecord/test/cases/persistence_test.rb b/activerecord/test/cases/persistence_test.rb
index c90c787950..13efd2576c 100644
--- a/activerecord/test/cases/persistence_test.rb
+++ b/activerecord/test/cases/persistence_test.rb
@@ -334,7 +334,7 @@ class PersistencesTest < ActiveRecord::TestCase
end
# This test is correct, but it is hard to fix it since
- # update_attribute trigger simply call save! that triggers
+ # update_attribute trigger simply call save! that triggers
# all callbacks.
# def test_update_attribute_with_one_changed_and_one_updated
# t = Topic.order('id').limit(1).first
@@ -348,7 +348,7 @@ class PersistencesTest < ActiveRecord::TestCase
# assert !t.title_changed?, "title should not have changed"
# assert_nil t.title_change, 'title change should be nil'
# assert_equal ['author_name'], t.changed
- #
+ #
# t.reload
# assert_equal 'David', t.author_name
# assert_equal 'super_title', t.title
diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb
index 03c4fc4e80..eeb619ac2f 100644
--- a/activerecord/test/cases/reflection_test.rb
+++ b/activerecord/test/cases/reflection_test.rb
@@ -135,7 +135,7 @@ class ReflectionTest < ActiveRecord::TestCase
def test_association_reflection_in_modules
ActiveRecord::Base.store_full_sti_class = false
-
+
assert_reflection MyApplication::Business::Firm,
:clients_of_firm,
:klass => MyApplication::Business::Client,
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index a50a4d4165..9494990b04 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -339,7 +339,7 @@ class DefaultScopingTest < ActiveRecord::TestCase
def test_default_scoping_with_inheritance
# Inherit a class having a default scope and define a new default scope
klass = Class.new(DeveloperOrderedBySalary)
- klass.send :default_scope, :limit => 1
+ klass.send :default_scope, :limit => 1
# Scopes added on children should append to parent scope
assert_equal 1, klass.scoped.limit_value
@@ -413,7 +413,7 @@ class DefaultScopingTest < ActiveRecord::TestCase
assert_equal 'David', PoorDeveloperCalledJamis.create!(:name => 'David').name
assert_equal 200000, PoorDeveloperCalledJamis.create!(:name => 'David', :salary => 200000).salary
end
-
+
def test_create_attribute_overwrites_default_values
assert_equal nil, PoorDeveloperCalledJamis.create!(:salary => nil).salary
assert_equal 50000, PoorDeveloperCalledJamis.create!(:name => 'David').salary
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index bcc36d79be..bd6e216c62 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -21,8 +21,8 @@ class RelationTest < ActiveRecord::TestCase
def test_two_named_scopes_with_includes_should_not_drop_any_include
car = Car.incl_engines.incl_tyres.first
- assert_no_queries { car.tyres.length }
- assert_no_queries { car.engines.length }
+ assert_no_queries { car.tyres.length }
+ assert_no_queries { car.engines.length }
end
def test_apply_relation_as_where_id
diff --git a/activerecord/test/cases/serialization_test.rb b/activerecord/test/cases/serialization_test.rb
index dab81530af..25dbcc9fc2 100644
--- a/activerecord/test/cases/serialization_test.rb
+++ b/activerecord/test/cases/serialization_test.rb
@@ -5,7 +5,7 @@ require 'models/reply'
require 'models/company'
class SerializationTest < ActiveRecord::TestCase
-
+
fixtures :topics, :companies, :accounts
FORMATS = [ :xml, :json ]
diff --git a/activerecord/test/cases/timestamp_test.rb b/activerecord/test/cases/timestamp_test.rb
index 401439994d..597b954d84 100644
--- a/activerecord/test/cases/timestamp_test.rb
+++ b/activerecord/test/cases/timestamp_test.rb
@@ -15,21 +15,21 @@ class TimestampTest < ActiveRecord::TestCase
def test_saving_a_changed_record_updates_its_timestamp
@developer.name = "Jack Bauer"
@developer.save!
-
+
assert_not_equal @previously_updated_at, @developer.updated_at
end
-
+
def test_saving_a_unchanged_record_doesnt_update_its_timestamp
@developer.save!
-
+
assert_equal @previously_updated_at, @developer.updated_at
end
-
+
def test_touching_a_record_updates_its_timestamp
previous_salary = @developer.salary
@developer.salary = previous_salary + 10000
@developer.touch
-
+
assert_not_equal @previously_updated_at, @developer.updated_at
assert_equal previous_salary + 10000, @developer.salary
assert @developer.salary_changed?, 'developer salary should have changed'
@@ -37,7 +37,7 @@ class TimestampTest < ActiveRecord::TestCase
@developer.reload
assert_equal previous_salary, @developer.salary
end
-
+
def test_touching_a_different_attribute
previously_created_at = @developer.created_at
@developer.touch(:created_at)
@@ -47,15 +47,15 @@ class TimestampTest < ActiveRecord::TestCase
assert_not_equal previously_created_at, @developer.created_at
assert_not_equal @previously_updated_at, @developer.updated_at
end
-
+
def test_saving_a_record_with_a_belongs_to_that_specifies_touching_the_parent_should_update_the_parent_updated_at
pet = Pet.first
owner = pet.owner
previously_owner_updated_at = owner.updated_at
-
+
pet.name = "Fluffy the Third"
pet.save
-
+
assert_not_equal previously_owner_updated_at, pet.owner.updated_at
end
@@ -63,22 +63,22 @@ class TimestampTest < ActiveRecord::TestCase
pet = Pet.first
owner = pet.owner
previously_owner_updated_at = owner.updated_at
-
+
pet.destroy
-
+
assert_not_equal previously_owner_updated_at, pet.owner.updated_at
end
-
+
def test_saving_a_record_with_a_belongs_to_that_specifies_touching_a_specific_attribute_the_parent_should_update_that_attribute
Pet.belongs_to :owner, :touch => :happy_at
pet = Pet.first
owner = pet.owner
previously_owner_happy_at = owner.happy_at
-
+
pet.name = "Fluffy the Third"
pet.save
-
+
assert_not_equal previously_owner_happy_at, pet.owner.happy_at
ensure
Pet.belongs_to :owner, :touch => true
diff --git a/activerecord/test/fixtures/comments.yml b/activerecord/test/fixtures/comments.yml
index 236bdb2e36..97d77f8b9a 100644
--- a/activerecord/test/fixtures/comments.yml
+++ b/activerecord/test/fixtures/comments.yml
@@ -9,7 +9,7 @@ more_greetings:
post_id: 1
body: Thank you again for the welcome
type: Comment
-
+
does_it_hurt:
id: 3
post_id: 2
@@ -37,7 +37,7 @@ eager_sti_on_associations_s_comment2:
eager_sti_on_associations_comment:
id: 8
post_id: 4
- body: Normal type
+ body: Normal type
type: Comment
check_eager_sti_on_associations:
diff --git a/activerecord/test/fixtures/companies.yml b/activerecord/test/fixtures/companies.yml
index 9ad68fbe11..ffaa097686 100644
--- a/activerecord/test/fixtures/companies.yml
+++ b/activerecord/test/fixtures/companies.yml
@@ -44,17 +44,17 @@ a_third_client:
ruby_type: Client
rails_core:
- id: 6
+ id: 6
name: RailsCore
type: DependentFirm
-
+
leetsoft:
- id: 7
+ id: 7
name: Leetsoft
client_of: 6
-
+
jadedpixel:
- id: 8
+ id: 8
name: Jadedpixel
client_of: 6
diff --git a/activerecord/test/fixtures/items.yml b/activerecord/test/fixtures/items.yml
index 31fd657df9..94e3821445 100644
--- a/activerecord/test/fixtures/items.yml
+++ b/activerecord/test/fixtures/items.yml
@@ -1,4 +1,3 @@
dvd:
id: 1
name: Godfather
- \ No newline at end of file
diff --git a/activerecord/test/fixtures/memberships.yml b/activerecord/test/fixtures/memberships.yml
index 99fbe46d9b..b9722dbc8a 100644
--- a/activerecord/test/fixtures/memberships.yml
+++ b/activerecord/test/fixtures/memberships.yml
@@ -4,7 +4,7 @@ membership_of_boring_club:
member: groucho
favourite: false
type: CurrentMembership
-
+
membership_of_favourite_club:
joined_on: <%= 3.weeks.ago.to_s(:db) %>
club: moustache_club
diff --git a/activerecord/test/fixtures/mixins.yml b/activerecord/test/fixtures/mixins.yml
index 0f60e92c2f..f0009cc5f0 100644
--- a/activerecord/test/fixtures/mixins.yml
+++ b/activerecord/test/fixtures/mixins.yml
@@ -1,6 +1,6 @@
# Nested set mixins
-<% (1..10).each do |counter| %>
+<% (1..10).each do |counter| %>
set_<%= counter %>:
id: <%= counter+3000 %>
<% end %>
diff --git a/activerecord/test/fixtures/taggings.yml b/activerecord/test/fixtures/taggings.yml
index 1e3d5965b8..3db6a4c079 100644
--- a/activerecord/test/fixtures/taggings.yml
+++ b/activerecord/test/fixtures/taggings.yml
@@ -11,7 +11,7 @@ thinking_general:
taggable_id: 2
taggable_type: Post
-fake:
+fake:
id: 3
tag_id: 1
taggable_id: 1
diff --git a/activerecord/test/fixtures/tags.yml b/activerecord/test/fixtures/tags.yml
index 471b96f362..7610fd38b9 100644
--- a/activerecord/test/fixtures/tags.yml
+++ b/activerecord/test/fixtures/tags.yml
@@ -1,7 +1,7 @@
general:
id: 1
name: General
-
+
misc:
id: 2
name: Misc \ No newline at end of file
diff --git a/activerecord/test/models/developer.rb b/activerecord/test/models/developer.rb
index c61c583c1d..a140fb8e57 100644
--- a/activerecord/test/models/developer.rb
+++ b/activerecord/test/models/developer.rb
@@ -56,7 +56,7 @@ class Developer < ActiveRecord::Base
audit_logs.build :message => message
end
- def self.all_johns
+ def self.all_johns
self.with_exclusive_scope :find => where(:name => 'John') do
self.all
end
diff --git a/activerecord/test/models/minivan.rb b/activerecord/test/models/minivan.rb
index 602438d16f..830cdb5796 100644
--- a/activerecord/test/models/minivan.rb
+++ b/activerecord/test/models/minivan.rb
@@ -1,9 +1,9 @@
class Minivan < ActiveRecord::Base
set_primary_key :minivan_id
-
+
belongs_to :speedometer
has_one :dashboard, :through => :speedometer
-
+
attr_readonly :color
end
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index 6c7b93be87..a3cb9c724a 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -87,7 +87,7 @@ class Post < ActiveRecord::Base
def self.reset_log
@log = []
end
-
+
def self.log(message=nil, side=nil, new_record=nil)
return @log if message.nil?
@log << [message, side, new_record]
diff --git a/activerecord/test/models/shop.rb b/activerecord/test/models/shop.rb
index b232185693..81414227ea 100644
--- a/activerecord/test/models/shop.rb
+++ b/activerecord/test/models/shop.rb
@@ -6,7 +6,7 @@ module Shop
class Product < ActiveRecord::Base
has_many :variants, :dependent => :delete_all
end
-
+
class Variant < ActiveRecord::Base
end
end
diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb
index 617f01b47d..ba2fe1987b 100644
--- a/activerecord/test/models/topic.rb
+++ b/activerecord/test/models/topic.rb
@@ -9,7 +9,7 @@ class Topic < ActiveRecord::Base
scope :rejected, :conditions => {:approved => false}
scope :by_lifo, :conditions => {: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']
diff --git a/activerecord/test/schema/postgresql_specific_schema.rb b/activerecord/test/schema/postgresql_specific_schema.rb
index 065d8cfe98..f38f4f3b44 100644
--- a/activerecord/test/schema/postgresql_specific_schema.rb
+++ b/activerecord/test/schema/postgresql_specific_schema.rb
@@ -100,7 +100,7 @@ _SQL
obj_id OID
);
_SQL
-
+
execute <<_SQL
CREATE TABLE postgresql_timestamp_with_zones (
id SERIAL PRIMARY KEY,
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index c72f7b25ca..ce7ee78aea 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -164,7 +164,7 @@ ActiveRecord::Schema.define do
t.string :address_country
t.string :gps_location
end
-
+
create_table :dashboards, :force => true, :id => false do |t|
t.string :dashboard_id
t.string :name
@@ -299,7 +299,7 @@ ActiveRecord::Schema.define do
t.boolean :favourite
t.integer :lock_version, :default => 0
end
-
+
create_table :minivans, :force => true, :id => false do |t|
t.string :minivan_id
t.string :name
@@ -469,7 +469,7 @@ ActiveRecord::Schema.define do
t.string :name
t.integer :ship_id
end
-
+
create_table :speedometers, :force => true, :id => false do |t|
t.string :speedometer_id
t.string :name
diff --git a/activeresource/CHANGELOG b/activeresource/CHANGELOG
index 8fa1b0b4b3..605f751c5c 100644
--- a/activeresource/CHANGELOG
+++ b/activeresource/CHANGELOG
@@ -87,7 +87,7 @@
ActiveResource::HttpMock.respond_to do |mock|
mock.get "/people/1.xml", {}, "<person><name>David</name></person>"
end
-
+
Now:
ActiveResource::HttpMock.respond_to.get "/people/1.xml", {}, "<person><name>David</name></person>"
@@ -97,14 +97,14 @@
self.site = "http://app/"
self.format = :json
end
-
+
person = Person.find(1) # => GET http://app/people/1.json
person.name = "David"
person.save # => PUT http://app/people/1.json {name: "David"}
-
+
Person.format = :xml
person.name = "Mary"
- person.save # => PUT http://app/people/1.json <person><name>Mary</name></person>
+ person.save # => PUT http://app/people/1.json <person><name>Mary</name></person>
* Fix reload error when path prefix is used. #8727 [Ian Warshak]
@@ -133,7 +133,7 @@
class Project
headers['X-Token'] = 'foo'
end
-
+
# makes the GET request with the custom X-Token header
Project.find(:all)
@@ -156,7 +156,7 @@
end
assert_kind_of Highrise::Comment, Note.find(1).comments.first
-
+
* Added load_attributes_from_response as a way of loading attributes from other responses than just create [David Heinemeier Hansson]
@@ -248,8 +248,8 @@ d
* Basic validation support [Rick Olson]
- Parses the xml response of ActiveRecord::Errors#to_xml with a similar interface to ActiveRecord::Errors.
-
+ Parses the xml response of ActiveRecord::Errors#to_xml with a similar interface to ActiveRecord::Errors.
+
render :xml => @person.errors.to_xml, :status => '400 Validation Error'
* Deep hashes are converted into collections of resources. [Jeremy Kemper]
@@ -267,12 +267,12 @@ d
* Add support for specifying prefixes.
* Allow overriding of element_name, collection_name, and primary key
* Provide simpler HTTP mock interface for testing
-
+
# rails routing code
map.resources :posts do |post|
post.resources :comments
end
-
+
# ActiveResources
class Post < ActiveResource::Base
self.site = "http://37s.sunrise.i:3000/"
@@ -281,7 +281,7 @@ d
class Comment < ActiveResource::Base
self.site = "http://37s.sunrise.i:3000/posts/:post_id/"
end
-
+
@post = Post.find 5
@comments = Comment.find :all, :post_id => @post.id
diff --git a/activeresource/README.rdoc b/activeresource/README.rdoc
index ad58eaf5fd..02398d969d 100644
--- a/activeresource/README.rdoc
+++ b/activeresource/README.rdoc
@@ -9,7 +9,7 @@ in ActionController::Resources).
Active Resource attempts to provide a coherent wrapper object-relational mapping for REST
web services. It follows the same philosophy as Active Record, in that one of its prime aims
-is to reduce the amount of code needed to map to these resources. This is made possible
+is to reduce the amount of code needed to map to these resources. This is made possible
by relying on a number of code- and protocol-based conventions that make it easy for Active Resource
to infer complex relations and structures. These conventions are outlined in detail in the documentation
for ActiveResource::Base.
@@ -41,14 +41,14 @@ records. But rather than dealing directly with a database record, you're dealin
==== Protocol
-Active Resource is built on a standard XML format for requesting and submitting resources over HTTP. It mirrors the RESTful routing
+Active Resource is built on a standard XML format for requesting and submitting resources over HTTP. It mirrors the RESTful routing
built into Action Controller but will also work with any other REST service that properly implements the protocol.
REST uses HTTP, but unlike "typical" web applications, it makes use of all the verbs available in the HTTP specification:
* GET requests are used for finding and retrieving resources.
* POST requests are used to create new resources.
* PUT requests are used to update existing resources.
-* DELETE requests are used to delete resources.
+* DELETE requests are used to delete resources.
For more information on how this protocol works with Active Resource, see the ActiveResource::Base documentation;
for more general information on REST web services, see the article here[http://en.wikipedia.org/wiki/Representational_State_Transfer].
@@ -111,7 +111,7 @@ as the id of the ARes object.
# is submitted as the body on
#
# POST http://api.people.com:3000/people.xml
- #
+ #
# when save is called on a new Person object. An empty response is
# is expected with a 'Location' header value:
#
diff --git a/activeresource/lib/active_resource/http_mock.rb b/activeresource/lib/active_resource/http_mock.rb
index 75425c01c0..a98af88a37 100644
--- a/activeresource/lib/active_resource/http_mock.rb
+++ b/activeresource/lib/active_resource/http_mock.rb
@@ -41,7 +41,7 @@ module ActiveResource
# mock.delete "/people/1.xml", {}, nil, 200
# end
# end
- #
+ #
# def test_get_matz
# person = Person.find(1)
# assert_equal "Matz", person.name
@@ -77,13 +77,13 @@ module ActiveResource
# mock.get "/people/1.xml", {}, @matz
# end
# end
- #
+ #
# def test_should_request_remote_service
# person = Person.find(1) # Call the remote service
- #
+ #
# # This request object has the same HTTP method and path as declared by the mock
# expected_request = ActiveResource::Request.new(:get, "/people/1.xml")
- #
+ #
# # Assert that the mock received, and responded to, the expected request from the model
# assert ActiveResource::HttpMock.requests.include?(expected_request)
# end
diff --git a/activeresource/lib/active_resource/validations.rb b/activeresource/lib/active_resource/validations.rb
index 026d81e44a..adceac2f61 100644
--- a/activeresource/lib/active_resource/validations.rb
+++ b/activeresource/lib/active_resource/validations.rb
@@ -6,7 +6,7 @@ module ActiveResource
end
# Active Resource validation is reported to and from this object, which is used by Base#save
- # to determine whether the object in a valid state to be saved. See usage example in Validations.
+ # to determine whether the object in a valid state to be saved. See usage example in Validations.
class Errors < ActiveModel::Errors
# Grabs errors from an array of messages (like ActiveRecord::Validations)
# The second parameter directs the errors cache to be cleared (default)
@@ -20,7 +20,7 @@ module ActiveResource
add humanized_attributes[attr_name], message[(attr_name.size + 1)..-1]
end
end
-
+
self[:base] << message if attr_message.nil?
end
end
@@ -37,15 +37,15 @@ module ActiveResource
from_array array, save_cache
end
end
-
+
# Module to support validation and errors with Active Resource objects. The module overrides
- # Base#save to rescue ActiveResource::ResourceInvalid exceptions and parse the errors returned
- # in the web service response. The module also adds an +errors+ collection that mimics the interface
+ # Base#save to rescue ActiveResource::ResourceInvalid exceptions and parse the errors returned
+ # in the web service response. The module also adds an +errors+ collection that mimics the interface
# of the errors provided by ActiveRecord::Errors.
#
# ==== Example
#
- # Consider a Person resource on the server requiring both a +first_name+ and a +last_name+ with a
+ # Consider a Person resource on the server requiring both a +first_name+ and a +last_name+ with a
# <tt>validates_presence_of :first_name, :last_name</tt> declaration in the model:
#
# person = Person.new(:first_name => "Jim", :last_name => "")
@@ -55,7 +55,7 @@ module ActiveResource
# person.errors.count # => 1
# person.errors.full_messages # => ["Last name can't be empty"]
# person.errors[:last_name] # => ["can't be empty"]
- # person.last_name = "Halpert"
+ # person.last_name = "Halpert"
# person.save # => true (and person is now saved to the remote service)
#
module Validations
@@ -118,7 +118,7 @@ module ActiveResource
# also any errors returned from the remote system the last time we
# saved.
# Remote errors can only be cleared by trying to re-save the resource.
- #
+ #
# ==== Examples
# my_person = Person.create(params[:person])
# my_person.valid?
diff --git a/activeresource/test/cases/base/custom_methods_test.rb b/activeresource/test/cases/base/custom_methods_test.rb
index 2d81549a65..459d33c24f 100644
--- a/activeresource/test/cases/base/custom_methods_test.rb
+++ b/activeresource/test/cases/base/custom_methods_test.rb
@@ -35,7 +35,7 @@ class CustomMethodsTest < Test::Unit::TestCase
Person.user = nil
Person.password = nil
- end
+ end
def teardown
ActiveResource::HttpMock.reset!
@@ -64,13 +64,13 @@ class CustomMethodsTest < Test::Unit::TestCase
# Test GET against an element URL
assert_equal Person.find(1).get(:shallow), {"id" => 1, "name" => 'Matz'}
assert_equal Person.find(1).get(:deep), {"id" => 1, "name" => 'Matz', "other" => 'other'}
-
+
# Test PUT against an element URL
assert_equal ActiveResource::Response.new("", 204, {}), Person.find(1).put(:promote, {:position => 'Manager'}, 'body')
-
+
# Test DELETE against an element URL
assert_equal ActiveResource::Response.new("", 200, {}), Person.find(1).delete(:deactivate)
-
+
# With nested resources
assert_equal StreetAddress.find(1, :params => { :person_id => 1 }).get(:deep),
{ "id" => 1, "street" => '12345 Street', "zip" => "27519" }
@@ -87,7 +87,7 @@ class CustomMethodsTest < Test::Unit::TestCase
# Test POST against a nested collection URL
addy = StreetAddress.new(:street => '123 Test Dr.', :person_id => 1)
- assert_equal ActiveResource::Response.new({ :street => '12345 Street' }.to_xml(:root => 'address'),
+ assert_equal ActiveResource::Response.new({ :street => '12345 Street' }.to_xml(:root => 'address'),
201, {'Location' => '/people/1/addresses/2.xml'}),
addy.post(:link)
diff --git a/activeresource/test/cases/validations_test.rb b/activeresource/test/cases/validations_test.rb
index 82546424f2..87c5c8c611 100644
--- a/activeresource/test/cases/validations_test.rb
+++ b/activeresource/test/cases/validations_test.rb
@@ -24,7 +24,7 @@ class ValidationsTest < ActiveModel::TestCase
assert p.save, "should have saved after fixing the validation, but had: #{p.errors.inspect}"
end
-
+
def test_fails_save!
p = new_project(:name => nil)
assert_raise(ActiveResource::ResourceInvalid) { p.save! }
diff --git a/activeresource/test/connection_test.rb b/activeresource/test/connection_test.rb
index a2744d7531..1b4b61899d 100644
--- a/activeresource/test/connection_test.rb
+++ b/activeresource/test/connection_test.rb
@@ -140,12 +140,12 @@ class ConnectionTest < Test::Unit::TestCase
assert_equal "Matz", people[0]["name"]
assert_equal "David", people[1]["name"]
end
-
+
def test_get_collection_single
people = @conn.get("/people_single_elements.xml")
assert_equal "Matz", people[0]["name"]
end
-
+
def test_get_collection_empty
people = @conn.get("/people_empty_elements.xml")
assert_equal [], people
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 53e4d19804..c7f5d6f8b9 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -90,7 +90,7 @@
* Rename #metaclass to #singleton_class now that ruby-core has decided [JK]
-* New assertions assert_blank and assert_present. #4299 [Juanjo Bazan]
+* New assertions assert_blank and assert_present. #4299 [Juanjo Bazan]
* Use Object#singleton_class instead of #metaclass. Prefer Ruby's choice. [Jeremy Kemper]
@@ -243,7 +243,7 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl
* Fix Ruby's Time marshaling bug in pre-1.9 versions of Ruby: utc instances are now correctly unmarshaled with a utc zone instead of the system local zone [#900 state:resolved] [Luca Guidi, Geoff Buesing]
* Add Array#in_groups which splits or iterates over the array in specified number of groups. #579. [Adrian Mugnolo] Example:
-
+
a = (1..10).to_a
a.in_groups(3) # => [[1, 2, 3, 4], [5, 6, 7, nil], [8, 9, 10, nil]]
a.in_groups(3, false) # => [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]]
@@ -331,7 +331,7 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl
* TZInfo: Removing unneeded TimezoneProxy class [Geoff Buesing]
-* TZInfo: Removing unneeded TimezoneIndexDefinition, since we're not including Indexes::Timezones [Geoff Buesing]
+* TZInfo: Removing unneeded TimezoneIndexDefinition, since we're not including Indexes::Timezones [Geoff Buesing]
* Removing unnecessary uses_tzinfo helper from tests, given that TZInfo is now bundled [Geoff Buesing]
@@ -339,7 +339,7 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl
* TimeWithZone#marshal_load does zone lookup via Time.get_zone, so that tzinfo/Olson identifiers are handled [Geoff Buesing]
-* Time.zone= accepts TZInfo::Timezone instances and Olson identifiers; wraps result in TimeZone instance [Geoff Buesing]
+* Time.zone= accepts TZInfo::Timezone instances and Olson identifiers; wraps result in TimeZone instance [Geoff Buesing]
* TimeWithZone time conversions don't need to be wrapped in TimeOrDateTime, because TZInfo does this internally [Geoff Buesing]
@@ -433,7 +433,7 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl
* TimeZone#to_s uses UTC rather than GMT; reapplying change that was undone in [8679]. #1689 [Cheah Chu Yeow]
-* Time.days_in_month defaults to current year if no year is supplied as argument #10799 [Radar], uses Date.gregorian_leap? to determine leap year, and uses constant lookup to determine days in month [Geoff Buesing]
+* Time.days_in_month defaults to current year if no year is supplied as argument #10799 [Radar], uses Date.gregorian_leap? to determine leap year, and uses constant lookup to determine days in month [Geoff Buesing]
* Adding Time and DateTime #compare_with_coercion, which layers behavior on #<=> so that any combination of Time, DateTime and ActiveSupport::TimeWithZone instances can be chronologically compared [Geoff Buesing]
@@ -510,7 +510,7 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl
* Introduce a base class for all test cases used by rails applications. ActiveSupport::TestCase [Michael Koziarski]
- The intention is to use this to reduce the amount of monkeypatching / overriding that
+ The intention is to use this to reduce the amount of monkeypatching / overriding that
is done to test/unit's classes.
* Document Enumerable and Hash #to_json. #9970 [Cheah Chu Yeow]
@@ -679,14 +679,14 @@ ActiveSupport.escape_html_entities_in_json from true to false to match previousl
<name>David</name>
<avatar type="file" name="me.jpg" content_type="image/jpg">R0lGODlhkACZAPUAAM5lcfjrtMQCG=\n</avatar>
</person>
-
+
...becomes:
-
+
attributes = { :person => { :name => "David", :avatar => #<StringIO> } }
attributes[:person][:avatar].content_type # => "image/jpg"
attributes[:person][:avatar].original_filename # => "me.jpg"
attributes[:person][:avatar].read # => binary data of the file
-
+
Which is duck-type compatible with the files that you get when doing multipart uploads through HTML.
* Improved multibyte performance by relying less on exception raising #8159 [Blaine]
@@ -889,11 +889,11 @@ public for compatibility. [Jeremy Kemper]
class Content < ActiveRecord::Base
# has a title attribute
end
-
+
class Email < ActiveRecord::Base
alias_attribute :subject, :title
end
-
+
e = Email.find(1)
e.title # => "Superstars"
e.subject # => "Superstars"
@@ -952,9 +952,9 @@ public for compatibility. [Jeremy Kemper]
<created-at type="date">2004-10-10</created-at>
</note>
EOT
-
+
...would return:
-
+
{ :note => { :title => "This is a note", :created_at => Date.new(2004, 10, 10) } }
* Added Jim Weirich's excellent FlexMock class to vendor (Copyright 2003, 2004 by Jim Weirich (jim@weriichhouse.org)) -- it's not automatically required, though, so require 'flexmock' is still necessary [David Heinemeier Hansson]
@@ -966,28 +966,28 @@ public for compatibility. [Jeremy Kemper]
* Add OrderedHash#values. [Sam Stephenson]
* Added Array#to_s(:db) that'll produce a comma-separated list of ids [David Heinemeier Hansson]. Example:
-
+
Purchase.find(:all, :conditions => "product_id IN (#{shops.products.to_s(:db)})"
-* Normalize classify's argument to a String so that it plays nice with Symbols. [Marcel Molina Jr.]
+* Normalize classify's argument to a String so that it plays nice with Symbols. [Marcel Molina Jr.]
* Strip out leading schema name in classify. References #5139. [Michael Schoen]
* Remove Enumerable#first_match since break(value) handles the use case well enough. [Nicholas Seckar]
Enumerable#first_match was like detect, but instead of returning the matching element, the yielded value returned. For example:
-
+
user_xml = adapters(:from => User, :to => Xml).first_match do |adapter|
adapter.adapt @user
end
-
+
But this is just as easily done with:
-
+
user_xml = adapters(:from => User, :to => Xml).each do
break adapter.adapt(@user)
end
-
-* Make Array#in_groups_of just return the grouped collection if a block isn't given. [Marcel Molina Jr.]
+
+* Make Array#in_groups_of just return the grouped collection if a block isn't given. [Marcel Molina Jr.]
* Don't destroy a HashWithIndifferentAccess if symbolize_keys! or stringify_keys! is called on it. Closes #5076. [Marcel Molina Jr., guy.naor@famundo.com]
@@ -999,7 +999,7 @@ public for compatibility. [Jeremy Kemper]
* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
-* Allow default options in with_options to be overridden. Closes #4480. [murphy@cYcnus.de]
+* Allow default options in with_options to be overridden. Closes #4480. [murphy@cYcnus.de]
* Added Module#alias_method_chain [Jamis Buck]
@@ -1050,7 +1050,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
* Added Hash#to_xml and Array#to_xml that makes it much easier to produce XML from basic structures [David Heinemeier Hansson]. Examples:
{ :name => "David", :street_name => "Paulina", :age => 26, :moved_on => Date.new(2005, 11, 15) }.to_xml
-
+
...returns:
<person>
@@ -1069,7 +1069,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
ex.
- latest_transcripts.group_by(&:day).each do |day, transcripts|
+ latest_transcripts.group_by(&:day).each do |day, transcripts|
p "#{day} -> #{transcripts.map(&:class) * ', '}"
end
"2006-03-01 -> Transcript"
@@ -1093,7 +1093,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
* Add 'around' methods to Logger, to make it easy to log before and after messages for a given block as requested in #3809. [Michael Koziarski] Example:
- logger.around_info("Start rendering component (#{options.inspect}): ",
+ logger.around_info("Start rendering component (#{options.inspect}): ",
"\n\nEnd of component rendering") { yield }
* Added Time#beginning_of_quarter #3607 [cohen.jeff@gmail.com]
@@ -1111,7 +1111,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
delegate :free?, :paying?, :to => :subscription
delegate :overdue?, :to => "subscription.last_payment"
end
-
+
account.free? # => account.subscription.free?
account.overdue? # => account.subscription.last_payment.overdue?
@@ -1126,7 +1126,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
* Add Reloadable::Subclasses which handles the common case where a base class should not be reloaded, but its subclasses should be. [Nicholas Seckar]
* Further improvements to reloading code [Nicholas Seckar, Trevor Squires]
-
+
- All classes/modules which include Reloadable can define reloadable? for fine grained control of reloading
- Class.remove_class uses Module#parent to access the parent module
- Class.remove_class expanded to handle multiple classes in a single call
@@ -1138,7 +1138,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
class Setting
include Reloadable
end
-
+
Reloading a class is done by removing its constant which will cause it to be loaded again on the next reference. [David Heinemeier Hansson]
* Added auto-loading support for classes in modules, so Conductor::Migration will look for conductor/migration.rb and Conductor::Database::Settings will look for conductor/database/settings.rb [Nicholas Seckar]
@@ -1175,7 +1175,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
* Add Symbol#to_proc, which allows for, e.g. [:foo, :bar].map(&:to_s). [Marcel Molina Jr.]
* Added the following methods [Marcel Molina Jr., Sam Stephenson]:
- * Object#copy_instance_variables_from(object) to copy instance variables from one object to another
+ * Object#copy_instance_variables_from(object) to copy instance variables from one object to another
* Object#extended_by to get an instance's included/extended modules
* Object#extend_with_included_modules_from(object) to extend an instance with the modules from another instance
@@ -1226,7 +1226,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
*1.2.0* (October 16th, 2005)
-* Update Exception extension to show the first few framework frames in an application trace. [Nicholas Seckar]
+* Update Exception extension to show the first few framework frames in an application trace. [Nicholas Seckar]
* Added Exception extension to provide support for clean backtraces. [Nicholas Seckar]
@@ -1275,9 +1275,9 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
Inflector.inflections do |inflect|
inflect.plural /^(ox)$/i, '\1\2en'
inflect.singular /^(ox)en/i, '\1'
-
+
inflect.irregular 'octopus', 'octopi'
-
+
inflect.uncountable "equipment"
end
@@ -1360,9 +1360,9 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
* Added Object#suppress which allows you to make a saner choice around with exceptions to swallow #980. Example:
suppress(ZeroDivisionError) { 1/0 }
-
+
...instead of:
-
+
1/0 rescue nil # BAD, EVIL, DIRTY.
@@ -1376,7 +1376,7 @@ approximations and shouldn't be used for critical calculations. [Michael Koziars
values << 'baz'
end
end
-
+
foo # => ['bar', 'baz']
diff --git a/activesupport/lib/active_support/base64.rb b/activesupport/lib/active_support/base64.rb
index b8c01628ce..35014cb3d5 100644
--- a/activesupport/lib/active_support/base64.rb
+++ b/activesupport/lib/active_support/base64.rb
@@ -7,7 +7,7 @@ module ActiveSupport
if defined? ::Base64
Base64 = ::Base64
else
- # Base64 provides utility methods for encoding and de-coding binary data
+ # Base64 provides utility methods for encoding and de-coding binary data
# using a base 64 representation. A base 64 representation of binary data
# consists entirely of printable US-ASCII characters. The Base64 module
# is included in Ruby 1.8, but has been removed in Ruby 1.9.
@@ -15,7 +15,7 @@ module ActiveSupport
# Encodes a string to its base 64 representation. Each 60 characters of
# output is separated by a newline character.
#
- # ActiveSupport::Base64.encode64("Original unencoded string")
+ # ActiveSupport::Base64.encode64("Original unencoded string")
# # => "T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==\n"
def self.encode64(data)
[data].pack("m")
@@ -23,7 +23,7 @@ module ActiveSupport
# Decodes a base 64 encoded string to its original representation.
#
- # ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==")
+ # ActiveSupport::Base64.decode64("T3JpZ2luYWwgdW5lbmNvZGVkIHN0cmluZw==")
# # => "Original unencoded string"
def self.decode64(data)
data.unpack("m").first
diff --git a/activesupport/lib/active_support/benchmarkable.rb b/activesupport/lib/active_support/benchmarkable.rb
index ee02ecb043..df62c18f41 100644
--- a/activesupport/lib/active_support/benchmarkable.rb
+++ b/activesupport/lib/active_support/benchmarkable.rb
@@ -3,10 +3,10 @@ require 'active_support/core_ext/hash/keys'
module ActiveSupport
module Benchmarkable
- # Allows you to measure the execution time of a block
+ # Allows you to measure the execution time of a block
# in a template and records the result to the log. Wrap this block around
# expensive operations or possible bottlenecks to get a time reading
- # for the operation. For example, let's say you thought your file
+ # for the operation. For example, let's say you thought your file
# processing method was taking too long; you could wrap it in a benchmark block.
#
# <% benchmark "Process data files" do %>
@@ -23,7 +23,7 @@ module ActiveSupport
# <%= lowlevel_files_operation %>
# <% end %>
#
- # Finally, you can pass true as the third argument to silence all log activity
+ # Finally, you can pass true as the third argument to silence all log activity
# inside the block. This is great for boiling down a noisy block to just a single statement:
#
# <% benchmark "Process data files", :level => :info, :silence => true do %>
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index 30195bdea5..8153dd57de 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -200,26 +200,26 @@ module ActiveSupport
#
# Setting <tt>:expires_in</tt> will set an expiration time on the cache. All caches
# support auto expiring content after a specified number of seconds. This value can
- # be specified as an option to the construction in which call all entries will be
+ # be specified as an option to the construction in which call all entries will be
# affected. Or it can be supplied to the +fetch+ or +write+ method for just one entry.
#
# cache = ActiveSupport::Cache::MemoryStore.new(:expire_in => 5.minutes)
# cache.write(key, value, :expire_in => 1.minute) # Set a lower value for one entry
#
# Setting <tt>:race_condition_ttl</tt> is very useful in situations where a cache entry
- # is used very frequently unver heavy load. If a cache expires and due to heavy load
- # seven different processes will try to read data natively and then they all will try to
- # write to cache. To avoid that case the first process to find an expired cache entry will
+ # is used very frequently unver heavy load. If a cache expires and due to heavy load
+ # seven different processes will try to read data natively and then they all will try to
+ # write to cache. To avoid that case the first process to find an expired cache entry will
# bump the cache expiration time by the value set in <tt>:race_condition_ttl</tt>. Yes
- # this process is extending the time for a stale value by another few seconds. Because
+ # this process is extending the time for a stale value by another few seconds. Because
# of extended life of the previous cache, other processes will continue to use slightly
# stale data for a just a big longer. In the meantime that first process will go ahead
# and will write into cache the new value. After that all the processes will start
# getting new value. The key is to keep <tt>:race_condition_ttl</tt> small.
#
# If the process regenerating the entry errors out, the entry will be regenerated
- # after the specified number of seconds. Also note that the life of stale cache is
- # extended only if it expired recently. Otherwise a new value is generated and
+ # after the specified number of seconds. Also note that the life of stale cache is
+ # extended only if it expired recently. Otherwise a new value is generated and
# <tt>:race_condition_ttl</tt> does not play any role.
#
# # Set all values to expire after one minute.
@@ -410,7 +410,7 @@ module ActiveSupport
raise NotImplementedError.new("#{self.class.name} does not support decrement")
end
- # Cleanup the cache by removing expired entries.
+ # Cleanup the cache by removing expired entries.
#
# Options are passed to the underlying cache implementation.
#
@@ -419,7 +419,7 @@ module ActiveSupport
raise NotImplementedError.new("#{self.class.name} does not support cleanup")
end
- # Clear the entire cache. Be careful with this method since it could
+ # Clear the entire cache. Be careful with this method since it could
# affect other processes if shared cache is being used.
#
# Options are passed to the underlying cache implementation.
@@ -473,8 +473,8 @@ module ActiveSupport
end
end
- # Expand key to be a consistent string value. Invoke +cache_key+ if
- # object responds to +cache_key+. Otherwise, to_param method will be
+ # Expand key to be a consistent string value. Invoke +cache_key+ if
+ # object responds to +cache_key+. Otherwise, to_param method will be
# called. If the key is a Hash, then keys will be sorted alphabetically.
def expanded_key(key) # :nodoc:
if key.respond_to?(:cache_key)
diff --git a/activesupport/lib/active_support/cache/strategy/local_cache.rb b/activesupport/lib/active_support/cache/strategy/local_cache.rb
index 3edba52fc4..4dce35f1c9 100644
--- a/activesupport/lib/active_support/cache/strategy/local_cache.rb
+++ b/activesupport/lib/active_support/cache/strategy/local_cache.rb
@@ -16,7 +16,7 @@ module ActiveSupport
@data = {}
end
- # Don't allow synchronizing since it isn't thread safe,
+ # Don't allow synchronizing since it isn't thread safe,
def synchronize # :nodoc:
yield
end
diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb
index 24e407c253..09ddd7da83 100644
--- a/activesupport/lib/active_support/callbacks.rb
+++ b/activesupport/lib/active_support/callbacks.rb
@@ -479,7 +479,7 @@ module ActiveSupport
end
filters.each do |filter|
- chain.delete_if {|c| c.matches?(type, filter) }
+ chain.delete_if {|c| c.matches?(type, filter) }
end
options[:prepend] ? chain.unshift(*mapped) : chain.push(*mapped)
diff --git a/activesupport/lib/active_support/core_ext/array/random_access.rb b/activesupport/lib/active_support/core_ext/array/random_access.rb
index edac7278bc..9a6b5e9b79 100644
--- a/activesupport/lib/active_support/core_ext/array/random_access.rb
+++ b/activesupport/lib/active_support/core_ext/array/random_access.rb
@@ -1,10 +1,10 @@
class Array
# Backport of Array#sample based on Marc-Andre Lafortune's http://github.com/marcandre/backports/
- # Returns a random element or +n+ random elements from the array.
+ # Returns a random element or +n+ random elements from the array.
# If the array is empty and +n+ is nil, returns <tt>nil</tt>. if +n+ is passed, returns <tt>[]</tt>.
- #
- # [1,2,3,4,5,6].sample # => 4
- # [1,2,3,4,5,6].sample(3) # => [2, 4, 5]
+ #
+ # [1,2,3,4,5,6].sample # => 4
+ # [1,2,3,4,5,6].sample(3) # => [2, 4, 5]
# [].sample # => nil
# [].sample(3) # => []
def sample(n=nil)
diff --git a/activesupport/lib/active_support/core_ext/array/wrap.rb b/activesupport/lib/active_support/core_ext/array/wrap.rb
index 06b2acd662..7fabae3138 100644
--- a/activesupport/lib/active_support/core_ext/array/wrap.rb
+++ b/activesupport/lib/active_support/core_ext/array/wrap.rb
@@ -10,7 +10,7 @@ class Array
# Array.wrap(nil) # => []
# Array.wrap([1, 2, 3]) # => [1, 2, 3]
# Array.wrap(0) # => [0]
- #
+ #
# This method is similar in purpose to <tt>Kernel#Array</tt>, but there are some differences:
#
# * If the argument responds to +to_ary+ the method is invoked. <tt>Kernel#Array</tt>
diff --git a/activesupport/lib/active_support/core_ext/date/calculations.rb b/activesupport/lib/active_support/core_ext/date/calculations.rb
index c5b54318ce..1856b4dd8b 100644
--- a/activesupport/lib/active_support/core_ext/date/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/date/calculations.rb
@@ -7,7 +7,7 @@ require 'active_support/core_ext/time/zones'
class Date
if RUBY_VERSION < '1.9'
undef :>>
-
+
# Backported from 1.9. The one in 1.8 leads to incorrect next_month and
# friends for dates where the calendar reform is involved. It additionally
# prevents an infinite loop fixed in r27013.
@@ -156,7 +156,7 @@ class Date
def next_year
years_since(1)
end unless method_defined?(:next_year)
-
+
# Shorthand for months_ago(1)
def prev_month
months_ago(1)
diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
index 47b8aa59fb..8e267c76c4 100644
--- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
@@ -9,12 +9,12 @@ class DateTime
remove_method :to_time if instance_methods.include?(:to_time)
# Convert to a formatted string. See Time::DATE_FORMATS for predefined formats.
- #
+ #
# This method is aliased to <tt>to_s</tt>.
- #
+ #
# === Examples
# datetime = DateTime.civil(2007, 12, 4, 0, 0, 0, 0) # => Tue, 04 Dec 2007 00:00:00 +0000
- #
+ #
# datetime.to_formatted_s(:db) # => "2007-12-04 00:00:00"
# datetime.to_s(:db) # => "2007-12-04 00:00:00"
# datetime.to_s(:number) # => "20071204000000"
@@ -50,7 +50,7 @@ class DateTime
def formatted_offset(colon = true, alternate_utc_string = nil)
utc? && alternate_utc_string || ActiveSupport::TimeZone.seconds_to_utc_offset(utc_offset, colon)
end
-
+
# Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005 14:30:00 +0000"
def readable_inspect
to_s(:rfc822)
@@ -83,8 +83,8 @@ class DateTime
def xmlschema
strftime("%Y-%m-%dT%H:%M:%S%Z")
end unless instance_methods(false).include?(:xmlschema)
-
- # Converts self to a floating-point number of seconds since the Unix epoch
+
+ # Converts self to a floating-point number of seconds since the Unix epoch
def to_f
seconds_since_unix_epoch.to_f
end
diff --git a/activesupport/lib/active_support/core_ext/date_time/zones.rb b/activesupport/lib/active_support/core_ext/date_time/zones.rb
index a7411d54ae..82a4f7ac5a 100644
--- a/activesupport/lib/active_support/core_ext/date_time/zones.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/zones.rb
@@ -9,7 +9,7 @@ class DateTime
# This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt> as the local zone
# instead of the operating system's time zone.
#
- # You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument,
+ # You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument,
# and the conversion will be based on that zone instead of <tt>Time.zone</tt>.
#
# DateTime.new(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb
index f76ed401cd..f1103029c8 100644
--- a/activesupport/lib/active_support/core_ext/enumerable.rb
+++ b/activesupport/lib/active_support/core_ext/enumerable.rb
@@ -9,7 +9,7 @@ module Enumerable
#
# Example:
#
- # latest_transcripts.group_by(&:day).each do |day, transcripts|
+ # latest_transcripts.group_by(&:day).each do |day, transcripts|
# p "#{day} -> #{transcripts.map(&:class).join(', ')}"
# end
# "2006-03-01 -> Transcript"
@@ -88,21 +88,21 @@ module Enumerable
# => { "nextangle" => <Person ...>, "chade-" => <Person ...>, ...}
# people.index_by { |person| "#{person.first_name} #{person.last_name}" }
# => { "Chade- Fowlersburg-e" => <Person ...>, "David Heinemeier Hansson" => <Person ...>, ...}
- #
+ #
def index_by
inject({}) do |accum, elem|
accum[yield(elem)] = elem
accum
end
end
-
+
# Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1.
# Works with a block too ala any?, so people.many? { |p| p.age > 26 } # => returns true if more than 1 person is over 26.
def many?(&block)
size = block_given? ? select(&block).size : self.size
size > 1
end
-
+
# The negative of the Enumerable#include?. Returns true if the collection does not include the object.
def exclude?(object)
!include?(object)
diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb
index 2763af6121..7e929848a9 100644
--- a/activesupport/lib/active_support/core_ext/hash/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb
@@ -7,7 +7,7 @@ require 'active_support/core_ext/string/inflections'
class Hash
# Returns a string containing an XML representation of its receiver:
- #
+ #
# {"foo" => 1, "bar" => 2}.to_xml
# # =>
# # <?xml version="1.0" encoding="UTF-8"?>
@@ -15,22 +15,22 @@ class Hash
# # <foo type="integer">1</foo>
# # <bar type="integer">2</bar>
# # </hash>
- #
+ #
# To do so, the method loops over the pairs and builds nodes that depend on
# the _values_. Given a pair +key+, +value+:
- #
+ #
# * If +value+ is a hash there's a recursive call with +key+ as <tt>:root</tt>.
- #
+ #
# * If +value+ is an array there's a recursive call with +key+ as <tt>:root</tt>,
# and +key+ singularized as <tt>:children</tt>.
- #
+ #
# * If +value+ is a callable object it must expect one or two arguments. Depending
# on the arity, the callable is invoked with the +options+ hash as first argument
# with +key+ as <tt>:root</tt>, and +key+ singularized as second argument. Its
# return value becomes a new node.
- #
+ #
# * If +value+ responds to +to_xml+ the method is invoked with +key+ as <tt>:root</tt>.
- #
+ #
# * Otherwise, a node with +key+ as tag is created with a string representation of
# +value+ as text node. If +value+ is +nil+ an attribute "nil" set to "true" is added.
# Unless the option <tt>:skip_types</tt> exists and is true, an attribute "type" is
@@ -48,9 +48,9 @@ class Hash
# "DateTime" => "datetime",
# "Time" => "datetime"
# }
- #
+ #
# By default the root node is "hash", but that's configurable via the <tt>:root</tt> option.
- #
+ #
# The default XML builder is a fresh instance of <tt>Builder::XmlMarkup</tt>. You can
# configure your own builder with the <tt>:builder</tt> option. The method also accepts
# options like <tt>:dasherize</tt> and friends, they are forwarded to the builder.
@@ -108,7 +108,7 @@ class Hash
# blank or nil parsed values are represented by nil
elsif value.blank? || value['nil'] == 'true'
nil
- # If the type is the only element which makes it then
+ # If the type is the only element which makes it then
# this still makes the value nil, except if type is
# a XML node(where type['value'] is a Hash)
elsif value['type'] && value.size == 1 && !value['type'].is_a?(::Hash)
@@ -118,7 +118,7 @@ class Hash
h[k] = typecast_xml_value(v)
h
end
-
+
# Turn { :files => { :file => #<StringIO> } into { :files => #<StringIO> } so it is compatible with
# how multipart uploaded files from HTML appear
xml_value["file"].is_a?(StringIO) ? xml_value["file"] : xml_value
diff --git a/activesupport/lib/active_support/core_ext/integer/time.rb b/activesupport/lib/active_support/core_ext/integer/time.rb
index a0ccf0e971..c677400396 100644
--- a/activesupport/lib/active_support/core_ext/integer/time.rb
+++ b/activesupport/lib/active_support/core_ext/integer/time.rb
@@ -1,7 +1,7 @@
class Integer
# Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
#
- # These methods use Time#advance for precise date calculations when using from_now, ago, etc.
+ # These methods use Time#advance for precise date calculations when using from_now, ago, etc.
# as well as adding or subtracting their results from a Time object. For example:
#
# # equivalent to Time.now.advance(:months => 1)
@@ -12,7 +12,7 @@ class Integer
#
# # equivalent to Time.now.advance(:months => 4, :years => 5)
# (4.months + 5.years).from_now
- #
+ #
# While these methods provide precise calculation when used as in the examples above, care
# should be taken to note that this is not true if the result of `months', `years', etc is
# converted before use:
diff --git a/activesupport/lib/active_support/core_ext/module/anonymous.rb b/activesupport/lib/active_support/core_ext/module/anonymous.rb
index df25a09ec9..3982c9c586 100644
--- a/activesupport/lib/active_support/core_ext/module/anonymous.rb
+++ b/activesupport/lib/active_support/core_ext/module/anonymous.rb
@@ -19,6 +19,6 @@ class Module
def anonymous?
# Uses blank? because the name of an anonymous class is an empty
# string in 1.8, and nil in 1.9.
- name.blank?
+ name.blank?
end
end
diff --git a/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb b/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
index 28ac89dab9..bfedbbb256 100644
--- a/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
+++ b/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
@@ -2,7 +2,7 @@ class Module
# Declare an attribute accessor with an initial default return value.
#
# To give attribute <tt>:age</tt> the initial value <tt>25</tt>:
- #
+ #
# class Person
# attr_accessor_with_default :age, 25
# end
@@ -16,7 +16,7 @@ class Module
# To give attribute <tt>:element_name</tt> a dynamic default value, evaluated
# in scope of self:
#
- # attr_accessor_with_default(:element_name) { name.underscore }
+ # attr_accessor_with_default(:element_name) { name.underscore }
#
def attr_accessor_with_default(sym, default = nil, &block)
raise 'Default value or block required' unless !default.nil? || block
diff --git a/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb b/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
index 2d88cb57e5..871f5cef3b 100644
--- a/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
+++ b/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
@@ -11,7 +11,7 @@ class Module
@@#{sym}
end
EOS
-
+
unless options[:instance_reader] == false
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{sym}
diff --git a/activesupport/lib/active_support/core_ext/module/remove_method.rb b/activesupport/lib/active_support/core_ext/module/remove_method.rb
index b8c01aca0e..07d7c9b018 100644
--- a/activesupport/lib/active_support/core_ext/module/remove_method.rb
+++ b/activesupport/lib/active_support/core_ext/module/remove_method.rb
@@ -3,7 +3,7 @@ class Module
remove_method(method)
rescue NameError
end
-
+
def redefine_method(method, &block)
remove_possible_method(method)
define_method(method, &block)
diff --git a/activesupport/lib/active_support/core_ext/module/synchronization.rb b/activesupport/lib/active_support/core_ext/module/synchronization.rb
index de76a069d6..38ce55f26e 100644
--- a/activesupport/lib/active_support/core_ext/module/synchronization.rb
+++ b/activesupport/lib/active_support/core_ext/module/synchronization.rb
@@ -3,9 +3,9 @@ require 'active_support/core_ext/array/extract_options'
class Module
# Synchronize access around a method, delegating synchronization to a
- # particular mutex. A mutex (either a Mutex, or any object that responds to
+ # particular mutex. A mutex (either a Mutex, or any object that responds to
# #synchronize and yields to a block) must be provided as a final :with option.
- # The :with option should be a symbol or string, and can represent a method,
+ # The :with option should be a symbol or string, and can represent a method,
# constant, or instance or class variable.
# Example:
# class SharedCache
diff --git a/activesupport/lib/active_support/core_ext/numeric/time.rb b/activesupport/lib/active_support/core_ext/numeric/time.rb
index d1062805c5..d32a9e0531 100644
--- a/activesupport/lib/active_support/core_ext/numeric/time.rb
+++ b/activesupport/lib/active_support/core_ext/numeric/time.rb
@@ -3,7 +3,7 @@ require 'active_support/duration'
class Numeric
# Enables the use of time calculations and declarations, like 45.minutes + 2.hours + 4.years.
#
- # These methods use Time#advance for precise date calculations when using from_now, ago, etc.
+ # These methods use Time#advance for precise date calculations when using from_now, ago, etc.
# as well as adding or subtracting their results from a Time object. For example:
#
# # equivalent to Time.now.advance(:months => 1)
@@ -14,7 +14,7 @@ class Numeric
#
# # equivalent to Time.now.advance(:months => 4, :years => 5)
# (4.months + 5.years).from_now
- #
+ #
# While these methods provide precise calculation when used as in the examples above, care
# should be taken to note that this is not true if the result of `months', `years', etc is
# converted before use:
@@ -25,8 +25,8 @@ class Numeric
# # equivalent to 365.25.days.to_f.from_now
# 1.year.to_f.from_now
#
- # In such cases, Ruby's core
- # Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and
+ # In such cases, Ruby's core
+ # Date[http://stdlib.rubyonrails.org/libdoc/date/rdoc/index.html] and
# Time[http://stdlib.rubyonrails.org/libdoc/time/rdoc/index.html] should be used for precision
# date and time arithmetic
def seconds
@@ -37,13 +37,13 @@ class Numeric
def minutes
ActiveSupport::Duration.new(self * 60, [[:seconds, self * 60]])
end
- alias :minute :minutes
-
+ alias :minute :minutes
+
def hours
ActiveSupport::Duration.new(self * 3600, [[:seconds, self * 3600]])
end
alias :hour :hours
-
+
def days
ActiveSupport::Duration.new(self * 24.hours, [[:days, self]])
end
@@ -53,12 +53,12 @@ class Numeric
ActiveSupport::Duration.new(self * 7.days, [[:days, self * 7]])
end
alias :week :weeks
-
+
def fortnights
ActiveSupport::Duration.new(self * 2.weeks, [[:days, self * 14]])
end
alias :fortnight :fortnights
-
+
# Reads best without arguments: 10.minutes.ago
def ago(time = ::Time.now)
time - self
diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb
index eb99bb1a36..51670b148f 100644
--- a/activesupport/lib/active_support/core_ext/object/blank.rb
+++ b/activesupport/lib/active_support/core_ext/object/blank.rb
@@ -17,7 +17,7 @@ class Object
def present?
!blank?
end
-
+
# Returns object if it's #present? otherwise returns nil.
# object.presence is equivalent to object.present? ? object : nil.
#
diff --git a/activesupport/lib/active_support/core_ext/object/instance_variables.rb b/activesupport/lib/active_support/core_ext/object/instance_variables.rb
index 866317b17a..97b288c608 100644
--- a/activesupport/lib/active_support/core_ext/object/instance_variables.rb
+++ b/activesupport/lib/active_support/core_ext/object/instance_variables.rb
@@ -7,7 +7,7 @@ class Object
# @x, @y = x, y
# end
# end
- #
+ #
# C.new(0, 1).instance_values # => {"x" => 0, "y" => 1}
def instance_values #:nodoc:
instance_variables.inject({}) do |values, name|
@@ -24,7 +24,7 @@ class Object
# @x, @y = x, y
# end
# end
- #
+ #
# C.new(0, 1).instance_variable_names # => ["@y", "@x"]
if RUBY_VERSION >= '1.9'
def instance_variable_names
@@ -47,15 +47,15 @@ class Object
# def initialize(x, y, z)
# @x, @y, @z = x, y, z
# end
- #
+ #
# def protected_instance_variables
# %w(@z)
# end
# end
- #
+ #
# a = C.new(0, 1, 2)
# b = C.new(3, 4, 5)
- #
+ #
# a.copy_instance_variables_from(b, [:@y])
# # a is now: @x = 3, @y = 1, @z = 2
def copy_instance_variables_from(object, exclude = []) #:nodoc:
diff --git a/activesupport/lib/active_support/core_ext/object/returning.rb b/activesupport/lib/active_support/core_ext/object/returning.rb
index 07250b2a27..c401992ccc 100644
--- a/activesupport/lib/active_support/core_ext/object/returning.rb
+++ b/activesupport/lib/active_support/core_ext/object/returning.rb
@@ -25,7 +25,7 @@ class Object
# end
#
# foo # => ['bar', 'baz']
- #
+ #
# # returning with a block argument
# def foo
# returning [] do |values|
@@ -33,7 +33,7 @@ class Object
# values << 'baz'
# end
# end
- #
+ #
# foo # => ['bar', 'baz']
def returning(value)
ActiveSupport::Deprecation.warn('Object#returning has been deprecated in favor of Object#tap.', caller)
diff --git a/activesupport/lib/active_support/core_ext/range/conversions.rb b/activesupport/lib/active_support/core_ext/range/conversions.rb
index 11a7ff66de..544e63132d 100644
--- a/activesupport/lib/active_support/core_ext/range/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/range/conversions.rb
@@ -6,7 +6,7 @@ class Range
# Gives a human readable format of the range.
#
# ==== Example
- #
+ #
# [1..100].to_formatted_s # => "1..100"
def to_formatted_s(format = :default)
if formatter = RANGE_FORMATS[format]
diff --git a/activesupport/lib/active_support/core_ext/string/access.rb b/activesupport/lib/active_support/core_ext/string/access.rb
index 64bc8f6cea..c0d5cdf2d5 100644
--- a/activesupport/lib/active_support/core_ext/string/access.rb
+++ b/activesupport/lib/active_support/core_ext/string/access.rb
@@ -4,27 +4,27 @@ class String
unless '1.9'.respond_to?(:force_encoding)
# Returns the character at the +position+ treating the string as an array (where 0 is the first character).
#
- # Examples:
+ # Examples:
# "hello".at(0) # => "h"
# "hello".at(4) # => "o"
# "hello".at(10) # => ERROR if < 1.9, nil in 1.9
def at(position)
mb_chars[position, 1].to_s
end
-
+
# Returns the remaining of the string from the +position+ treating the string as an array (where 0 is the first character).
#
- # Examples:
+ # Examples:
# "hello".from(0) # => "hello"
# "hello".from(2) # => "llo"
# "hello".from(10) # => "" if < 1.9, nil in 1.9
def from(position)
mb_chars[position..-1].to_s
end
-
+
# Returns the beginning of the string up to the +position+ treating the string as an array (where 0 is the first character).
#
- # Examples:
+ # Examples:
# "hello".to(0) # => "h"
# "hello".to(2) # => "hel"
# "hello".to(10) # => "hello"
@@ -34,7 +34,7 @@ class String
# Returns the first character of the string or the first +limit+ characters.
#
- # Examples:
+ # Examples:
# "hello".first # => "h"
# "hello".first(2) # => "he"
# "hello".first(10) # => "hello"
@@ -50,7 +50,7 @@ class String
# Returns the last character of the string or the last +limit+ characters.
#
- # Examples:
+ # Examples:
# "hello".last # => "o"
# "hello".last(2) # => "lo"
# "hello".last(10) # => "hello"
diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb
index 32913a06ad..9a4e63672f 100644
--- a/activesupport/lib/active_support/core_ext/string/inflections.rb
+++ b/activesupport/lib/active_support/core_ext/string/inflections.rb
@@ -72,7 +72,7 @@ class String
alias_method :titlecase, :titleize
# The reverse of +camelize+. Makes an underscored, lowercase form from the expression in the string.
- #
+ #
# +underscore+ will also change '::' to '/' to convert namespaces to paths.
#
# "ActiveRecord".underscore # => "active_record"
@@ -97,7 +97,7 @@ class String
end
# Replaces special characters in a string so that it may be used as part of a 'pretty' URL.
- #
+ #
# ==== Examples
#
# class Person
@@ -105,10 +105,10 @@ class String
# "#{id}-#{name.parameterize}"
# end
# end
- #
+ #
# @person = Person.find(1)
# # => #<Person id: 1, name: "Donald E. Knuth">
- #
+ #
# <%= link_to(@person.name, person_path %>
# # => <a href="/person/1-donald-e-knuth">Donald E. Knuth</a>
def parameterize(sep = '-')
@@ -138,11 +138,11 @@ class String
def classify
ActiveSupport::Inflector.classify(self)
end
-
+
# Capitalizes the first word, turns underscores into spaces, and strips '_id'.
# Like +titleize+, this is meant for creating pretty output.
#
- # "employee_salary" # => "Employee salary"
+ # "employee_salary" # => "Employee salary"
# "author_id" # => "Author"
def humanize
ActiveSupport::Inflector.humanize(self)
diff --git a/activesupport/lib/active_support/core_ext/time/calculations.rb b/activesupport/lib/active_support/core_ext/time/calculations.rb
index 90b6cd3685..d430751623 100644
--- a/activesupport/lib/active_support/core_ext/time/calculations.rb
+++ b/activesupport/lib/active_support/core_ext/time/calculations.rb
@@ -92,12 +92,12 @@ class Time
options[:weeks], partial_weeks = options[:weeks].divmod(1)
options[:days] = (options[:days] || 0) + 7 * partial_weeks
end
-
+
unless options[:days].nil?
options[:days], partial_days = options[:days].divmod(1)
options[:hours] = (options[:hours] || 0) + 24 * partial_days
end
-
+
d = to_date.advance(options)
time_advanced_by_date = change(:year => d.year, :month => d.month, :day => d.day)
seconds_to_advance = (options[:seconds] || 0) + (options[:minutes] || 0) * 60 + (options[:hours] || 0) * 3600
diff --git a/activesupport/lib/active_support/core_ext/time/conversions.rb b/activesupport/lib/active_support/core_ext/time/conversions.rb
index 86103ebce2..025c619783 100644
--- a/activesupport/lib/active_support/core_ext/time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/time/conversions.rb
@@ -46,7 +46,7 @@ class Time
end
alias_method :to_default_s, :to_s
alias_method :to_s, :to_formatted_s
-
+
# Returns the UTC offset as an +HH:MM formatted string.
#
# Time.local(2000).formatted_offset # => "-06:00"
diff --git a/activesupport/lib/active_support/core_ext/time/zones.rb b/activesupport/lib/active_support/core_ext/time/zones.rb
index 6b9ee84d5c..ef401a6d18 100644
--- a/activesupport/lib/active_support/core_ext/time/zones.rb
+++ b/activesupport/lib/active_support/core_ext/time/zones.rb
@@ -4,13 +4,13 @@ class Time
class << self
attr_accessor :zone_default
- # Returns the TimeZone for the current request, if this has been set (via Time.zone=).
+ # Returns the TimeZone for the current request, if this has been set (via Time.zone=).
# If <tt>Time.zone</tt> has not been set for the current request, returns the TimeZone specified in <tt>config.time_zone</tt>.
def zone
Thread.current[:time_zone] || zone_default
end
- # Sets <tt>Time.zone</tt> to a TimeZone object for the current request/thread.
+ # Sets <tt>Time.zone</tt> to a TimeZone object for the current request/thread.
#
# This method accepts any of the following:
#
@@ -63,7 +63,7 @@ class Time
# This method is similar to Time#localtime, except that it uses <tt>Time.zone</tt> as the local zone
# instead of the operating system's time zone.
#
- # You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument,
+ # You can also pass in a TimeZone instance or string that identifies a TimeZone as an argument,
# and the conversion will be based on that zone instead of <tt>Time.zone</tt>.
#
# Time.utc(2000).in_time_zone('Alaska') # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
diff --git a/activesupport/lib/active_support/duration.rb b/activesupport/lib/active_support/duration.rb
index 7da357730b..a535e2b668 100644
--- a/activesupport/lib/active_support/duration.rb
+++ b/activesupport/lib/active_support/duration.rb
@@ -3,7 +3,7 @@ require 'active_support/core_ext/array/conversions'
require 'active_support/core_ext/object/acts_like'
module ActiveSupport
- # Provides accurate date and time measurements using Date#advance and
+ # Provides accurate date and time measurements using Date#advance and
# Time#advance, respectively. It mainly supports the methods on Numeric.
# Example:
#
diff --git a/activesupport/lib/active_support/i18n_railtie.rb b/activesupport/lib/active_support/i18n_railtie.rb
index db09919fd3..f8a5616a76 100644
--- a/activesupport/lib/active_support/i18n_railtie.rb
+++ b/activesupport/lib/active_support/i18n_railtie.rb
@@ -66,7 +66,7 @@ module I18n
I18n.fallbacks = I18n::Locale::Fallbacks.new(*args)
end
-
+
def self.validate_fallbacks(fallbacks)
case fallbacks
when ActiveSupport::OrderedOptions
diff --git a/activesupport/lib/active_support/lazy_load_hooks.rb b/activesupport/lib/active_support/lazy_load_hooks.rb
index ef43fc0431..3b8696b5c7 100644
--- a/activesupport/lib/active_support/lazy_load_hooks.rb
+++ b/activesupport/lib/active_support/lazy_load_hooks.rb
@@ -1,4 +1,4 @@
-# lazy_load_hooks allows rails to lazily load a lot of components and thus making the app boot faster. Because of
+# lazy_load_hooks allows rails to lazily load a lot of components and thus making the app boot faster. Because of
# this feature now there is no need to require <tt>ActiveRecord::Base</tt> at boot time purely to apply configuration. Instead
# a hook is registered that applies configuration once <tt>ActiveRecord::Base</tt> is loaded. Here <tt>ActiveRecord::Base</tt> is used
# as example but this feature can be applied elsewhere too.
@@ -12,7 +12,7 @@
# end
# end
#
-# When the entirety of +activerecord/lib/active_record/base.rb+ has been evaluated then +run_load_hooks+ is invoked.
+# When the entirety of +activerecord/lib/active_record/base.rb+ has been evaluated then +run_load_hooks+ is invoked.
# The very last line of +activerecord/lib/active_record/base.rb+ is:
#
# ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
diff --git a/activesupport/lib/active_support/locale/en.yml b/activesupport/lib/active_support/locale/en.yml
index 8f08f37a70..a1499bcc90 100644
--- a/activesupport/lib/active_support/locale/en.yml
+++ b/activesupport/lib/active_support/locale/en.yml
@@ -7,10 +7,10 @@ en:
default: "%Y-%m-%d"
short: "%b %d"
long: "%B %d, %Y"
-
+
day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]
-
+
# Don't forget the nil at the beginning; there's no such thing as a 0th month
month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
@@ -27,7 +27,7 @@ en:
long: "%B %d, %Y %H:%M"
am: "am"
pm: "pm"
-
+
# Used in array.to_sentence.
support:
array:
diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb
index 83930b3f0d..63c0470d3f 100644
--- a/activesupport/lib/active_support/log_subscriber.rb
+++ b/activesupport/lib/active_support/log_subscriber.rb
@@ -47,7 +47,7 @@ module ActiveSupport
# Embed in a String to clear all previous ANSI sequences.
CLEAR = "\e[0m"
BOLD = "\e[1m"
-
+
# Colors
BLACK = "\e[30m"
RED = "\e[31m"
diff --git a/activesupport/lib/active_support/log_subscriber/test_helper.rb b/activesupport/lib/active_support/log_subscriber/test_helper.rb
index 9e52cb97a9..5c24b9c759 100644
--- a/activesupport/lib/active_support/log_subscriber/test_helper.rb
+++ b/activesupport/lib/active_support/log_subscriber/test_helper.rb
@@ -12,7 +12,7 @@ module ActiveSupport
# def setup
# ActiveRecord::LogSubscriber.attach_to(:active_record)
# end
- #
+ #
# def test_basic_query_logging
# Developer.all
# wait
diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb
index 51fa626b45..d21f90f8b7 100644
--- a/activesupport/lib/active_support/message_encryptor.rb
+++ b/activesupport/lib/active_support/message_encryptor.rb
@@ -2,9 +2,9 @@ require 'openssl'
require 'active_support/base64'
module ActiveSupport
- # MessageEncryptor is a simple way to encrypt values which get stored somewhere
+ # MessageEncryptor is a simple way to encrypt values which get stored somewhere
# you don't trust.
- #
+ #
# The cipher text and initialization vector are base64 encoded and returned to you.
#
# This can be used in situations similar to the MessageVerifier, but where you don't
@@ -17,53 +17,53 @@ module ActiveSupport
@secret = secret
@cipher = cipher
end
-
+
def encrypt(value)
cipher = new_cipher
# Rely on OpenSSL for the initialization vector
iv = cipher.random_iv
-
- cipher.encrypt
+
+ cipher.encrypt
cipher.key = @secret
cipher.iv = iv
-
- encrypted_data = cipher.update(Marshal.dump(value))
+
+ encrypted_data = cipher.update(Marshal.dump(value))
encrypted_data << cipher.final
[encrypted_data, iv].map {|v| ActiveSupport::Base64.encode64s(v)}.join("--")
end
-
+
def decrypt(encrypted_message)
cipher = new_cipher
encrypted_data, iv = encrypted_message.split("--").map {|v| ActiveSupport::Base64.decode64(v)}
-
+
cipher.decrypt
cipher.key = @secret
cipher.iv = iv
decrypted_data = cipher.update(encrypted_data)
decrypted_data << cipher.final
-
+
Marshal.load(decrypted_data)
rescue OpenSSLCipherError, TypeError
raise InvalidMessage
end
-
+
def encrypt_and_sign(value)
verifier.generate(encrypt(value))
end
-
+
def decrypt_and_verify(value)
decrypt(verifier.verify(value))
end
-
-
-
- private
+
+
+
+ private
def new_cipher
OpenSSL::Cipher::Cipher.new(@cipher)
end
-
+
def verifier
MessageVerifier.new(@secret)
end
diff --git a/activesupport/lib/active_support/message_verifier.rb b/activesupport/lib/active_support/message_verifier.rb
index 6c46b68eaf..9a4468f73c 100644
--- a/activesupport/lib/active_support/message_verifier.rb
+++ b/activesupport/lib/active_support/message_verifier.rb
@@ -4,28 +4,28 @@ require 'active_support/core_ext/object/blank'
module ActiveSupport
# MessageVerifier makes it easy to generate and verify messages which are signed
# to prevent tampering.
- #
+ #
# This is useful for cases like remember-me tokens and auto-unsubscribe links where the
# session store isn't suitable or available.
#
# Remember Me:
# cookies[:remember_me] = @verifier.generate([@user.id, 2.weeks.from_now])
- #
+ #
# In the authentication filter:
#
# id, time = @verifier.verify(cookies[:remember_me])
# if time < Time.now
# self.current_user = User.find(id)
# end
- #
+ #
class MessageVerifier
class InvalidSignature < StandardError; end
-
+
def initialize(secret, digest = 'SHA1')
@secret = secret
@digest = digest
end
-
+
def verify(signed_message)
raise InvalidSignature if signed_message.blank?
@@ -36,12 +36,12 @@ module ActiveSupport
raise InvalidSignature
end
end
-
+
def generate(value)
data = ActiveSupport::Base64.encode64s(Marshal.dump(value))
"#{data}--#{generate_digest(data)}"
end
-
+
private
# constant-time comparison algorithm to prevent timing attacks
def secure_compare(a, b)
diff --git a/activesupport/lib/active_support/multibyte.rb b/activesupport/lib/active_support/multibyte.rb
index 8ffdf5a1bf..57e8e24bf4 100644
--- a/activesupport/lib/active_support/multibyte.rb
+++ b/activesupport/lib/active_support/multibyte.rb
@@ -6,7 +6,7 @@ module ActiveSupport #:nodoc:
autoload :EncodingError, 'active_support/multibyte/exceptions'
autoload :Chars, 'active_support/multibyte/chars'
autoload :Unicode, 'active_support/multibyte/unicode'
-
+
# The proxy class returned when calling mb_chars. You can use this accessor to configure your own proxy
# class so you can support other encodings. See the ActiveSupport::Multibyte::Chars implementation for
# an example how to do this.
diff --git a/activesupport/lib/active_support/ordered_hash.rb b/activesupport/lib/active_support/ordered_hash.rb
index 2e8d538d0b..dfc3f01fa2 100644
--- a/activesupport/lib/active_support/ordered_hash.rb
+++ b/activesupport/lib/active_support/ordered_hash.rb
@@ -8,12 +8,12 @@ module ActiveSupport
# The order of iteration over hashes in Ruby 1.8 is undefined. For example, you do not know the
# order in which +keys+ will return keys, or +each+ yield pairs. <tt>ActiveSupport::OrderedHash</tt>
# implements a hash that preserves insertion order, as in Ruby 1.9:
- #
+ #
# oh = ActiveSupport::OrderedHash.new
# oh[:a] = 1
# oh[:b] = 2
# oh.keys # => [:a, :b], this order is guaranteed
- #
+ #
# <tt>ActiveSupport::OrderedHash</tt> is namespaced to prevent conflicts with other implementations.
class OrderedHash < ::Hash #:nodoc:
def to_yaml_type
diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb
index 7fc2b45b51..37e357552c 100644
--- a/activesupport/lib/active_support/ordered_options.rb
+++ b/activesupport/lib/active_support/ordered_options.rb
@@ -1,13 +1,13 @@
require 'active_support/ordered_hash'
# Usually key value pairs are handled something like this:
-#
+#
# h = ActiveSupport::OrderedOptions.new
# h[:boy] = 'John'
# h[:girl] = 'Mary'
# h[:boy] # => 'John'
# h[:girl] # => 'Mary'
-#
+#
# Using <tt>OrderedOptions</tt> above code could be reduced to:
#
# h = ActiveSupport::OrderedOptions.new
@@ -15,7 +15,7 @@ require 'active_support/ordered_hash'
# h.girl = 'Mary'
# h.boy # => 'John'
# h.girl # => 'Mary'
-#
+#
module ActiveSupport #:nodoc:
class OrderedOptions < OrderedHash
def []=(key, value)
diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb
index 33793f0688..8c68f42781 100644
--- a/activesupport/lib/active_support/testing/assertions.rb
+++ b/activesupport/lib/active_support/testing/assertions.rb
@@ -63,14 +63,14 @@ module ActiveSupport
def assert_no_difference(expression, message = nil, &block)
assert_difference expression, 0, message, &block
end
-
+
# Test if an expression is blank. Passes if object.blank? is true.
#
# assert_blank [] # => true
def assert_blank(object)
assert object.blank?, "#{object.inspect} is not blank"
end
-
+
# Test if an expression is not blank. Passes if object.present? is true.
#
# assert_present {:data => 'x' } # => true
diff --git a/activesupport/lib/active_support/testing/declarative.rb b/activesupport/lib/active_support/testing/declarative.rb
index 70a6c2ca60..1c05d45888 100644
--- a/activesupport/lib/active_support/testing/declarative.rb
+++ b/activesupport/lib/active_support/testing/declarative.rb
@@ -1,10 +1,10 @@
module ActiveSupport
module Testing
module Declarative
-
+
def self.extended(klass)
klass.class_eval do
-
+
unless method_defined?(:describe)
def self.describe(text)
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
@@ -14,9 +14,9 @@ module ActiveSupport
RUBY_EVAL
end
end
-
+
end
- end
+ end
unless defined?(Spec)
# test "verify something" do
diff --git a/activesupport/lib/active_support/testing/pending.rb b/activesupport/lib/active_support/testing/pending.rb
index 21134ff9e2..39d1f50125 100644
--- a/activesupport/lib/active_support/testing/pending.rb
+++ b/activesupport/lib/active_support/testing/pending.rb
@@ -25,13 +25,13 @@ module ActiveSupport
failed = true
end
- flunk("<#{description}> did not fail.") unless failed
+ flunk("<#{description}> did not fail.") unless failed
end
caller[0] =~ (/(.*):(.*):in `(.*)'/)
@@pending_cases << "#{$3} at #{$1}, line #{$2}"
print "P"
-
+
@@at_exit ||= begin
at_exit do
puts "\nPending Cases:"
@@ -42,7 +42,7 @@ module ActiveSupport
end
end
end
-
+
end
end
end \ No newline at end of file
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index ad6c3de1f5..48c7990b1e 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -18,7 +18,7 @@ module ActiveSupport
#
# See Time and TimeZone for further documentation of these methods.
#
- # TimeWithZone instances implement the same API as Ruby Time instances, so that Time and TimeWithZone instances are interchangeable.
+ # TimeWithZone instances implement the same API as Ruby Time instances, so that Time and TimeWithZone instances are interchangeable.
# Examples:
#
# t = Time.zone.now # => Sun, 18 May 2008 13:27:25 EDT -04:00
@@ -36,7 +36,7 @@ module ActiveSupport
def self.name
'Time' # Report class name as 'Time' to thwart type checking
end
-
+
include Comparable
attr_reader :time_zone
diff --git a/activesupport/lib/active_support/xml_mini/rexml.rb b/activesupport/lib/active_support/xml_mini/rexml.rb
index a58f22ee5d..36692af1d3 100644
--- a/activesupport/lib/active_support/xml_mini/rexml.rb
+++ b/activesupport/lib/active_support/xml_mini/rexml.rb
@@ -19,7 +19,7 @@ module ActiveSupport
if !data.respond_to?(:read)
data = StringIO.new(data || '')
end
-
+
char = data.getc
if char.nil?
{}
diff --git a/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb b/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb
index 77ea230d2c..57a13d89ea 100644
--- a/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb
+++ b/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb
@@ -1,7 +1,7 @@
class ClassFolder
class NestedClass
end
-
+
class SiblingClass
end
end
diff --git a/activesupport/test/clean_backtrace_test.rb b/activesupport/test/clean_backtrace_test.rb
index 86838a7f9a..32e346bb48 100644
--- a/activesupport/test/clean_backtrace_test.rb
+++ b/activesupport/test/clean_backtrace_test.rb
@@ -5,7 +5,7 @@ class BacktraceCleanerFilterTest < ActiveSupport::TestCase
@bc = ActiveSupport::BacktraceCleaner.new
@bc.add_filter { |line| line.gsub("/my/prefix", '') }
end
-
+
test "backtrace should not contain prefix when it has been filtered out" do
assert_equal "/my/class.rb", @bc.clean([ "/my/prefix/my/class.rb" ]).first
end
@@ -14,14 +14,14 @@ class BacktraceCleanerFilterTest < ActiveSupport::TestCase
@bc.remove_filters!
assert_equal "/my/prefix/my/class.rb", @bc.clean(["/my/prefix/my/class.rb"]).first
end
-
+
test "backtrace should contain unaltered lines if they dont match a filter" do
assert_equal "/my/other_prefix/my/class.rb", @bc.clean([ "/my/other_prefix/my/class.rb" ]).first
end
-
+
test "backtrace should filter all lines in a backtrace" do
assert_equal \
- ["/my/class.rb", "/my/module.rb"],
+ ["/my/class.rb", "/my/module.rb"],
@bc.clean([ "/my/prefix/my/class.rb", "/my/prefix/my/module.rb" ])
end
end
@@ -31,10 +31,10 @@ class BacktraceCleanerSilencerTest < ActiveSupport::TestCase
@bc = ActiveSupport::BacktraceCleaner.new
@bc.add_silencer { |line| line =~ /mongrel/ }
end
-
+
test "backtrace should not contain lines that match the silencer" do
assert_equal \
- [ "/other/class.rb" ],
+ [ "/other/class.rb" ],
@bc.clean([ "/mongrel/class.rb", "/other/class.rb", "/mongrel/stuff.rb" ])
end
end
@@ -45,7 +45,7 @@ class BacktraceCleanerFilterAndSilencerTest < ActiveSupport::TestCase
@bc.add_filter { |line| line.gsub("/mongrel", "") }
@bc.add_silencer { |line| line =~ /mongrel/ }
end
-
+
test "backtrace should not silence lines that has first had their silence hook filtered out" do
assert_equal [ "/class.rb" ], @bc.clean([ "/mongrel/class.rb" ])
end
diff --git a/activesupport/test/clean_logger_test.rb b/activesupport/test/clean_logger_test.rb
index 6c4ec5ac46..2cc46904b4 100644
--- a/activesupport/test/clean_logger_test.rb
+++ b/activesupport/test/clean_logger_test.rb
@@ -41,7 +41,7 @@ class CleanLoggerTest < Test::Unit::TestCase
assert_equal "error\nfatal\nerror\nfatal\nunsilenced\n", @out.string
end
-
+
def test_datetime_format
@logger.formatter = Logger::Formatter.new
@logger.datetime_format = "%Y-%m-%d"
@@ -49,7 +49,7 @@ class CleanLoggerTest < Test::Unit::TestCase
assert_equal "%Y-%m-%d", @logger.datetime_format
assert_match(/D, \[\d\d\d\d-\d\d-\d\d#\d+\] DEBUG -- : debug/, @out.string)
end
-
+
def test_nonstring_formatting
an_object = [1, 2, 3, 4, 5]
@logger.debug an_object
diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb
index 009a254c64..d14ae39737 100644
--- a/activesupport/test/core_ext/array_ext_test.rb
+++ b/activesupport/test/core_ext/array_ext_test.rb
@@ -18,10 +18,10 @@ class ArrayExtAccessTests < Test::Unit::TestCase
assert_equal %w( a b c ), %w( a b c d ).to(2)
assert_equal %w( a b c d ), %w( a b c d ).to(10)
end
-
+
def test_second_through_tenth
array = (1..42).to_a
-
+
assert_equal array[1], array.second
assert_equal array[2], array.third
assert_equal array[3], array.fourth
@@ -319,7 +319,7 @@ class ArrayExtractOptionsTests < Test::Unit::TestCase
assert_equal({}, options)
assert_equal [hash], array
end
-
+
def test_extract_options_extracts_extractable_subclass
hash = ExtractableHashSubclass.new
hash[:foo] = 1
@@ -370,14 +370,14 @@ class ArrayExtRandomTests < ActiveSupport::TestCase
assert_equal 2, s.size
assert_equal 1, (a-s).size
assert_equal [], a-(0..20).sum{a.sample(2)}
-
+
o = Object.new
def o.to_int; 1; end
assert_equal [0], [0].sample(o)
-
+
o = Object.new
assert_raises(TypeError) { [0].sample(o) }
-
+
o = Object.new
def o.to_int; ''; end
assert_raises(TypeError) { [0].sample(o) }
diff --git a/activesupport/test/core_ext/class/attribute_accessor_test.rb b/activesupport/test/core_ext/class/attribute_accessor_test.rb
index 2c896d0cdb..456f4b7948 100644
--- a/activesupport/test/core_ext/class/attribute_accessor_test.rb
+++ b/activesupport/test/core_ext/class/attribute_accessor_test.rb
@@ -10,27 +10,27 @@ class ClassAttributeAccessorTest < Test::Unit::TestCase
end
@object = @class.new
end
-
+
def test_should_use_mattr_default
assert_nil @class.foo
assert_nil @object.foo
end
-
+
def test_should_set_mattr_value
@class.foo = :test
assert_equal :test, @object.foo
-
+
@object.foo = :test2
assert_equal :test2, @class.foo
end
-
+
def test_should_not_create_instance_writer
assert_respond_to @class, :foo
assert_respond_to @class, :foo=
assert_respond_to @object, :bar
assert !@object.respond_to?(:bar=)
end
-
+
def test_should_not_create_instance_reader
assert_respond_to @class, :shaq
assert !@object.respond_to?(:shaq)
diff --git a/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb b/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb
index 63ea46b564..b284e5ee1c 100644
--- a/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb
+++ b/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb
@@ -21,7 +21,7 @@ class ClassInheritableAttributesTest < Test::Unit::TestCase
assert_respond_to @klass.new, :a=
end
end
-
+
def test_writer_declaration_without_instance_writer
assert_nothing_raised do
@klass.class_inheritable_writer :a, :instance_writer => false
@@ -39,7 +39,7 @@ class ClassInheritableAttributesTest < Test::Unit::TestCase
assert_respond_to @klass.new, :a=
end
end
-
+
def test_accessor_declaration_without_instance_writer
assert_nothing_raised do
@klass.class_inheritable_accessor :a, :instance_writer => false
@@ -176,37 +176,37 @@ class ClassInheritableAttributesTest < Test::Unit::TestCase
assert_equal 'b', @klass.b
assert_equal 'B', @sub.b
end
-
+
def test_array_inheritance
@klass.class_inheritable_accessor :a
@klass.a = []
@sub = eval("class SubbyArray < @klass; end; SubbyArray")
-
+
assert_equal [], @klass.a
assert_equal [], @sub.a
-
+
@sub.a << :first
-
+
assert_equal [:first], @sub.a
assert_equal [], @klass.a
end
-
+
def test_array_inheritance_
@klass.class_inheritable_accessor :a
@klass.a = {}
@sub = eval("class SubbyHash < @klass; end; SubbyHash")
-
+
assert_equal Hash.new, @klass.a
assert_equal Hash.new, @sub.a
-
+
@sub.a[:first] = :first
-
+
assert_equal 1, @sub.a.keys.size
assert_equal 0, @klass.a.keys.size
end
-
+
def test_reset_inheritable_attributes
@klass.class_inheritable_accessor :a
@klass.a = 'a'
diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb
index 59c168d33d..3141e895e6 100644
--- a/activesupport/test/core_ext/date_ext_test.rb
+++ b/activesupport/test/core_ext/date_ext_test.rb
@@ -26,7 +26,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase
assert_equal year, Date.new(year).to_time(format).year
end
end
- end
+ end
end
def test_to_datetime
@@ -242,7 +242,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase
def test_yesterday_constructor
assert_equal Date.current - 1, Date.yesterday
end
-
+
def test_yesterday_constructor_when_zone_default_is_not_set
with_env_tz 'UTC' do
with_tz_default do
@@ -286,7 +286,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase
def test_since
assert_equal Time.local(2005,2,21,0,0,45), Date.new(2005,2,21).since(45)
end
-
+
def test_since_when_zone_default_is_set
zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']
with_env_tz 'UTC' do
@@ -300,7 +300,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase
def test_ago
assert_equal Time.local(2005,2,20,23,59,15), Date.new(2005,2,21).ago(45)
end
-
+
def test_ago_when_zone_default_is_set
zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']
with_env_tz 'UTC' do
@@ -314,7 +314,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase
def test_beginning_of_day
assert_equal Time.local(2005,2,21,0,0,0), Date.new(2005,2,21).beginning_of_day
end
-
+
def test_beginning_of_day_when_zone_default_is_set
zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']
with_env_tz 'UTC' do
@@ -328,7 +328,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase
def test_end_of_day
assert_equal Time.local(2005,2,21,23,59,59,999999.999), Date.new(2005,2,21).end_of_day
end
-
+
def test_end_of_day_when_zone_default_is_set
zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']
with_env_tz 'UTC' do
@@ -338,7 +338,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase
end
end
end
-
+
def test_xmlschema
with_env_tz 'US/Eastern' do
assert_match(/^1980-02-28T00:00:00-05:?00$/, Date.new(1980, 2, 28).xmlschema)
@@ -350,7 +350,7 @@ class DateExtCalculationsTest < ActiveSupport::TestCase
end
end
end
-
+
def test_xmlschema_when_zone_default_is_set
with_env_tz 'UTC' do
with_tz_default ActiveSupport::TimeZone['Eastern Time (US & Canada)'] do # UTC -5
diff --git a/activesupport/test/core_ext/date_time_ext_test.rb b/activesupport/test/core_ext/date_time_ext_test.rb
index e8506f5222..cb290c541b 100644
--- a/activesupport/test/core_ext/date_time_ext_test.rb
+++ b/activesupport/test/core_ext/date_time_ext_test.rb
@@ -242,7 +242,7 @@ class DateTimeExtCalculationsTest < Test::Unit::TestCase
assert_equal false, DateTime.civil(2005,2,10,15,30,45, Rational(-18000, 86400)).past?
assert_equal false, DateTime.civil(2005,2,10,15,30,46, Rational(-18000, 86400)).past?
end
-
+
def test_past_without_offset
DateTime.stubs(:current).returns(DateTime.civil(2005,2,10,15,30,45, Rational(-18000, 86400)))
assert_equal true, DateTime.civil(2005,2,10,20,30,44).past?
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb
index 710c221fac..8469f78566 100644
--- a/activesupport/test/core_ext/duration_test.rb
+++ b/activesupport/test/core_ext/duration_test.rb
@@ -117,13 +117,13 @@ class DurationTest < ActiveSupport::TestCase
ensure
Time.zone_default = nil
end
-
+
def test_adding_hours_across_dst_boundary
with_env_tz 'CET' do
assert_equal Time.local(2009,3,29,0,0,0) + 24.hours, Time.local(2009,3,30,1,0,0)
end
end
-
+
def test_adding_day_across_dst_boundary
with_env_tz 'CET' do
assert_equal Time.local(2009,3,29,0,0,0) + 1.day, Time.local(2009,3,30,0,0,0)
diff --git a/activesupport/test/core_ext/enumerable_test.rb b/activesupport/test/core_ext/enumerable_test.rb
index 4650b796b6..4655bfe519 100644
--- a/activesupport/test/core_ext/enumerable_test.rb
+++ b/activesupport/test/core_ext/enumerable_test.rb
@@ -89,7 +89,7 @@ class EnumerableTests < Test::Unit::TestCase
assert ![ 1, 2 ].many? {|x| x > 1 }
assert [ 1, 2, 2 ].many? {|x| x > 1 }
end
-
+
def test_exclude?
assert [ 1 ].exclude?(2)
assert ![ 1 ].exclude?(1)
diff --git a/activesupport/test/core_ext/hash_ext_test.rb b/activesupport/test/core_ext/hash_ext_test.rb
index 5d9846a216..fc8d8170a1 100644
--- a/activesupport/test/core_ext/hash_ext_test.rb
+++ b/activesupport/test/core_ext/hash_ext_test.rb
@@ -640,12 +640,12 @@ class HashToXmlTest < Test::Unit::TestCase
EOT
expected_topic_hash = {
- :title => nil,
+ :title => nil,
:id => nil,
:approved => nil,
:written_on => nil,
:viewed_at => nil,
- :content => nil,
+ :content => nil,
:parent_id => nil
}.stringify_keys
@@ -723,7 +723,7 @@ class HashToXmlTest < Test::Unit::TestCase
assert_equal expected_topic_hash, Hash.from_xml(topic_xml)["rsp"]["photos"]["photo"]
end
-
+
def test_all_caps_key_from_xml
test_xml = <<-EOT
<ABC3XYZ>
@@ -839,13 +839,13 @@ class HashToXmlTest < Test::Unit::TestCase
assert_equal expected_bacon_hash, Hash.from_xml(bacon_xml)["bacon"]
end
-
+
def test_type_trickles_through_when_unknown
product_xml = <<-EOT
<product>
<weight type="double">0.5</weight>
<image type="ProductImage"><filename>image.gif</filename></image>
-
+
</product>
EOT
@@ -854,7 +854,7 @@ class HashToXmlTest < Test::Unit::TestCase
:image => {'type' => 'ProductImage', 'filename' => 'image.gif' },
}.stringify_keys
- assert_equal expected_product_hash, Hash.from_xml(product_xml)["product"]
+ assert_equal expected_product_hash, Hash.from_xml(product_xml)["product"]
end
def test_should_use_default_value_for_unknown_key
@@ -888,41 +888,41 @@ class HashToXmlTest < Test::Unit::TestCase
assert_equal expected, hash.to_xml(@xml_options)
end
end
-
- def test_empty_string_works_for_typecast_xml_value
+
+ def test_empty_string_works_for_typecast_xml_value
assert_nothing_raised do
Hash.__send__(:typecast_xml_value, "")
end
end
-
+
def test_escaping_to_xml
- hash = {
- :bare_string => 'First & Last Name',
+ hash = {
+ :bare_string => 'First & Last Name',
:pre_escaped_string => 'First &amp; Last Name'
}.stringify_keys
-
+
expected_xml = '<person><bare-string>First &amp; Last Name</bare-string><pre-escaped-string>First &amp;amp; Last Name</pre-escaped-string></person>'
assert_equal expected_xml, hash.to_xml(@xml_options)
end
-
+
def test_unescaping_from_xml
xml_string = '<person><bare-string>First &amp; Last Name</bare-string><pre-escaped-string>First &amp;amp; Last Name</pre-escaped-string></person>'
- expected_hash = {
- :bare_string => 'First & Last Name',
+ expected_hash = {
+ :bare_string => 'First & Last Name',
:pre_escaped_string => 'First &amp; Last Name'
}.stringify_keys
assert_equal expected_hash, Hash.from_xml(xml_string)['person']
end
-
+
def test_roundtrip_to_xml_from_xml
- hash = {
- :bare_string => 'First & Last Name',
+ hash = {
+ :bare_string => 'First & Last Name',
:pre_escaped_string => 'First &amp; Last Name'
}.stringify_keys
assert_equal hash, Hash.from_xml(hash.to_xml(@xml_options))['person']
end
-
+
def test_datetime_xml_type_with_utc_time
alert_xml = <<-XML
<alert>
@@ -933,7 +933,7 @@ class HashToXmlTest < Test::Unit::TestCase
assert alert_at.utc?
assert_equal Time.utc(2008, 2, 10, 15, 30, 45), alert_at
end
-
+
def test_datetime_xml_type_with_non_utc_time
alert_xml = <<-XML
<alert>
@@ -944,7 +944,7 @@ class HashToXmlTest < Test::Unit::TestCase
assert alert_at.utc?
assert_equal Time.utc(2008, 2, 10, 15, 30, 45), alert_at
end
-
+
def test_datetime_xml_type_with_far_future_date
alert_xml = <<-XML
<alert>
diff --git a/activesupport/test/core_ext/kernel_test.rb b/activesupport/test/core_ext/kernel_test.rb
index c22af89918..228b644c1a 100644
--- a/activesupport/test/core_ext/kernel_test.rb
+++ b/activesupport/test/core_ext/kernel_test.rb
@@ -46,7 +46,7 @@ class KernelTest < Test::Unit::TestCase
o = Object.new
assert_equal class << o; self end, o.singleton_class
end
-
+
def test_class_eval
o = Object.new
class << o; @x = 1; end
diff --git a/activesupport/test/core_ext/module/anonymous_test.rb b/activesupport/test/core_ext/module/anonymous_test.rb
index 7a78a3b012..cb556af772 100644
--- a/activesupport/test/core_ext/module/anonymous_test.rb
+++ b/activesupport/test/core_ext/module/anonymous_test.rb
@@ -6,7 +6,7 @@ class AnonymousTest < ActiveSupport::TestCase
assert Module.new.anonymous?
assert Class.new.anonymous?
end
-
+
test "a named class or module are not anonymous" do
assert !Kernel.anonymous?
assert !Object.anonymous?
diff --git a/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb b/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb
index 7c0d0bb242..9494ca9ef6 100644
--- a/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb
+++ b/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb
@@ -7,24 +7,24 @@ class AttrAccessorWithDefaultTest < Test::Unit::TestCase
def helper
'helper'
end
- end
+ end
@instance = @target.new
end
-
+
def test_default_arg
@target.attr_accessor_with_default :foo, :bar
assert_equal(:bar, @instance.foo)
@instance.foo = nil
assert_nil(@instance.foo)
end
-
+
def test_default_proc
@target.attr_accessor_with_default(:foo) {helper.upcase}
assert_equal('HELPER', @instance.foo)
@instance.foo = nil
assert_nil(@instance.foo)
end
-
+
def test_invalid_args
assert_raise(RuntimeError) {@target.attr_accessor_with_default :foo}
end
diff --git a/activesupport/test/core_ext/module/attribute_accessor_test.rb b/activesupport/test/core_ext/module/attribute_accessor_test.rb
index 67fcd437d0..118fb070a0 100644
--- a/activesupport/test/core_ext/module/attribute_accessor_test.rb
+++ b/activesupport/test/core_ext/module/attribute_accessor_test.rb
@@ -32,7 +32,7 @@ class ModuleAttributeAccessorTest < Test::Unit::TestCase
assert_respond_to @object, :bar
assert !@object.respond_to?(:bar=)
end
-
+
def test_should_not_create_instance_reader
assert_respond_to @module, :shaq
assert !@object.respond_to?(:shaq)
diff --git a/activesupport/test/core_ext/module/attribute_aliasing_test.rb b/activesupport/test/core_ext/module/attribute_aliasing_test.rb
index f17d031662..065c3531e0 100644
--- a/activesupport/test/core_ext/module/attribute_aliasing_test.rb
+++ b/activesupport/test/core_ext/module/attribute_aliasing_test.rb
@@ -44,14 +44,14 @@ class AttributeAliasingTest < Test::Unit::TestCase
# upper-case attributes, and when people want to alias those names
# to more sensible ones, everything goes *foof*.
e = AttributeAliasing::Email.new
-
+
assert !e.body?
assert !e.Data?
-
+
e.body = "No, really, this is not a joke."
assert_equal "No, really, this is not a joke.", e.Data
assert e.Data?
-
+
e.Data = "Uppercased methods are teh suck"
assert_equal "Uppercased methods are teh suck", e.body
assert e.body?
diff --git a/activesupport/test/core_ext/module/reachable_test.rb b/activesupport/test/core_ext/module/reachable_test.rb
index 72892b77d5..80eb31a5c4 100644
--- a/activesupport/test/core_ext/module/reachable_test.rb
+++ b/activesupport/test/core_ext/module/reachable_test.rb
@@ -6,33 +6,33 @@ class AnonymousTest < ActiveSupport::TestCase
assert !Module.new.reachable?
assert !Class.new.reachable?
end
-
+
test "ordinary named classes or modules are reachable" do
assert Kernel.reachable?
assert Object.reachable?
end
-
+
test "a named class or module whose constant has gone is not reachable" do
c = eval "class C; end; C"
m = eval "module M; end; M"
-
+
self.class.send(:remove_const, :C)
self.class.send(:remove_const, :M)
-
+
assert !c.reachable?
assert !m.reachable?
end
-
+
test "a named class or module whose constants store different objects are not reachable" do
c = eval "class C; end; C"
m = eval "module M; end; M"
-
+
self.class.send(:remove_const, :C)
- self.class.send(:remove_const, :M)
+ self.class.send(:remove_const, :M)
eval "class C; end"
eval "module M; end"
-
+
assert C.reachable?
assert M.reachable?
assert !c.reachable?
diff --git a/activesupport/test/core_ext/numeric_ext_test.rb b/activesupport/test/core_ext/numeric_ext_test.rb
index 992ec60302..e40b487753 100644
--- a/activesupport/test/core_ext/numeric_ext_test.rb
+++ b/activesupport/test/core_ext/numeric_ext_test.rb
@@ -38,7 +38,7 @@ class NumericExtTimeAndDateTimeTest < Test::Unit::TestCase
assert seconds.from_now >= now + seconds
end
end
-
+
def test_irregular_durations
assert_equal @now.advance(:days => 3000), 3000.days.since(@now)
assert_equal @now.advance(:months => 1), 1.month.since(@now)
@@ -49,16 +49,16 @@ class NumericExtTimeAndDateTimeTest < Test::Unit::TestCase
assert_equal @dtnow.advance(:months => -1), 1.month.until(@dtnow)
assert_equal @dtnow.advance(:years => 20), 20.years.since(@dtnow)
end
-
+
def test_duration_addition
assert_equal @now.advance(:days => 1).advance(:months => 1), (1.day + 1.month).since(@now)
assert_equal @now.advance(:days => 7), (1.week + 5.seconds - 5.seconds).since(@now)
assert_equal @now.advance(:years => 2), (4.years - 2.years).since(@now)
assert_equal @dtnow.advance(:days => 1).advance(:months => 1), (1.day + 1.month).since(@dtnow)
assert_equal @dtnow.advance(:days => 7), (1.week + 5.seconds - 5.seconds).since(@dtnow)
- assert_equal @dtnow.advance(:years => 2), (4.years - 2.years).since(@dtnow)
+ assert_equal @dtnow.advance(:years => 2), (4.years - 2.years).since(@dtnow)
end
-
+
def test_time_plus_duration
assert_equal @now + 8, @now + 8.seconds
assert_equal @now + 22.9, @now + 22.9.seconds
@@ -69,21 +69,21 @@ class NumericExtTimeAndDateTimeTest < Test::Unit::TestCase
assert_equal @dtnow.advance(:days => 15), @dtnow + 15.days
assert_equal @dtnow.advance(:months => 1), @dtnow + 1.month
end
-
+
def test_chaining_duration_operations
assert_equal @now.advance(:days => 2).advance(:months => -3), @now + 2.days - 3.months
assert_equal @now.advance(:days => 1).advance(:months => 2), @now + 1.day + 2.months
assert_equal @dtnow.advance(:days => 2).advance(:months => -3), @dtnow + 2.days - 3.months
- assert_equal @dtnow.advance(:days => 1).advance(:months => 2), @dtnow + 1.day + 2.months
+ assert_equal @dtnow.advance(:days => 1).advance(:months => 2), @dtnow + 1.day + 2.months
end
-
+
def test_duration_after_convertion_is_no_longer_accurate
assert_equal 30.days.to_i.since(@now), 1.month.to_i.since(@now)
assert_equal 365.25.days.to_f.since(@now), 1.year.to_f.since(@now)
assert_equal 30.days.to_i.since(@dtnow), 1.month.to_i.since(@dtnow)
- assert_equal 365.25.days.to_f.since(@dtnow), 1.year.to_f.since(@dtnow)
+ assert_equal 365.25.days.to_f.since(@dtnow), 1.year.to_f.since(@dtnow)
end
-
+
def test_add_one_year_to_leap_day
assert_equal Time.utc(2005,2,28,15,15,10), Time.utc(2004,2,29,15,15,10) + 1.year
assert_equal DateTime.civil(2005,2,28,15,15,10), DateTime.civil(2004,2,29,15,15,10) + 1.year
@@ -102,12 +102,12 @@ class NumericExtDateTest < Test::Unit::TestCase
assert_equal @today.to_time.since(60), @today + 1.minute
assert_equal @today.to_time.since(60*60), @today + 1.hour
end
-
+
def test_chaining_duration_operations
assert_equal @today.advance(:days => 2).advance(:months => -3), @today + 2.days - 3.months
assert_equal @today.advance(:days => 1).advance(:months => 2), @today + 1.day + 2.months
end
-
+
def test_add_one_year_to_leap_day
assert_equal Date.new(2005,2,28), Date.new(2004,2,29) + 1.year
end
@@ -132,7 +132,7 @@ class NumericExtSizeTest < Test::Unit::TestCase
assert_equal right, left
end
end
-
+
def test_units_as_bytes_independently
assert_equal 3145728, 3.megabytes
assert_equal 3145728, 3.megabyte
diff --git a/activesupport/test/core_ext/object_and_class_ext_test.rb b/activesupport/test/core_ext/object_and_class_ext_test.rb
index 6588f2e345..3ccf18f473 100644
--- a/activesupport/test/core_ext/object_and_class_ext_test.rb
+++ b/activesupport/test/core_ext/object_and_class_ext_test.rb
@@ -144,7 +144,7 @@ class ObjectTryTest < Test::Unit::TestCase
assert !@string.respond_to?(method)
assert_raise(NoMethodError) { @string.try(method) }
end
-
+
def test_valid_method
assert_equal 5, @string.try(:size)
end
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index affa1b5e18..f7e2ecd357 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -218,7 +218,7 @@ class StringInflectionsTest < Test::Unit::TestCase
# And changes the original string:
assert_equal original, expected
end
-
+
def test_truncate
assert_equal "Hello World!", "Hello World!".truncate(12)
assert_equal "Hello Wor...", "Hello World!!".truncate(12)
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 1cf84df386..c43b3eb358 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -187,7 +187,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2005,4,2,3,18,0), Time.local(2005,4,3,4,18,0).ago(24.hours), 'dt-24.hours=>st'
assert_equal Time.local(2005,4,2,3,18,0), Time.local(2005,4,3,4,18,0).ago(86400), 'dt-86400=>st'
assert_equal Time.local(2005,4,2,3,18,0), Time.local(2005,4,3,4,18,0).ago(86400.seconds), 'dt-86400.seconds=>st'
-
+
assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(24.hours), 'st-24.hours=>st'
assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(86400), 'st-86400=>st'
assert_equal Time.local(2005,4,1,4,18,0), Time.local(2005,4,2,4,18,0).ago(86400.seconds), 'st-86400.seconds=>st'
@@ -197,7 +197,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2006,9,30,3,18,0), Time.local(2006,10,1,4,18,0).ago(24.hours), 'dt-24.hours=>st'
assert_equal Time.local(2006,9,30,3,18,0), Time.local(2006,10,1,4,18,0).ago(86400), 'dt-86400=>st'
assert_equal Time.local(2006,9,30,3,18,0), Time.local(2006,10,1,4,18,0).ago(86400.seconds), 'dt-86400.seconds=>st'
-
+
assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(24.hours), 'st-24.hours=>st'
assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(86400), 'st-86400=>st'
assert_equal Time.local(2006,9,29,4,18,0), Time.local(2006,9,30,4,18,0).ago(86400.seconds), 'st-86400.seconds=>st'
@@ -210,7 +210,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2005,10,29,5,3), Time.local(2005,10,30,4,3,0).ago(24.hours), 'st-24.hours=>dt'
assert_equal Time.local(2005,10,29,5,3), Time.local(2005,10,30,4,3,0).ago(86400), 'st-86400=>dt'
assert_equal Time.local(2005,10,29,5,3), Time.local(2005,10,30,4,3,0).ago(86400.seconds), 'st-86400.seconds=>dt'
-
+
assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(24.hours), 'dt-24.hours=>dt'
assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(86400), 'dt-86400=>dt'
assert_equal Time.local(2005,10,28,4,3), Time.local(2005,10,29,4,3,0).ago(86400.seconds), 'dt-86400.seconds=>dt'
@@ -220,7 +220,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2006,3,18,5,3), Time.local(2006,3,19,4,3,0).ago(24.hours), 'st-24.hours=>dt'
assert_equal Time.local(2006,3,18,5,3), Time.local(2006,3,19,4,3,0).ago(86400), 'st-86400=>dt'
assert_equal Time.local(2006,3,18,5,3), Time.local(2006,3,19,4,3,0).ago(86400.seconds), 'st-86400.seconds=>dt'
-
+
assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(24.hours), 'dt-24.hours=>dt'
assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(86400), 'dt-86400=>dt'
assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(86400.seconds), 'dt-86400.seconds=>dt'
@@ -252,7 +252,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2006,3,17,4,3), Time.local(2006,3,18,4,3,0).ago(1.day), 'dt-1.day=>dt'
end
end
-
+
def test_since
assert_equal Time.local(2005,2,22,10,10,11), Time.local(2005,2,22,10,10,10).since(1)
assert_equal Time.local(2005,2,22,11,10,10), Time.local(2005,2,22,10,10,10).since(3600)
@@ -268,7 +268,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2005,4,3,20,27,0), Time.local(2005,4,2,19,27,0).since(24.hours), 'st+24.hours=>dt'
assert_equal Time.local(2005,4,3,20,27,0), Time.local(2005,4,2,19,27,0).since(86400), 'st+86400=>dt'
assert_equal Time.local(2005,4,3,20,27,0), Time.local(2005,4,2,19,27,0).since(86400.seconds), 'st+86400.seconds=>dt'
-
+
assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(24.hours), 'dt+24.hours=>dt'
assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(86400), 'dt+86400=>dt'
assert_equal Time.local(2005,4,4,19,27,0), Time.local(2005,4,3,19,27,0).since(86400.seconds), 'dt+86400.seconds=>dt'
@@ -278,7 +278,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2006,10,1,20,27,0), Time.local(2006,9,30,19,27,0).since(24.hours), 'st+24.hours=>dt'
assert_equal Time.local(2006,10,1,20,27,0), Time.local(2006,9,30,19,27,0).since(86400), 'st+86400=>dt'
assert_equal Time.local(2006,10,1,20,27,0), Time.local(2006,9,30,19,27,0).since(86400.seconds), 'st+86400.seconds=>dt'
-
+
assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(24.hours), 'dt+24.hours=>dt'
assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(86400), 'dt+86400=>dt'
assert_equal Time.local(2006,10,2,19,27,0), Time.local(2006,10,1,19,27,0).since(86400.seconds), 'dt+86400.seconds=>dt'
@@ -330,7 +330,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2005,10,30,23,45,0), Time.local(2005,10,30,0,45,0).since(24.hours), 'dt+24.hours=>st'
assert_equal Time.local(2005,10,30,23,45,0), Time.local(2005,10,30,0,45,0).since(86400), 'dt+86400=>st'
assert_equal Time.local(2005,10,30,23,45,0), Time.local(2005,10,30,0,45,0).since(86400.seconds), 'dt+86400.seconds=>st'
-
+
assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(24.hours), 'st+24.hours=>st'
assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(86400), 'st+86400=>st'
assert_equal Time.local(2005,11, 1,0,45,0), Time.local(2005,10,31,0,45,0).since(86400.seconds), 'st+86400.seconds=>st'
@@ -340,7 +340,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
assert_equal Time.local(2006,3,20,0,45,0), Time.local(2006,3,19,1,45,0).since(24.hours), 'dt+24.hours=>st'
assert_equal Time.local(2006,3,20,0,45,0), Time.local(2006,3,19,1,45,0).since(86400), 'dt+86400=>st'
assert_equal Time.local(2006,3,20,0,45,0), Time.local(2006,3,19,1,45,0).since(86400.seconds), 'dt+86400.seconds=>st'
-
+
assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(24.hours), 'st+24.hours=>st'
assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(86400), 'st+86400=>st'
assert_equal Time.local(2006,3,21,1,45,0), Time.local(2006,3,20,1,45,0).since(86400.seconds), 'st+86400.seconds=>st'
@@ -729,7 +729,7 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
def test_minus_with_time_with_zone
assert_equal 86_400.0, Time.utc(2000, 1, 2) - ActiveSupport::TimeWithZone.new( Time.utc(2000, 1, 1), ActiveSupport::TimeZone['UTC'] )
end
-
+
def test_minus_with_datetime
assert_equal 86_400.0, Time.utc(2000, 1, 2) - DateTime.civil(2000, 1, 1)
end
diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb
index 5ce4277672..0bb2c4a39e 100644
--- a/activesupport/test/core_ext/time_with_zone_test.rb
+++ b/activesupport/test/core_ext/time_with_zone_test.rb
@@ -287,7 +287,7 @@ class TimeWithZoneTest < Test::Unit::TestCase
assert_equal 946684800, result
assert_kind_of Integer, result
end
-
+
def test_to_i_with_wrapped_datetime
datetime = DateTime.civil(2000, 1, 1, 0)
twz = ActiveSupport::TimeWithZone.new(datetime, @time_zone)
@@ -328,7 +328,7 @@ class TimeWithZoneTest < Test::Unit::TestCase
assert_kind_of Time, @twz
assert_kind_of ActiveSupport::TimeWithZone, @twz
end
-
+
def test_class_name
assert_equal 'Time', ActiveSupport::TimeWithZone.name
end
@@ -703,7 +703,7 @@ class TimeWithZoneTest < Test::Unit::TestCase
assert_equal "Sun, 15 Jul 2007 10:30:00 EDT -04:00", twz.years_ago(1).inspect
assert_equal "Sun, 15 Jul 2007 10:30:00 EDT -04:00", (twz - 1.year).inspect
end
-
+
protected
def with_env_tz(new_tz = 'US/Eastern')
old_tz, ENV['TZ'] = ENV['TZ'], new_tz
diff --git a/activesupport/test/i18n_test.rb b/activesupport/test/i18n_test.rb
index dfcd4f822d..34825c9b8f 100644
--- a/activesupport/test/i18n_test.rb
+++ b/activesupport/test/i18n_test.rb
@@ -7,68 +7,68 @@ class I18nTest < Test::Unit::TestCase
@date = Date.parse("2008-7-2")
@time = Time.utc(2008, 7, 2, 16, 47, 1)
end
-
+
def test_time_zone_localization_with_default_format
now = Time.local(2000)
assert_equal now.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(now)
end
-
+
def test_date_localization_should_use_default_format
assert_equal @date.strftime("%Y-%m-%d"), I18n.localize(@date)
end
-
+
def test_date_localization_with_default_format
assert_equal @date.strftime("%Y-%m-%d"), I18n.localize(@date, :format => :default)
end
-
+
def test_date_localization_with_short_format
assert_equal @date.strftime("%b %d"), I18n.localize(@date, :format => :short)
end
-
+
def test_date_localization_with_long_format
assert_equal @date.strftime("%B %d, %Y"), I18n.localize(@date, :format => :long)
end
-
- def test_time_localization_should_use_default_format
+
+ def test_time_localization_should_use_default_format
assert_equal @time.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(@time)
end
-
+
def test_time_localization_with_default_format
assert_equal @time.strftime("%a, %d %b %Y %H:%M:%S %z"), I18n.localize(@time, :format => :default)
end
-
+
def test_time_localization_with_short_format
assert_equal @time.strftime("%d %b %H:%M"), I18n.localize(@time, :format => :short)
end
-
+
def test_time_localization_with_long_format
assert_equal @time.strftime("%B %d, %Y %H:%M"), I18n.localize(@time, :format => :long)
end
-
+
def test_day_names
assert_equal Date::DAYNAMES, I18n.translate(:'date.day_names')
end
-
+
def test_abbr_day_names
assert_equal Date::ABBR_DAYNAMES, I18n.translate(:'date.abbr_day_names')
end
-
+
def test_month_names
assert_equal Date::MONTHNAMES, I18n.translate(:'date.month_names')
end
-
+
def test_abbr_month_names
assert_equal Date::ABBR_MONTHNAMES, I18n.translate(:'date.abbr_month_names')
end
-
+
def test_date_order
assert_equal [:year, :month, :day], I18n.translate(:'date.order')
end
-
+
def test_time_am
assert_equal 'am', I18n.translate(:'time.am')
end
-
+
def test_time_pm
assert_equal 'pm', I18n.translate(:'time.pm')
end
diff --git a/activesupport/test/message_encryptor_test.rb b/activesupport/test/message_encryptor_test.rb
index 684b931176..419ac14283 100644
--- a/activesupport/test/message_encryptor_test.rb
+++ b/activesupport/test/message_encryptor_test.rb
@@ -14,18 +14,18 @@ class MessageEncryptorTest < Test::Unit::TestCase
@encryptor = ActiveSupport::MessageEncryptor.new(ActiveSupport::SecureRandom.hex(64))
@data = { :some => "data", :now => Time.local(2010) }
end
-
+
def test_simple_round_tripping
message = @encryptor.encrypt(@data)
assert_equal @data, @encryptor.decrypt(message)
end
-
+
def test_encrypting_twice_yields_differing_cipher_text
first_messqage = @encryptor.encrypt(@data)
second_message = @encryptor.encrypt(@data)
assert_not_equal first_messqage, second_message
end
-
+
def test_messing_with_either_value_causes_failure
text, iv = @encryptor.encrypt(@data).split("--")
assert_not_decrypted([iv, text] * "--")
@@ -33,20 +33,20 @@ class MessageEncryptorTest < Test::Unit::TestCase
assert_not_decrypted([munge(text), iv] * "--")
assert_not_decrypted([munge(text), munge(iv)] * "--")
end
-
+
def test_signed_round_tripping
message = @encryptor.encrypt_and_sign(@data)
assert_equal @data, @encryptor.decrypt_and_verify(message)
end
-
-
+
+
private
def assert_not_decrypted(value)
assert_raise(ActiveSupport::MessageEncryptor::InvalidMessage) do
@encryptor.decrypt(value)
end
end
-
+
def munge(base64_string)
bits = ActiveSupport::Base64.decode64(base64_string)
bits.reverse!
diff --git a/activesupport/test/multibyte_conformance.rb b/activesupport/test/multibyte_conformance.rb
index 6ec9a839af..b3b477bb75 100644
--- a/activesupport/test/multibyte_conformance.rb
+++ b/activesupport/test/multibyte_conformance.rb
@@ -27,21 +27,21 @@ end
class MultibyteConformanceTest < Test::Unit::TestCase
include MultibyteTestHelpers
-
+
UNIDATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::Unicode::UNICODE_VERSION}/ucd"
UNIDATA_FILE = '/NormalizationTest.txt'
CACHE_DIR = File.join(Dir.tmpdir, 'cache')
-
+
def setup
FileUtils.mkdir_p(CACHE_DIR)
Downloader.download(UNIDATA_URL + UNIDATA_FILE, CACHE_DIR + UNIDATA_FILE)
@proxy = ActiveSupport::Multibyte::Chars
end
-
+
def test_normalizations_C
each_line_of_norm_tests do |*cols|
col1, col2, col3, col4, col5, comment = *cols
-
+
# CONFORMANCE:
# 1. The following invariants must be true for all conformant implementations
#
@@ -56,7 +56,7 @@ class MultibyteConformanceTest < Test::Unit::TestCase
assert_equal_codepoints col4, @proxy.new(col5).normalize(:c), "Form C - Col 4 has to be C(5) - #{comment}"
end
end
-
+
def test_normalizations_D
each_line_of_norm_tests do |*cols|
col1, col2, col3, col4, col5, comment = *cols
@@ -71,10 +71,10 @@ class MultibyteConformanceTest < Test::Unit::TestCase
assert_equal_codepoints col5, @proxy.new(col5).normalize(:d), "Form D - Col 5 has to be NFD(5) - #{comment}"
end
end
-
+
def test_normalizations_KC
each_line_of_norm_tests do | *cols |
- col1, col2, col3, col4, col5, comment = *cols
+ col1, col2, col3, col4, col5, comment = *cols
#
# NFKC
# c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5)
@@ -85,10 +85,10 @@ class MultibyteConformanceTest < Test::Unit::TestCase
assert_equal_codepoints col4, @proxy.new(col5).normalize(:kc), "Form D - Col 4 has to be NFKC(5) - #{comment}"
end
end
-
+
def test_normalizations_KD
each_line_of_norm_tests do | *cols |
- col1, col2, col3, col4, col5, comment = *cols
+ col1, col2, col3, col4, col5, comment = *cols
#
# NFKD
# c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5)
@@ -99,7 +99,7 @@ class MultibyteConformanceTest < Test::Unit::TestCase
assert_equal_codepoints col5, @proxy.new(col5).normalize(:kd), "Form KD - Col 5 has to be NFKD(5) - #{comment}"
end
end
-
+
protected
def each_line_of_norm_tests(&block)
lines = 0
@@ -108,21 +108,21 @@ class MultibyteConformanceTest < Test::Unit::TestCase
until f.eof? || (max_test_lines > 38 and lines > max_test_lines)
lines += 1
line = f.gets.chomp!
- next if (line.empty? || line =~ /^\#/)
-
+ next if (line.empty? || line =~ /^\#/)
+
cols, comment = line.split("#")
cols = cols.split(";").map{|e| e.strip}.reject{|e| e.empty? }
next unless cols.length == 5
-
+
# codepoints are in hex in the test suite, pack wants them as integers
cols.map!{|c| c.split.map{|codepoint| codepoint.to_i(16)}.pack("U*") }
cols << comment
-
+
yield(*cols)
end
end
end
-
+
def inspect_codepoints(str)
str.to_s.unpack("U*").map{|cp| cp.to_s(16) }.join(' ')
end
diff --git a/activesupport/test/option_merger_test.rb b/activesupport/test/option_merger_test.rb
index 33e3e69666..5b2e16a212 100644
--- a/activesupport/test/option_merger_test.rb
+++ b/activesupport/test/option_merger_test.rb
@@ -65,7 +65,7 @@ class OptionMergerTest < Test::Unit::TestCase
end
end
end
-
+
def test_nested_method_with_options_using_lamdba
local_lamdba = lambda { { :lambda => true } }
with_options(@options) do |o|
diff --git a/activesupport/test/rescuable_test.rb b/activesupport/test/rescuable_test.rb
index 1c74ce8b2a..bf4f5265ef 100644
--- a/activesupport/test/rescuable_test.rb
+++ b/activesupport/test/rescuable_test.rb
@@ -24,7 +24,7 @@ class Stargate
rescue_from NuclearExplosion do
@result = 'alldead'
end
-
+
rescue_from MadRonon do |e|
@result = e.message
end
@@ -80,16 +80,16 @@ class RescueableTest < Test::Unit::TestCase
@stargate.dispatch :attack
assert_equal 'killed', @stargate.result
end
-
+
def test_rescue_from_with_block
@stargate.dispatch :nuke
assert_equal 'alldead', @stargate.result
end
-
+
def test_rescue_from_with_block_with_args
@stargate.dispatch :ronanize
assert_equal 'dex', @stargate.result
- end
+ end
def test_rescues_defined_later_are_added_at_end_of_the_rescue_handlers_array
expected = ["WraithAttack", "WraithAttack", "NuclearExplosion", "MadRonon"]
diff --git a/activesupport/test/test_test.rb b/activesupport/test/test_test.rb
index 633d3b212b..cdaf63961a 100644
--- a/activesupport/test/test_test.rb
+++ b/activesupport/test/test_test.rb
@@ -89,19 +89,19 @@ end
class AssertBlankTest < ActiveSupport::TestCase
BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", [], {} ]
NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'x', [nil], { nil => 0 } ]
-
+
def test_assert_blank_true
BLANK.each { |v| assert_blank v }
end
-
+
def test_assert_blank_false
NOT_BLANK.each { |v|
- begin
+ begin
assert_blank v
fail 'should not get to here'
rescue Exception => e
- assert_match(/is not blank/, e.message)
- end
+ assert_match(/is not blank/, e.message)
+ end
}
end
end
@@ -109,19 +109,19 @@ end
class AssertPresentTest < ActiveSupport::TestCase
BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", [], {} ]
NOT_BLANK = [ EmptyFalse.new, Object.new, true, 0, 1, 'x', [nil], { nil => 0 } ]
-
+
def test_assert_blank_true
NOT_BLANK.each { |v| assert_present v }
end
-
+
def test_assert_blank_false
BLANK.each { |v|
- begin
+ begin
assert_present v
fail 'should not get to here'
rescue Exception => e
- assert_match(/is blank/, e.message)
- end
+ assert_match(/is blank/, e.message)
+ end
}
end
end
diff --git a/activesupport/test/time_zone_test.rb b/activesupport/test/time_zone_test.rb
index af6eee69e5..49cefc6e82 100644
--- a/activesupport/test/time_zone_test.rb
+++ b/activesupport/test/time_zone_test.rb
@@ -216,7 +216,7 @@ class TimeZoneTest < Test::Unit::TestCase
assert_equal "+0000", ActiveSupport::TimeZone.seconds_to_utc_offset(0, false)
assert_equal "+0500", ActiveSupport::TimeZone.seconds_to_utc_offset(18_000, false)
end
-
+
def test_seconds_to_utc_offset_with_negative_offset
assert_equal "-01:00", ActiveSupport::TimeZone.seconds_to_utc_offset(-3_600)
assert_equal "-00:59", ActiveSupport::TimeZone.seconds_to_utc_offset(-3_599)
diff --git a/ci/ci_setup_notes.txt b/ci/ci_setup_notes.txt
index b61e893b8e..9451fb0dc6 100644
--- a/ci/ci_setup_notes.txt
+++ b/ci/ci_setup_notes.txt
@@ -26,7 +26,7 @@ $ sudo shutdown -r now
* Update aptitude:
$ sudo aptitude update
-* Use cinabox to perform rest of ruby/ccrb setup:
+* Use cinabox to perform rest of ruby/ccrb setup:
* http://github.com/thewoolleyman/cinabox/tree/master/README.txt
# This is not yet properly supported by RubyGems...
@@ -41,7 +41,7 @@ $ sudo aptitude update
# # add these lines:
# ---
# gemhome: /home/ci/.gem/ruby/1.8
-# gempath:
+# gempath:
# - /home/ci/.gem/ruby/1.8
* If you did not configure no-root-gem installation via ~/.gemrc as shown above, then allow no-password sudo for gem installation:
@@ -89,7 +89,7 @@ Configuration.dashboard_url = 'http://ci.yourdomain.com/'
Configuration.serialize_builds = true
Configuration.serialized_build_timeout = 1.hours
BuildReaper.number_of_builds_to_keep = 100
-
+
* Copy and configure cruise project config file
$ cp ~/.cruise/projects/rails/work/ci/cruise_config.rb ~/.cruise/projects/rails
$ vi ~/.cruise/projects/rails/cruise_config.rb:
diff --git a/ci/site_config.rb b/ci/site_config.rb
index c08dac8e84..09d5b550e8 100644
--- a/ci/site_config.rb
+++ b/ci/site_config.rb
@@ -6,10 +6,10 @@
# EMAIL NOTIFICATION
# ------------------
-# CruiseControl.rb can notify you about build status via email. It uses the Action Mailer component of Ruby on Rails
-# framework. Obviously, Action Mailer needs to know how to send out email messages.
+# CruiseControl.rb can notify you about build status via email. It uses the Action Mailer component of Ruby on Rails
+# framework. Obviously, Action Mailer needs to know how to send out email messages.
# If you have an SMTP server on your network, and it needs no authentication, write this in your site_config.rb:
-#
+#
ActionMailer::Base.smtp_settings = {
:address => "localhost",
:domain => "ci.rubyonrails.org",
@@ -26,8 +26,8 @@ ActionMailer::Base.smtp_settings = {
# :user_name => "yourgmailaccount",
# :password => "yourgmailpassword"
# }
-#
-# The same approach works for other SMTP servers thet require authentication. Note that GMail's SMTP server runs on a
+#
+# The same approach works for other SMTP servers thet require authentication. Note that GMail's SMTP server runs on a
# non-standard port 587 (standard port for SMTP is 25).
#
# For further details about configuration of outgoing email, see Ruby On Rails documentation for ActionMailer::Base.
@@ -63,7 +63,7 @@ Configuration.serialize_builds = true
# Amount of time a project will wait to build before failing when build serialization is on
Configuration.serialized_build_timeout = 3.hours
-# To delete build when there are more than a certain number present, uncomment this line - it will make the dashboard
+# To delete build when there are more than a certain number present, uncomment this line - it will make the dashboard
# perform better
BuildReaper.number_of_builds_to_keep = 100
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index fc1ec340c7..df6718764e 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -46,7 +46,7 @@
* Removed all the default commands in script/* and replaced them with script/rails and a rails command that'll act the same when run from within the app [DHH]. Example:
./script/generate scaffold post title:string can now be called as rails g scaffold post title:string
-
+
Run rails --help inside an app for more help.
* Removed config/initializers/new_rails_defaults.rb as all frameworks now follow the settings from it [DHH]
@@ -68,7 +68,7 @@
cookies.permanent.signed[:remember_me] = current_user.id
# => Set-Cookie: discount=BAhU--848956038e692d7046deab32b7131856ab20e14e; path=/; expires=Sun, 16-Dec-2029 03:24:16 GMT
-
+
...to use the signed cookies, you need to set a secret to ActionController::Base.cookie_verifier_secret (automatically done in config/initializers/cookie_verification_secret.rb for new Rails applications).
* Added config/initializers/cookie_verification_secret.rb with an auto-generated secret for using ActionController::Base#cookies.signed [DHH]
@@ -101,42 +101,42 @@
* Add "-m/--template" option to Rails generator to apply a template to the generated application. [Jeremy McAnally]
This has been extracted from rg - http://github.com/jeremymcanally/rg
-
+
Example:
-
+
# template.rb
-
+
# Install plugins from git or svn
plugin "will-paginate", :git => "git://github.com/mislav/will_paginate.git"
plugin "old-restful-auth", :svn => "http://svn.techno-weenie.net/projects/plugins/restful_authentication/"
-
+
# Add gems to environment.rb
gem "jeremymcanally-context"
gem "bluecloth"
-
+
# Vendor file. Data in a string or...
vendor("borrowed.rb", <<CODE
def helpful_method
do_something_helpful_here
end
CODE
-
+
# ...file data from block return value.
# #initializer creates a new initializer file
initializer("crypto.rb") do
salt = "--#{Time.now}--#{rand}--#{srand(Time.now.to_i)}"
-
+
"SPECIAL_SALT = '#{salt}'"
end
-
+
Usage:
-
+
To use a template, provide a file path or URL:
-
+
1. Using a local file :
rails <application name> -m /path/to/my/template.rb
-
+
2. Or directly from a URL :
rails <application name> --template=http://gist.github.com/31208.txt
@@ -235,7 +235,7 @@
rake gems:unpack # unpacks all gems
rake gems:unpack GEM=mygem # unpacks only the gem 'mygem'
-
+
rake gems:build # builds all unpacked gems
rake gems:build GEM=mygem # builds only the gem 'mygem'
@@ -246,16 +246,16 @@
* Allow files in plugins to be reloaded like the rest of the application. [Rick Olson]
Enables or disables plugin reloading.
-
+
config.reload_plugins = true
-
+
You can get around this setting per plugin.
If #reload_plugins? == false (DEFAULT), add this to your plugin's init.rb to make it reloadable:
-
+
Dependencies.load_once_paths.delete lib_path
-
+
If #reload_plugins? == true, add this to your plugin's init.rb to only load it once:
-
+
Dependencies.load_once_paths << lib_path
* Small tweak to allow plugins to specify gem dependencies. [Rick Olson]
@@ -280,13 +280,13 @@
config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
config.gem "aws-s3", :lib => "aws/s3"
end
-
+
# List required gems.
rake gems
-
+
# Install all required gems:
rake gems:install
-
+
# Unpack specified gem to vendor/gems/gem_name-x.x.x
rake gems:unpack GEM=bj
@@ -473,9 +473,9 @@ databases on localhost. #9753 [Trevor Wennblom]
For example:
ruby script/generation migration AddSomeStuffToCustomers first_name:string last_name:string
-
+
or
-
+
ruby script/generation migration RemoveSomeStuffFromCustomers first_name:string last_name:string
* Add ActiveResource to Rails::Info. Closes #8741 [Chris Kampmeier]
@@ -535,13 +535,13 @@ databases on localhost. #9753 [Trevor Wennblom]
* Removed breakpointer and Binding.of_caller in favor of relying on ruby-debug by Kent Sibilev since the breakpointer has been broken since Ruby 1.8.4 and will not be coming back [David Heinemeier Hansson]
To use the new debugger, start your server with script/server --debugger and insert a call to 'debugger'
- (instead of 'breakpoint') where you want to jump into the debugger.
-
+ (instead of 'breakpoint') where you want to jump into the debugger.
+
BACKWARDS INCOMPATIBILITY NOTE: You must remove the default line 12 from config/environments/development.rb:
-
+
config.breakpoint_server = true
-
- This configuration option is no longer available. Rails will fail to start in development mode as long as
+
+ This configuration option is no longer available. Rails will fail to start in development mode as long as
that's still present.
* Resource scaffolding returns the created entity.to_xml. [Jeremy Kemper]
@@ -553,7 +553,7 @@ databases on localhost. #9753 [Trevor Wennblom]
* Include Active Resource instead of Action Web Service [David Heinemeier Hansson] You can add AWS back with this in config/environment.rb:
config.load_paths += %W( #{RAILS_ROOT}/vendor/rails/actionwebservice/lib )
-
+
...or just gem 'actionwebservice'
* Give generate scaffold a more descriptive database message. Closes #7316 [Jeremy McAnally]
@@ -566,7 +566,7 @@ databases on localhost. #9753 [Trevor Wennblom]
* Windows: include MinGW in RUBY_PLATFORM check. #2982 [okkez000@gmail.com, Kaspar Schiess]
-* Split out the basic plugin locator functionality into an abstract super class. Add a FileSystemLocator to do the job of checking the plugin_paths for plugins. Add plugin_locators configuration option which will iterate over the set of plugin locators and load each of the plugin loaders they return. Rename locater everywhere to locator. [Marcel Molina Jr.]
+* Split out the basic plugin locator functionality into an abstract super class. Add a FileSystemLocator to do the job of checking the plugin_paths for plugins. Add plugin_locators configuration option which will iterate over the set of plugin locators and load each of the plugin loaders they return. Rename locater everywhere to locator. [Marcel Molina Jr.]
* Split plugin location and loading out of the initializer and into a new Plugin namespace, which includes Plugin::Locater and Plugin::Loader. The loader class that is used can be customized using the config.plugin_loader option. Those monkey patching the plugin loading subsystem take note, the internals changing here will likely break your modifications. The good news is that it should be substantially easier to hook into the plugin locating and loading process now. [Marcel Molina Jr.]
@@ -602,7 +602,7 @@ databases on localhost. #9753 [Trevor Wennblom]
* Ensure plugins are in the Dependencies.load_once_paths collection by default. [Rick Olson]
If you really want your plugins to reload, add this to the very top of init.rb:
-
+
Dependencies.load_once_paths.delete(lib_path)
* Allow config.to_prepare to work, make the dispatcher safe to 're require'. [Michael Koziarski, Nicholas Seckar]
@@ -724,9 +724,9 @@ databases on localhost. #9753 [Trevor Wennblom]
* Remove the uncanny default of adding all app/models/*/ directories to the load path. This change will break application which expect the current behavior. As
documented in initializer.rb, the workaround is:
-
+
config.autoload_paths += Dir[RAILS_ROOT + '/app/models/*/']
-
+
References #6031. [Nicholas Seckar]
* Update to script.aculo.us 1.6.3 [Thomas Fuchs]
@@ -811,10 +811,10 @@ References #6031. [Nicholas Seckar]
0002 def show
0003-> breakpoint
0004 end
- 0005
+ 0005
0006 def index
0007 end
- 0008
+ 0008
=> "/path/to/rails/root/app/controllers/top_controller.rb"
irb(#<TopController:0x40822a68>):004:0> show_call_stack 3
@@ -905,7 +905,7 @@ References #6031. [Nicholas Seckar]
* Ensure plugins are in the Dependencies.load_once_paths collection by default. [Rick Olson]
If you really want your plugins to reload, add this to the very top of init.rb:
-
+
Dependencies.load_once_paths.delete(lib_path)
* Fix scaffold_resource generator so it respects the --pretend argument when creating the routes file. Closes #6852 [fearoffish]
@@ -1011,9 +1011,9 @@ References #6031. [Nicholas Seckar]
* Remove the uncanny default of adding all app/models/*/ directories to the load path. This change will break application which expect the current behavior. As
documented in initializer.rb, the workaround is:
-
+
config.autoload_paths += Dir[RAILS_ROOT + '/app/models/*/']
-
+
References #6031. [Nicholas Seckar]
* Update to script.aculo.us 1.6.3 [Thomas Fuchs]
@@ -1094,10 +1094,10 @@ References #6031. [Nicholas Seckar]
0002 def show
0003-> breakpoint
0004 end
- 0005
+ 0005
0006 def index
0007 end
- 0008
+ 0008
=> "/path/to/rails/root/app/controllers/top_controller.rb"
irb(#<TopController:0x40822a68>):004:0> show_call_stack 3
@@ -1332,7 +1332,7 @@ References #6031. [Nicholas Seckar]
* Changed the default session configuration to place sessions in tmp/sessions, if that directory is available, instead of /tmp (this essentially means a goodbye to 9/10 White Screen of Death errors and should have web hosting firms around the world cheering) [David Heinemeier Hansson]
-* Added tmp/sessions, tmp/cache, and tmp/sockets as default directories in the Rails skeleton [David Heinemeier Hansson]
+* Added tmp/sessions, tmp/cache, and tmp/sockets as default directories in the Rails skeleton [David Heinemeier Hansson]
* Added that script/generate model will now automatically create a migration file for the model created. This can be turned off by calling the generator with --skip-migration [David Heinemeier Hansson]
@@ -1711,7 +1711,7 @@ References #6031. [Nicholas Seckar]
# runs the one statement 10 times
script/benchmarker 10 'Person.expensive_method(10)'
-
+
# pits the two statements against each other with 50 runs each
script/benchmarker 50 'Person.expensive_method(10)' 'Person.cheap_method(10)'
@@ -1751,18 +1751,18 @@ References #6031. [Nicholas Seckar]
* Changed .htaccess to allow dispatch.* to be called from a sub-directory as part of the push with Action Pack to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Lütke]
* Added script/runner which can be used to run code inside the environment by eval'ing the first parameter. Examples:
-
+
./script/runner 'ReminderService.deliver'
./script/runner 'Mailer.receive(STDIN.read)'
-
+
This makes it easier to do CRON and postfix scripts without actually making a script just to trigger 1 line of code.
* Fixed webrick_server cookie handling to allow multiple cookes to be set at once #800, #813 [dave@cherryville.org]
* Fixed the Rakefile's interaction with postgresql to:
- 1. Use PGPASSWORD and PGHOST in the environment to fix prompting for
- passwords when connecting to a remote db and local socket connections.
+ 1. Use PGPASSWORD and PGHOST in the environment to fix prompting for
+ passwords when connecting to a remote db and local socket connections.
2. Add a '-x' flag to pg_dump which stops it dumping privileges #807 [rasputnik]
3. Quote the user name and use template0 when dumping so the functions doesn't get dumped too #855 [pburleson]
4. Use the port if available #875 [madrobby]
@@ -1825,10 +1825,10 @@ References #6031. [Nicholas Seckar]
Controller: components/list/items_controller.rb
(holds a List::ItemsController class with uses_component_template_root called)
-
+
Model : components/list/item.rb
(namespace is still shared, so an Item model in app/models will take precedence)
-
+
Views : components/list/items/show.rhtml
@@ -1921,11 +1921,11 @@ References #6031. [Nicholas Seckar]
* Fixed dependency management to happen in a unified fashion for Active Record and Action Pack using the new Dependencies module. This means that
the environment options needs to change from:
-
+
Before in development.rb:
ActionController::Base.reload_dependencies = true  
ActiveRecord::Base.reload_associations     = true
-
+
Now in development.rb:
Dependencies.mechanism = :load
@@ -1979,41 +1979,41 @@ References #6031. [Nicholas Seckar]
* Added breakpoint support through the script/breakpointer client. This means that you can break out of execution at any point in
the code, investigate and change the model, AND then resume execution! Example:
-
+
class WeblogController < ActionController::Base
def index
@posts = Post.find_all
breakpoint "Breaking out from the list"
end
end
-
- So the controller will accept the action, run the first line, then present you with a IRB prompt in the breakpointer window.
+
+ So the controller will accept the action, run the first line, then present you with a IRB prompt in the breakpointer window.
Here you can do things like:
-
+
Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
>> @posts.inspect
- => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
#<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
>> @posts.first.title = "hello from a breakpoint"
=> "hello from a breakpoint"
...and even better is that you can examine how your runtime objects actually work:
- >> f = @posts.first
+ >> f = @posts.first
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
>> f.
Display all 152 possibilities? (y or n)
-
+
Finally, when you're ready to resume execution, you press CTRL-D
* Changed environments to be configurable through an environment variable. By default, the environment is "development", but you
can change that and set your own by configuring the Apache vhost with a string like (mod_env must be available on the server):
-
+
SetEnv RAILS_ENV production
-
+
...if you're using WEBrick, you can pick the environment to use with the command-line parameters -e/--environment, like this:
-
+
ruby public/dispatcher.servlet -e production
* Added a new default environment called "development", which leaves the production environment to be tuned exclusively for that.
@@ -2028,11 +2028,11 @@ References #6031. [Nicholas Seckar]
app/controllers/account_controller.rb # URL: /account/
app/controllers/admin/account_controller.rb # URL: /admin/account/
-
+
NOTE: You need to update your public/.htaccess with the new rules to pick it up
-* Added reloading for associations and dependencies under cached environments like FastCGI and mod_ruby. This makes it possible to use
- those environments for development. This is turned on by default, but can be turned off with
+* Added reloading for associations and dependencies under cached environments like FastCGI and mod_ruby. This makes it possible to use
+ those environments for development. This is turned on by default, but can be turned off with
ActiveRecord::Base.reload_associations = false and ActionController::Base.reload_dependencies = false in production environments.
* Added support for sub-directories in app/models. So now you can have something like Basecamp with:
@@ -2041,7 +2041,7 @@ References #6031. [Nicholas Seckar]
app/models/project
app/models/participants
app/models/settings
-
+
It's poor man's namespacing, but only for file-system organization. You still require files just like before.
Nothing changes inside the files themselves.
@@ -2061,7 +2061,7 @@ References #6031. [Nicholas Seckar]
@david.projects << @new_project
breakpoint "Let's have a closer look at @david"
end
-
+
You need to install dev-utils yourself for this to work ("gem install dev-util").
* Added shared generator behavior so future upgrades should be possible without manually copying over files [Jeremy Kemper]
@@ -2120,7 +2120,7 @@ References #6031. [Nicholas Seckar]
*0.7.0*
-* Added an optional second argument to the new_model script that allows the programmer to specify the table name,
+* Added an optional second argument to the new_model script that allows the programmer to specify the table name,
which will used to generate a custom table_name method in the model and will also be used in the creation of fixtures.
[Kevin Radloff]
@@ -2134,8 +2134,8 @@ References #6031. [Nicholas Seckar]
* create_fixtures in both the functional and unit test helper now turns off the log during fixture generation
and can generate more than one fixture at a time. Which makes it possible for assignments like:
-
- @people, @projects, @project_access, @companies, @accounts =
+
+ @people, @projects, @project_access, @companies, @accounts =
create_fixtures "people", "projects", "project_access", "companies", "accounts"
* Upgraded to Action Pack 0.8.5 (locally-scoped variables, partials, advanced send_file)
@@ -2147,7 +2147,7 @@ References #6031. [Nicholas Seckar]
* No longer specifies a template for rdoc, so it'll use whatever is default (you can change it in the rakefile)
-* The new_model generator will now use the same rules for plural wordings as Active Record
+* The new_model generator will now use the same rules for plural wordings as Active Record
(so Category will give categories, not categorys) [Kevin Radloff]
* dispatch.fcgi now sets FCGI_PURE_RUBY to true to ensure that it's the Ruby version that's loaded [danp]
@@ -2173,13 +2173,13 @@ References #6031. [Nicholas Seckar]
* Added environments that can be included from any script to get the full Active Record and Action Controller
context running. This can be used by maintenance scripts or to interact with the model through IRB. Example:
-
+
require 'config/environments/production'
-
+
for account in Account.find_all
account.recalculate_interests
end
-
+
A short migration script for an account model that had it's interest calculation strategy changed.
* Accessing the index of a controller with "/weblog" will now redirect to "/weblog/" (only on Apache, not WEBrick)
@@ -2202,7 +2202,7 @@ References #6031. [Nicholas Seckar]
* Added lib in root as a place to store app specific libraries
-* Added lib and vendor to load_path, so anything store within can be loaded directly.
+* Added lib and vendor to load_path, so anything store within can be loaded directly.
Hence lib/redcloth.rb can be loaded with require "redcloth"
* Upgraded to Action Pack 0.7.8 (lots of fixes)
@@ -2216,7 +2216,7 @@ References #6031. [Nicholas Seckar]
* Updated the generated template stubs to valid XHTML files
-* Ensure that controllers generated are capitalized, so "new_controller TodoLists"
+* Ensure that controllers generated are capitalized, so "new_controller TodoLists"
gives the same as "new_controller Todolists" and "new_controller todolists".
diff --git a/railties/README.rdoc b/railties/README.rdoc
index a1718a7d96..789d5255b7 100644
--- a/railties/README.rdoc
+++ b/railties/README.rdoc
@@ -15,7 +15,7 @@ The latest version of Railties can be installed with Rubygems:
* gem install railties
-Documentation can be found at
+Documentation can be found at
* http://api.rubyonrails.org
diff --git a/railties/guides/assets/stylesheets/main.css b/railties/guides/assets/stylesheets/main.css
index bab0b7a9d9..7e6dfbdb51 100644
--- a/railties/guides/assets/stylesheets/main.css
+++ b/railties/guides/assets/stylesheets/main.css
@@ -22,7 +22,7 @@ ol { list-style-type: decimal; }
dl { margin: 0 0 1.5em 0; }
dl dt { font-weight: bold; }
dd { margin-left: 1.5em;}
-
+
pre,code { margin: 1.5em 0; white-space: pre; overflow: auto; }
pre,code,tt { font: 1em 'andale mono', 'lucida console', monospace; line-height: 1.5; }
@@ -53,7 +53,7 @@ table {
background: #FFF;
border-collapse: collapse;
}
-
+
table th, table td {
padding: 0.25em 1em;
border: 1px solid #CCC;
@@ -76,7 +76,7 @@ body {
font-family: Helvetica, Arial, sans-serif;
font-size: 87.5%;
line-height: 1.5em;
- background: #222;
+ background: #222;
color: #999;
}
@@ -114,7 +114,7 @@ body {
#mainCol {
width: 45em;
margin-left: 2em;
- }
+ }
#subCol {
position: absolute;
@@ -127,7 +127,7 @@ body {
font-size: 0.9285em;
line-height: 1.3846em;
}
-
+
#extraCol {display: none;}
#footer {
@@ -180,7 +180,7 @@ a, a:link, a:visited {
#header .nav .index a {
background: #980905 url(../images/nav_arrow.gif) no-repeat right top;
- padding-right: 1em;
+ padding-right: 1em;
position: relative;
z-index: 15;
padding-bottom: 0.125em;
@@ -246,7 +246,7 @@ h3 {
margin: 0.875em 0 0.2916em;
font-weight: bold;
}
-
+
h4 {
font-size: 1.2857em;
line-height: 1.2em;
@@ -261,7 +261,7 @@ h5 {
font-weight: bold;
}
-h6 {
+h6 {
font-size: 1em;
line-height: 1.5em;
margin: 1em 0 .5em;
@@ -367,7 +367,7 @@ tt {
div.code_container {
background: #EEE url(../images/tab_grey.gif) no-repeat left top;
- padding: 0.25em 1em 0.5em 48px;
+ padding: 0.25em 1em 0.5em 48px;
}
code {
@@ -411,15 +411,15 @@ code {
padding: 0 0 1em;
font-size: 1.1667em;
}
-
+
/* Clearing
--------------------------------------- */
.clearfix:after {
- content: ".";
- display: block;
- height: 0;
- clear: both;
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
visibility: hidden;
}
diff --git a/railties/guides/rails_guides/generator.rb b/railties/guides/rails_guides/generator.rb
index bb7cdb6756..5a5ce54503 100644
--- a/railties/guides/rails_guides/generator.rb
+++ b/railties/guides/rails_guides/generator.rb
@@ -32,7 +32,7 @@
#
# Separate many using commas:
#
-# # generates only
+# # generates only
# ONLY=assoc,migrations ruby rails_guides.rb
#
# Note that if you are working on a guide generation will by default process
@@ -77,7 +77,7 @@ module RailsGuides
def initialize_dirs(output)
@guides_dir = File.join(File.dirname(__FILE__), '..')
@source_dir = File.join(@guides_dir, "source")
- @output_dir = output || File.join(@guides_dir, "output")
+ @output_dir = output || File.join(@guides_dir, "output")
end
def create_output_dir_if_needed
@@ -116,7 +116,7 @@ module RailsGuides
def output_file_for(guide)
guide.sub(GUIDES_RE, '.html')
end
-
+
def generate?(source_file, output_file)
fin = File.join(source_dir, source_file)
fout = File.join(output_dir, output_file)
@@ -213,9 +213,9 @@ module RailsGuides
code_blocks << %{<div class="code_container"><code class="#{css_class}">#{es}</code></div>}
"\ndirty_workaround_for_notextile_#{code_blocks.size - 1}\n"
end
-
+
body = yield body
-
+
body.gsub(%r{<p>dirty_workaround_for_notextile_(\d+)</p>}) do |_|
code_blocks[$1.to_i]
end
@@ -225,7 +225,7 @@ module RailsGuides
anchors = extract_anchors(html)
check_fragment_identifiers(html, anchors)
end
-
+
def extract_anchors(html)
# Textile generates headers with IDs computed from titles.
anchors = Set.new
@@ -241,7 +241,7 @@ module RailsGuides
anchors += Set.new(html.scan(/<p\s+class="footnote"\s+id="([^"]+)/).flatten)
return anchors
end
-
+
def check_fragment_identifiers(html, anchors)
html.scan(/<a\s+href="#([^"]+)/).flatten.each do |fragment_identifier|
next if fragment_identifier == 'mainCol' # in layout, jumps to some DIV
diff --git a/railties/guides/source/2_3_release_notes.textile b/railties/guides/source/2_3_release_notes.textile
index f3530c4ddd..72fe723687 100644
--- a/railties/guides/source/2_3_release_notes.textile
+++ b/railties/guides/source/2_3_release_notes.textile
@@ -53,7 +53,7 @@ The "Ruby on Rails guides":http://guides.rubyonrails.org/ project has published
h3. Ruby 1.9.1 Support
-Rails 2.3 should pass all of its own tests whether you are running on Ruby 1.8 or the now-released Ruby 1.9.1. You should be aware, though, that moving to 1.9.1 entails checking all of the data adapters, plugins, and other code that you depend on for Ruby 1.9.1 compatibility, as well as Rails core.
+Rails 2.3 should pass all of its own tests whether you are running on Ruby 1.8 or the now-released Ruby 1.9.1. You should be aware, though, that moving to 1.9.1 entails checking all of the data adapters, plugins, and other code that you depend on for Ruby 1.9.1 compatibility, as well as Rails core.
h3. Active Record
@@ -77,7 +77,7 @@ Turning on nested attributes enables a number of things: automatic (and atomic)
You can also specify requirements for any new records that are added via nested attributes using the +:reject_if+ option:
<ruby>
-accepts_nested_attributes_for :author,
+accepts_nested_attributes_for :author,
:reject_if => proc { |attributes| attributes['name'].blank? }
</ruby>
@@ -149,7 +149,7 @@ end
Note that you should only use this method for batch processing: for small numbers of records (less than 1000), you should just use the regular find methods with your own loop.
-* More Information (at that point the convenience method was called just +each+):
+* More Information (at that point the convenience method was called just +each+):
** "Rails 2.3: Batch Finding":http://afreshcup.com/2009/02/23/rails-23-batch-finding/
** "What's New in Edge Rails: Batched Find":http://ryandaigle.com/articles/2009/2/23/what-s-new-in-edge-rails-batched-find
@@ -449,7 +449,7 @@ returns
<option>joke</option>
<option>poem</option>
<option disabled=“disabled“>private</option>
-</select>
+</select>
</ruby>
You can also use an anonymous function to determine at runtime which options from collections will be selected and/or disabled:
@@ -502,7 +502,7 @@ The support for XML parsing in ActiveSupport has been made more flexible by allo
XmlMini.backend = 'LibXML'
</ruby>
-* Lead Contributor: "Bart ten Brinke":http://www.movesonrails.com/
+* Lead Contributor: "Bart ten Brinke":http://www.movesonrails.com/
* Lead Contributor: "Aaron Patterson":http://tenderlovemaking.com/
h4. Fractional seconds for TimeWithZone
diff --git a/railties/guides/source/action_controller_overview.textile b/railties/guides/source/action_controller_overview.textile
index ec2d5b2787..b38ae07043 100644
--- a/railties/guides/source/action_controller_overview.textile
+++ b/railties/guides/source/action_controller_overview.textile
@@ -115,7 +115,7 @@ h4. Routing Parameters
The +params+ hash will always contain the +:controller+ and +:action+ keys, but you should use the methods +controller_name+ and +action_name+ instead to access these values. Any other parameters defined by the routing, such as +:id+ will also be available. As an example, consider a listing of clients where the list can show either active or inactive clients. We can add a route which captures the +:status+ parameter in a "pretty" URL:
<ruby>
-map.connect "/clients/:status",
+map.connect "/clients/:status",
:controller => "clients",
:action => "index",
:foo => "bar"
@@ -296,7 +296,7 @@ class MainController < ApplicationController
# Will persist all flash values.
flash.keep
- # You can also use a key to keep only some kind of value.
+ # You can also use a key to keep only some kind of value.
# flash.keep(:notice)
redirect_to users_url
end
@@ -369,14 +369,14 @@ class UsersController < ApplicationController
end
</ruby>
-Notice that in the above case code is <tt>render :xml => @users</tt> and not <tt>render :xml => @users.to_xml</tt>. That is because if the input is not string then rails automatically invokes +to_xml+ .
+Notice that in the above case code is <tt>render :xml => @users</tt> and not <tt>render :xml => @users.to_xml</tt>. That is because if the input is not string then rails automatically invokes +to_xml+ .
h3. Filters
-Filters are methods that are run before, after or "around" a controller action.
+Filters are methods that are run before, after or "around" a controller action.
-Filters are inherited, so if you set a filter on +ApplicationController+, it will be run on every controller in your application.
+Filters are inherited, so if you set a filter on +ApplicationController+, it will be run on every controller in your application.
Before filters may halt the request cycle. A common before filter is one which requires that a user is logged in for an action to be run. You can define the filter method this way:
@@ -536,7 +536,7 @@ You will see how the token gets added as a hidden field:
<html>
<form action="/users/1" method="post">
-<input type="hidden"
+<input type="hidden"
value="67250ab105eb5ad10851c00a5621854a23af5489"
name="authenticity_token"/>
<!-- fields -->
@@ -659,7 +659,7 @@ class ClientsController < ApplicationController
# returns it. The user will get the PDF as a file download.
def download_pdf
client = Client.find(params[:id])
- send_data generate_pdf(client),
+ send_data generate_pdf(client),
:filename => "#{client.name}.pdf",
:type => "application/pdf"
end
diff --git a/railties/guides/source/action_view_overview.textile b/railties/guides/source/action_view_overview.textile
index 8b5eda0973..e242cdaf73 100644
--- a/railties/guides/source/action_view_overview.textile
+++ b/railties/guides/source/action_view_overview.textile
@@ -12,9 +12,9 @@ endprologue.
h3. What is Action View?
-Action View and Action Controller are the two major components of Action Pack. In Rails, web requests are handled by Action Pack, which splits the work into a controller part (performing the logic) and a view part (rendering a template). Typically, Action Controller will be concerned with communicating with the database and performing CRUD actions where necessary. Action View is then responsible for compiling the response.
+Action View and Action Controller are the two major components of Action Pack. In Rails, web requests are handled by Action Pack, which splits the work into a controller part (performing the logic) and a view part (rendering a template). Typically, Action Controller will be concerned with communicating with the database and performing CRUD actions where necessary. Action View is then responsible for compiling the response.
-Action View templates are written using embedded Ruby in tags mingled with HTML. To avoid cluttering the templates with boilerplate code, a number of helper classes provide common behavior for forms, dates, and strings. It's also easy to add new helpers to your application as it evolves.
+Action View templates are written using embedded Ruby in tags mingled with HTML. To avoid cluttering the templates with boilerplate code, a number of helper classes provide common behavior for forms, dates, and strings. It's also easy to add new helpers to your application as it evolves.
Note: Some features of Action View are tied to Active Record, but that doesn't mean that Action View depends on Active Record. Action View is an independent package that can be used with any sort of backend.
@@ -24,7 +24,7 @@ TODO...
h3. Using Action View outside of Rails
-Action View works well with Action Record, but it can also be used with other Ruby tools. We can demonstrate this by creating a small "Rack":http://rack.rubyforge.org/ application that includes Action View functionality. This may be useful, for example, if you'd like access to Action View's helpers in a Rack application.
+Action View works well with Action Record, but it can also be used with other Ruby tools. We can demonstrate this by creating a small "Rack":http://rack.rubyforge.org/ application that includes Action View functionality. This may be useful, for example, if you'd like access to Action View's helpers in a Rack application.
Let's start by ensuring that you have the Action Pack and Rack gems installed:
@@ -55,11 +55,11 @@ We can see this all come together by starting up the application and then visiti
ruby hello_world.rb
</shell>
-TODO needs a screenshot? I have one - not sure where to put it.
+TODO needs a screenshot? I have one - not sure where to put it.
-Notice how 'hello world' has been converted into 'Hello World' by the +titleize+ helper method.
+Notice how 'hello world' has been converted into 'Hello World' by the +titleize+ helper method.
-Action View can also be used with "Sinatra":http://www.sinatrarb.com/ in the same way.
+Action View can also be used with "Sinatra":http://www.sinatrarb.com/ in the same way.
Let's start by ensuring that you have the Action Pack and Sinatra gems installed:
@@ -90,7 +90,7 @@ ruby hello_world.rb
Once the application is running, you can see Sinatra and Action View working together by visiting +http://localhost:4567/+
-TODO needs a screenshot? I have one - not sure where to put it.
+TODO needs a screenshot? I have one - not sure where to put it.
h3. Templates, Partials and Layouts
@@ -172,7 +172,7 @@ TODO...
h3. Overview of all the helpers provided by Action View
-The following is only a brief overview summary of the helpers available in Action View. It's recommended that you review the API Documentation, which covers all of the helpers in more detail, but this should serve as a good starting point.
+The following is only a brief overview summary of the helpers available in Action View. It's recommended that you review the API Documentation, which covers all of the helpers in more detail, but this should serve as a good starting point.
h4. ActiveRecordHelper
@@ -196,7 +196,7 @@ error_messages_for "post"
h5. form
-Returns a form with inputs for all attributes of the specified Active Record object. For example, let's say we have a +@post+ with attributes named +title+ of type +String+ and +body+ of type +Text+. Calling +form+ would produce a form to creating a new post with inputs for those attributes.
+Returns a form with inputs for all attributes of the specified Active Record object. For example, let's say we have a +@post+ with attributes named +title+ of type +String+ and +body+ of type +Text+. Calling +form+ would produce a form to creating a new post with inputs for those attributes.
<ruby>
form("post")
@@ -220,24 +220,24 @@ Typically, +form_for+ is used instead of +form+ because it doesn't automatically
h5. input
-Returns a default input tag for the type of object returned by the method.
+Returns a default input tag for the type of object returned by the method.
For example, if +@post+ has an attribute +title+ mapped to a +String+ column that holds "Hello World":
<ruby>
-input("post", "title") # =>
+input("post", "title") # =>
<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
</ruby>
h4. AssetTagHelper
-This module provides methods for generating HTML that links views to assets such as images, javascripts, stylesheets, and feeds.
+This module provides methods for generating HTML that links views to assets such as images, javascripts, stylesheets, and feeds.
By default, Rails links to these assets on the current host in the public folder, but you can direct Rails to link to assets from a dedicated assets server by setting +ActionController::Base.asset_host+ in your +config/environment.rb+. For example, let's say your asset host is +assets.example.com+:
<ruby>
ActionController::Base.asset_host = "assets.example.com"
-image_tag("rails.png") # => <img src="http://assets.example.com/images/rails.png" alt="Rails" />
+image_tag("rails.png") # => <img src="http://assets.example.com/images/rails.png" alt="Rails" />
</ruby>
h5. register_javascript_expansion
@@ -301,10 +301,10 @@ Returns an html script tag for each of the sources provided. You can pass in the
<ruby>
javascript_include_tag "common" # =>
- <script type="text/javascript" src="/javascripts/common.js"></script>
+ <script type="text/javascript" src="/javascripts/common.js"></script>
</ruby>
-To include the Prototype and Scriptaculous javascript libraries in your application, pass +:defaults+ as the source. When using +:defaults+, if an +application.js+ file exists in your +public/javascripts+ directory, it will be included as well.
+To include the Prototype and Scriptaculous javascript libraries in your application, pass +:defaults+ as the source. When using +:defaults+, if an +application.js+ file exists in your +public/javascripts+ directory, it will be included as well.
<ruby>
javascript_include_tag :defaults
@@ -319,8 +319,8 @@ javascript_include_tag :all
You can also cache multiple javascripts into one file, which requires less HTTP connections to download and can better be compressed by gzip (leading to faster transfers). Caching will only happen if +ActionController::Base.perform_caching+ is set to true (which is the case by default for the Rails production environment, but not for the development environment).
<ruby>
-javascript_include_tag :all, :cache => true # =>
- <script type="text/javascript" src="/javascripts/all.js"></script>
+javascript_include_tag :all, :cache => true # =>
+ <script type="text/javascript" src="/javascripts/all.js"></script>
</ruby>
h5. javascript_path
@@ -333,7 +333,7 @@ javascript_path "common" # => /javascripts/common.js
h5. stylesheet_link_tag
-Returns a stylesheet link tag for the sources specified as arguments. If you don't specify an extension, +.css+ will be appended automatically.
+Returns a stylesheet link tag for the sources specified as arguments. If you don't specify an extension, +.css+ will be appended automatically.
<ruby>
stylesheet_link_tag "application" # =>
@@ -346,7 +346,7 @@ You can also include all styles in the stylesheet directory using :all as the so
stylesheet_link_tag :all
</ruby>
-You can also cache multiple stylesheets into one file, which requires less HTTP connections and can better be compressed by gzip (leading to faster transfers). Caching will only happen if ActionController::Base.perform_caching is set to true (which is the case by default for the Rails production environment, but not for the development environment).
+You can also cache multiple stylesheets into one file, which requires less HTTP connections and can better be compressed by gzip (leading to faster transfers). Caching will only happen if ActionController::Base.perform_caching is set to true (which is the case by default for the Rails production environment, but not for the development environment).
<ruby>
stylesheet_link_tag :all, :cache => true
@@ -415,7 +415,7 @@ Allows you to measure the execution time of a block in a template and records th
<ruby>
<% benchmark "Process data files" do %>
<%= expensive_files_operation %>
-<% end %>
+<% end %>
</ruby>
This would add something like "Process data files (0.34523)" to the log, which you can then use to compare timings when optimizing your code.
@@ -455,7 +455,7 @@ The captured variable can then be used anywhere else.
<%= @greeting %>
</body>
</html>
-</ruby>
+</ruby>
h5. content_for
@@ -484,7 +484,7 @@ For example, let's say we have a standard application layout, but also a special
<% content_for :special_script do %>
<script type="text/javascript">alert('Hello!')</script>
-<% end %>
+<% end %>
</ruby>
h4. DateHelper
@@ -523,7 +523,7 @@ Returns a set of html select-tags (one for year, month, and day) pre-selected wi
select_date(Time.today + 6.days)
# Generates a date select that defaults to today (no specified date)
-select_date()
+select_date()
</ruby>
h5. select_datetime
@@ -535,7 +535,7 @@ Returns a set of html select-tags (one for year, month, day, hour, and minute) p
select_datetime(Time.now + 4.days)
# Generates a datetime select that defaults to today (no specified datetime)
-select_datetime()
+select_datetime()
</ruby>
h5. select_day
@@ -583,7 +583,7 @@ Returns a select tag with options for each of the seconds 0 through 59 with the
<ruby>
# Generates a select field for seconds that defaults to the seconds for the time provided
-select_second(Time.now + 16.minutes)
+select_second(Time.now + 16.minutes)
</ruby>
h5. select_time
@@ -592,7 +592,7 @@ Returns a set of html select-tags (one for hour and minute).
<ruby>
# Generates a time select that defaults to the time provided
-select_time(Time.now)
+select_time(Time.now)
</ruby>
h5. select_year
@@ -621,7 +621,7 @@ Returns a set of select tags (one for hour, minute and optionally second) pre-se
<ruby>
# Creates a time select tag that, when POSTed, will be stored in the order variable in the submitted attribute
-time_select("order", "submitted")
+time_select("order", "submitted")
</ruby>
h4. DebugHelper
@@ -711,7 +711,7 @@ Returns an file upload input tag tailored for accessing a specified attribute.
<ruby>
file_field(:user, :avatar)
-# => <input type="file" id="user_avatar" name="user[avatar]" />
+# => <input type="file" id="user_avatar" name="user[avatar]" />
</ruby>
h5. form_for
@@ -733,7 +733,7 @@ Returns a hidden input tag tailored for accessing a specified attribute.
<ruby>
hidden_field(:user, :token)
-# => <input type="hidden" id="user_token" name="user[token]" value="#{@user.token}" />
+# => <input type="hidden" id="user_token" name="user[token]" value="#{@user.token}" />
</ruby>
h5. label
@@ -751,7 +751,7 @@ Returns an input tag of the "password" type tailored for accessing a specified a
<ruby>
password_field(:login, :pass)
-# => <input type="text" id="login_pass" name="login[pass]" value="#{@login.pass}" />
+# => <input type="text" id="login_pass" name="login[pass]" value="#{@login.pass}" />
</ruby>
h5. radio_button
@@ -854,7 +854,7 @@ end
Sample usage:
-<ruby>
+<ruby>
option_groups_from_collection_for_select(@continents, :countries, :name, :id, :name, 3)
</ruby>
@@ -880,7 +880,7 @@ Note: Only the +optgroup+ and +option+ tags are returned, so you still have to w
h5. options_for_select
-Accepts a container (hash, array, enumerable, your type) and returns a string of option tags.
+Accepts a container (hash, array, enumerable, your type) and returns a string of option tags.
<ruby>
options_for_select([ "VISA", "MasterCard" ])
@@ -902,7 +902,7 @@ For example, imagine a loop iterating over each person in @project.people to gen
<ruby>
options_from_collection_for_select(@project.people, "id", "name")
# => <option value="#{person.id}">#{person.name}</option>
-</ruby>
+</ruby>
Note: Only the +option+ tags are returned, you have to wrap this call in a regular HTML +select+ tag.
@@ -949,7 +949,7 @@ Creates a check box form input tag.
<ruby>
check_box_tag 'accept'
-# => <input id="accept" name="accept" type="checkbox" value="1" />
+# => <input id="accept" name="accept" type="checkbox" value="1" />
</ruby>
h5. field_set_tag
@@ -965,7 +965,7 @@ Creates a field set for grouping HTML form elements.
h5. file_field_tag
-Creates a file upload field.
+Creates a file upload field.
If you are using file uploads then you will also need to set the multipart option for the form tag:
@@ -1173,7 +1173,7 @@ number_with_delimiter(12345678) # => 12,345,678
h5. number_with_precision
-Formats a number with the specified level of +precision+, which defaults to 3.
+Formats a number with the specified level of +precision+, which defaults to 3.
<ruby>
number_with_precision(111.2345) # => 111.235
@@ -1207,7 +1207,7 @@ form_remote_tag :html => { :action => url_for(:controller => "some", :action =>
would generate the following:
<html>
-<form action="/some/place" method="post" onsubmit="new Ajax.Request('',
+<form action="/some/place" method="post" onsubmit="new Ajax.Request('',
{asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;">
</html>
@@ -1293,7 +1293,7 @@ Yields a JavaScriptGenerator and returns the generated JavaScript code. Use this
<ruby>
update_page do |page|
page.hide 'spinner'
-end
+end
</ruby>
h5. update_page_tag
@@ -1395,7 +1395,7 @@ h5. remove
Removes the DOM elements with the given ids from the page.
<ruby>
-page.remove 'person_23', 'person_9', 'person_2'
+page.remove 'person_23', 'person_9', 'person_2'
</ruby>
h5. replace
@@ -1420,7 +1420,7 @@ Returns a collection reference by finding it through a CSS pattern in the DOM.
<ruby>
page.select('p.welcome b').first.hide # => $$('p.welcome b').first().hide();
-</ruby>
+</ruby>
h5. show
@@ -1440,7 +1440,7 @@ Toggles the visibility of the DOM elements with the given ids. Example:
<ruby>
page.toggle 'person_14', 'person_12', 'person_23' # Hides the elements
-page.toggle 'person_14', 'person_12', 'person_23' # Shows the previously hidden elements
+page.toggle 'person_14', 'person_12', 'person_23' # Shows the previously hidden elements
</ruby>
h5. visual_effect
@@ -1455,11 +1455,11 @@ h3. Localized Views
Action View has the ability render different templates depending on the current locale.
-For example, suppose you have a Posts controller with a show action. By default, calling this action will render +app/views/posts/show.html.erb+. But if you set +I18n.locale = :de+, then +app/views/posts/show.de.html.erb+ will be rendered instead. If the localized template isn't present, the undecorated version will be used. This means you're not required to provide localized views for all cases, but they will be preferred and used if available.
+For example, suppose you have a Posts controller with a show action. By default, calling this action will render +app/views/posts/show.html.erb+. But if you set +I18n.locale = :de+, then +app/views/posts/show.de.html.erb+ will be rendered instead. If the localized template isn't present, the undecorated version will be used. This means you're not required to provide localized views for all cases, but they will be preferred and used if available.
You can use the same technique to localize the rescue files in your public directory. For example, setting +I18n.locale = :de+ and creating +public/500.de.html+ and +public/404.de.html+ would allow you to have localized rescue pages.
-Since Rails doesn't restrict the symbols that you use to set I18n.locale, you can leverage this system to display different content depending on anything you like. For example, suppose you have some "expert" users that should see different pages from "normal" users. You could add the following to +app/controllers/application.rb+:
+Since Rails doesn't restrict the symbols that you use to set I18n.locale, you can leverage this system to display different content depending on anything you like. For example, suppose you have some "expert" users that should see different pages from "normal" users. You could add the following to +app/controllers/application.rb+:
<ruby>
before_filter :set_expert_locale
@@ -1471,7 +1471,7 @@ end
Then you could create special views like +app/views/posts/show.expert.html.erb+ that would only be displayed to expert users.
-You can read more about the Rails Internationalization (I18n) API "here":i18n.html.
+You can read more about the Rails Internationalization (I18n) API "here":i18n.html.
h3. Changelog
diff --git a/railties/guides/source/active_record_basics.textile b/railties/guides/source/active_record_basics.textile
index e6ef2cdd20..f0081b48c0 100644
--- a/railties/guides/source/active_record_basics.textile
+++ b/railties/guides/source/active_record_basics.textile
@@ -16,7 +16,7 @@ Active Record is the M in "MVC":getting_started.html#the-mvc-architecture - the
h4. The Active Record Pattern
-Active Record was described by Martin Fowler in his book _Patterns of Enterprise Application Architecture_. In Active Record, objects carry both persistent data and behavior which operates on that data. Active Record takes the opinion that ensuring data access logic is part of the object will educate users of that object on how to write to and read from the database.
+Active Record was described by Martin Fowler in his book _Patterns of Enterprise Application Architecture_. In Active Record, objects carry both persistent data and behavior which operates on that data. Active Record takes the opinion that ensuring data access logic is part of the object will educate users of that object on how to write to and read from the database.
h4. Object Relational Mapping
@@ -132,7 +132,7 @@ CRUD is an acronym for the four verbs we use to operate on data: *C*reate, *R*ea
h4. Create
-Active Record objects can be created from a hash, a block or have its attributes manually set after creation. The _new_ method will return a new object while _create_ will return the object and save it to the database.
+Active Record objects can be created from a hash, a block or have its attributes manually set after creation. The _new_ method will return a new object while _create_ will return the object and save it to the database.
For example, given a model +User+ with attributes of +name+ and +occupation+, the _create_ method call will create and save a new record into the database:
diff --git a/railties/guides/source/active_record_querying.textile b/railties/guides/source/active_record_querying.textile
index 53095a2bd3..b54b5c116b 100644
--- a/railties/guides/source/active_record_querying.textile
+++ b/railties/guides/source/active_record_querying.textile
@@ -153,7 +153,7 @@ SELECT * FROM clients WHERE (clients.id IN (1,10))
h4. Retrieving Multiple Objects in Batches
-Sometimes you need to iterate over a large set of records. For example to send a newsletter to all users, to export some data, etc.
+Sometimes you need to iterate over a large set of records. For example to send a newsletter to all users, to export some data, etc.
The following may seem very straight forward at first:
@@ -674,7 +674,7 @@ Post.joins(:category, :comments)
This produces:
<sql>
-SELECT posts.* FROM posts
+SELECT posts.* FROM posts
INNER JOIN categories ON posts.category_id = categories.id
INNER JOIN comments ON comments.post_id = posts.id
</sql>
@@ -753,7 +753,7 @@ h4. Eager Loading Multiple Associations
Active Record lets you eager load any number of associations with a single +Model.find+ call by using an array, hash, or a nested hash of array/hash with the +includes+ method.
-h5. Array of Multiple Associations
+h5. Array of Multiple Associations
<ruby>
Post.includes(:category, :comments)
@@ -771,7 +771,7 @@ This will find the category with id 1 and eager load all of the associated posts
h4. Specifying Conditions on Eager Loaded Associations
-Even though Active Record lets you specify conditions on the eager loaded associations just like +joins+, the recommended way is to use "joins":#joining-tables instead.
+Even though Active Record lets you specify conditions on the eager loaded associations just like +joins+, the recommended way is to use "joins":#joining-tables instead.
h3. Dynamic Finders
@@ -807,8 +807,8 @@ h3. Finding by SQL
If you'd like to use your own SQL to find records in a table you can use +find_by_sql+. The +find_by_sql+ method will return an array of objects even if the underlying query returns just a single record. For example you could run this query:
<ruby>
-Client.find_by_sql("SELECT * FROM clients
- INNER JOIN orders ON clients.id = orders.client_id
+Client.find_by_sql("SELECT * FROM clients
+ INNER JOIN orders ON clients.id = orders.client_id
ORDER clients.created_at desc")
</ruby>
diff --git a/railties/guides/source/active_record_validations_callbacks.textile b/railties/guides/source/active_record_validations_callbacks.textile
index 37a65d211e..1e232422e3 100644
--- a/railties/guides/source/active_record_validations_callbacks.textile
+++ b/railties/guides/source/active_record_validations_callbacks.textile
@@ -16,7 +16,7 @@ endprologue.
h3. The Object Life Cycle
-During the normal operation of a Rails application, objects may be created, updated, and destroyed. Active Record provides hooks into this <em>object life cycle</em> so that you can control your application and its data.
+During the normal operation of a Rails application, objects may be created, updated, and destroyed. Active Record provides hooks into this <em>object life cycle</em> so that you can control your application and its data.
Validations allow you to ensure that only valid data is stored in your database. Callbacks and observers allow you to trigger logic before or after an alteration of an object's state.
@@ -33,7 +33,7 @@ There are several ways to validate data before it is saved into your database, i
* Database constraints and/or stored procedures make the validation mechanisms database-dependent and can make testing and maintenance more difficult. However, if your database is used by other applications, it may be a good idea to use some constraints at the database level. Additionally, database-level validations can safely handle some things (such as uniqueness in heavily-used tables) that can be difficult to implement otherwise.
* Client-side validations can be useful, but are generally unreliable if used alone. If they are implemented using JavaScript, they may be bypassed if JavaScript is turned off in the user's browser. However, if combined with other techniques, client-side validation can be a convenient way to provide users with immediate feedback as they use your site.
* Controller-level validations can be tempting to use, but often become unwieldy and difficult to test and maintain. Whenever possible, it's a good idea to "keep your controllers skinny":http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model, as it will make your application a pleasure to work with in the long run.
-* Model-level validations are the best way to ensure that only valid data is saved into your database. They are database agnostic, cannot be bypassed by end users, and are convenient to test and maintain. Rails makes them easy to use, provides built-in helpers for common needs, and allows you to create your own validation methods as well.
+* Model-level validations are the best way to ensure that only valid data is saved into your database. They are database agnostic, cannot be bypassed by end users, and are convenient to test and maintain. Rails makes them easy to use, provides built-in helpers for common needs, and allows you to create your own validation methods as well.
h4. When Does Validation Happen?
@@ -116,7 +116,7 @@ end
=> #<Person id: nil, name: nil>
>> p.errors
=> {}
-
+
>> p.valid?
=> false
>> p.errors
@@ -126,7 +126,7 @@ end
=> #<Person id: nil, name: nil>
>> p.errors
=> {:name=>["can't be blank"]}
-
+
>> p.save
=> false
@@ -368,7 +368,7 @@ class LineItem < ActiveRecord::Base
end
</ruby>
-Since +false.blank?+ is true, if you want to validate the presence of a boolean field you should use +validates_inclusion_of :field_name, :in => [true, false]+.
+Since +false.blank?+ is true, if you want to validate the presence of a boolean field you should use +validates_inclusion_of :field_name, :in => [true, false]+.
The default error message for +validates_presence_of+ is "_can't be empty_".
@@ -550,9 +550,9 @@ end
h3. Creating Custom Validation Methods
-When the built-in validation helpers are not enough for your needs, you can write your own validation methods.
+When the built-in validation helpers are not enough for your needs, you can write your own validation methods.
-Simply create methods that verify the state of your models and add messages to the +errors+ collection when they are invalid. You must then register these methods by using one or more of the +validate+, +validate_on_create+ or +validate_on_update+ class methods, passing in the symbols for the validation methods' names.
+Simply create methods that verify the state of your models and add messages to the +errors+ collection when they are invalid. You must then register these methods by using one or more of the +validate+, +validate_on_create+ or +validate_on_update+ class methods, passing in the symbols for the validation methods' names.
You can pass more than one symbol for each class method and the respective validations will be run in the same order as they were registered.
@@ -593,7 +593,7 @@ end
h3. Working with Validation Errors
-In addition to the +valid?+ and +invalid?+ methods covered earlier, Rails provides a number of methods for working with the +errors+ collection and inquiring about the validity of objects.
+In addition to the +valid?+ and +invalid?+ methods covered earlier, Rails provides a number of methods for working with the +errors+ collection and inquiring about the validity of objects.
The following is a list of the most commonly used methods. Please refer to the +ActiveRecord::Errors+ documentation for a list of all the available methods.
@@ -611,7 +611,7 @@ person = Person.new
person.valid? # => false
person.errors
# => {:name => ["can't be blank", "is too short (minimum is 3 characters)"]}
-
+
person = Person.new(:name => "John Doe")
person.valid? # => true
person.errors # => []
@@ -660,7 +660,7 @@ person.errors[:name]
person.errors.full_messages
# => ["Name cannot contain the characters !@#%*()_-+="]
</ruby>
-
+
Another way to do this is using +[]=+ setter
<ruby>
@@ -739,7 +739,7 @@ person.errors.size # => 0
h3. Displaying Validation Errors in the View
-Rails provides built-in helpers to display the error messages of your models in your view templates.
+Rails provides built-in helpers to display the error messages of your models in your view templates.
h4. +error_messages+ and +error_messages_for+
@@ -811,7 +811,7 @@ The name of the class and the id can be changed with the +:class+ and +:id+ opti
h4. Customizing the Error Messages HTML
-By default, form fields with errors are displayed enclosed by a +div+ element with the +field_with_errors+ CSS class. However, it's possible to override that.
+By default, form fields with errors are displayed enclosed by a +div+ element with the +field_with_errors+ CSS class. However, it's possible to override that.
The way form fields with errors are treated is defined by +ActionView::Base.field_error_proc+. This is a +Proc+ that receives two parameters:
@@ -865,7 +865,7 @@ The macro-style class methods can also receive a block. Consider using this styl
class User < ActiveRecord::Base
validates_presence_of :login, :email
- before_create {|user| user.name = user.login.capitalize
+ before_create {|user| user.name = user.login.capitalize
if user.name.blank?}
end
</ruby>
@@ -967,7 +967,7 @@ The +after_initialize+ callback is triggered every time a new object of the clas
h3. Skipping Callbacks
-Just as with validations, it's also possible to skip callbacks. These methods should be used with caution, however, because important business rules and application logic may be kept in callbacks. Bypassing them without understanding the potential implications may lead to invalid data.
+Just as with validations, it's also possible to skip callbacks. These methods should be used with caution, however, because important business rules and application logic may be kept in callbacks. Bypassing them without understanding the potential implications may lead to invalid data.
* +decrement+
* +decrement_counter+
@@ -982,7 +982,7 @@ Just as with validations, it's also possible to skip callbacks. These methods sh
h3. Halting Execution
-As you start registering new callbacks for your models, they will be queued for execution. This queue will include all your model's validations, the registered callbacks, and the database operation to be executed.
+As you start registering new callbacks for your models, they will be queued for execution. This queue will include all your model's validations, the registered callbacks, and the database operation to be executed.
The whole callback chain is wrapped in a transaction. If any <em>before</em> callback method returns exactly +false+ or raises an exception the execution chain gets halted and a ROLLBACK is issued; <em>after</em> callbacks can only accomplish that by raising an exception.
@@ -990,11 +990,11 @@ WARNING. Raising an arbitrary exception may break code that expects +save+ and f
h3. Relational Callbacks
-Callbacks work through model relationships, and can even be defined by them. Let's take an example where a user has many posts. In our example, a user's posts should be destroyed if the user is destroyed. So, we'll add an +after_destroy+ callback to the +User+ model by way of its relationship to the +Post+ model.
+Callbacks work through model relationships, and can even be defined by them. Let's take an example where a user has many posts. In our example, a user's posts should be destroyed if the user is destroyed. So, we'll add an +after_destroy+ callback to the +User+ model by way of its relationship to the +Post+ model.
<ruby>
class User < ActiveRecord::Base
- has_many :posts, :dependent => :destroy
+ has_many :posts, :dependent => :destroy
end
class Post < ActiveRecord::Base
@@ -1069,7 +1069,7 @@ Here's an example where we create a class with an +after_destroy+ callback for a
<ruby>
class PictureFileCallbacks
def after_destroy(picture_file)
- File.delete(picture_file.filepath)
+ File.delete(picture_file.filepath)
if File.exists?(picture_file.filepath)
end
end
@@ -1088,7 +1088,7 @@ Note that we needed to instantiate a new +PictureFileCallbacks+ object, since we
<ruby>
class PictureFileCallbacks
def self.after_destroy(picture_file)
- File.delete(picture_file.filepath)
+ File.delete(picture_file.filepath)
if File.exists?(picture_file.filepath)
end
end
@@ -1144,7 +1144,7 @@ By default, Rails will simply strip "Observer" from an observer's name to find t
<ruby>
class MailerObserver < ActiveRecord::Observer
observe :registration, :user
-
+
def after_create(model)
# code to send confirmation email...
end
diff --git a/railties/guides/source/active_support_core_extensions.textile b/railties/guides/source/active_support_core_extensions.textile
index 8ccfc8e304..9b3bb1da15 100644
--- a/railties/guides/source/active_support_core_extensions.textile
+++ b/railties/guides/source/active_support_core_extensions.textile
@@ -348,7 +348,7 @@ That idiom may convey _grouping_ to the reader as well. For example, say you wan
<ruby>
I18n.with_options :locale => user.locale, :scope => "newsletter" do |i18n|
subject i18n.t :subject
- body i18n.t :body, :user_name => user.name
+ body i18n.t :body, :user_name => user.name
end
</ruby>
@@ -762,7 +762,7 @@ class Counter
end
</ruby>
-The method receives the name of an action, and a +:with+ option with code. The code is evaluated in the context of the receiver each time the method is invoked, and it should evaluate to a +Mutex+ instance or any other object that responds to +synchronize+ and accepts a block.
+The method receives the name of an action, and a +:with+ option with code. The code is evaluated in the context of the receiver each time the method is invoked, and it should evaluate to a +Mutex+ instance or any other object that responds to +synchronize+ and accepts a block.
NOTE: Defined in +active_support/core_ext/module/synchronization.rb+.
@@ -1107,7 +1107,7 @@ module ActiveRecord
end
</ruby>
-Since values are copied when a subclass is defined, if the base class changes the attribute after that, the subclass does not see the new value. That's the point.
+Since values are copied when a subclass is defined, if the base class changes the attribute after that, the subclass does not see the new value. That's the point.
NOTE: Defined in +active_support/core_ext/class/inheritable_attributes.rb+.
@@ -1139,7 +1139,7 @@ NOTE: Defined in +active_support/core_ext/class/subclasses.rb+.
h5. +descendants+
-The +descendants+ method returns all classes that are <tt>&lt;</tt> than its receiver:
+The +descendants+ method returns all classes that are <tt>&lt;</tt> than its receiver:
<ruby>
class C; end
@@ -1260,7 +1260,7 @@ Pass a +:separator+ to truncate the string at a natural break:
<ruby>
"Oh dear! Oh dear! I shall be late!".truncate(18)
-# => "Oh dear! Oh dea..."
+# => "Oh dear! Oh dea..."
"Oh dear! Oh dear! I shall be late!".truncate(18, :separator => ' ')
# => "Oh dear! Oh..."
</ruby>
@@ -1751,7 +1751,7 @@ The methods +to_date+, +to_time+, and +to_datetime+ are basically convenience wr
<ruby>
"2010-07-27".to_date # => Tue, 27 Jul 2010
"2010-07-27 23:37:00".to_time # => Tue Jul 27 23:37:00 UTC 2010
-"2010-07-27 23:37:00".to_datetime # => Tue, 27 Jul 2010 23:37:00 +0000
+"2010-07-27 23:37:00".to_datetime # => Tue, 27 Jul 2010 23:37:00 +0000
</ruby>
+to_time+ receives an optional argument +:utc+ or +:local+, to indicate which time zone you want the time in:
@@ -3032,14 +3032,14 @@ h6. +ago+, +since+
The method +ago+ receives a number of seconds as argument and returns a timestamp those many seconds ago from midnight:
<ruby>
-date = Date.current # => Fri, 11 Jun 2010
+date = Date.current # => Fri, 11 Jun 2010
date.ago(1) # => Thu, 10 Jun 2010 23:59:59 EDT -04:00
</ruby>
Similarly, +since+ moves forward:
<ruby>
-date = Date.current # => Fri, 11 Jun 2010
+date = Date.current # => Fri, 11 Jun 2010
date.since(1) # => Fri, 11 Jun 2010 00:00:01 EDT -04:00
</ruby>
diff --git a/railties/guides/source/ajax_on_rails.textile b/railties/guides/source/ajax_on_rails.textile
index 8a38cf2dc2..972e7ea840 100644
--- a/railties/guides/source/ajax_on_rails.textile
+++ b/railties/guides/source/ajax_on_rails.textile
@@ -47,7 +47,7 @@ Let's start with the the probably most often used helper: +link_to_remote+, whic
The signature of +link_to_remote+ function is the same as that of the standard +link_to+ helper:
<ruby>
-def link_to_remote(name, options = {}, html_options = nil)
+def link_to_remote(name, options = {}, html_options = nil)
</ruby>
And here is a simple example of link_to_remote in action:
@@ -98,7 +98,7 @@ link_to_remote "Delete the item",
Note that if we wouldn't override the default behavior (POST), the above snippet would route to the create action rather than destroy.
** *JavaScript filters* You can customize the remote call further by wrapping it with some JavaScript code. Let's say in the previous example, when deleting a link, you'd like to ask for a confirmation by showing a simple modal text box to the user. This is a typical example what you can accomplish with these options - let's see them one by one:
-*** +:confirm+ =&gt; +msg+ Pops up a JavaScript confirmation dialog, displaying +msg+. If the user chooses 'OK', the request is launched, otherwise canceled.
+*** +:confirm+ =&gt; +msg+ Pops up a JavaScript confirmation dialog, displaying +msg+. If the user chooses 'OK', the request is launched, otherwise canceled.
*** +:condition+ =&gt; +code+ Evaluates +code+ (which should evaluate to a boolean) and proceeds if it's true, cancels the request otherwise.
*** +:before+ =&gt; +code+ Evaluates the +code+ just before launching the request. The output of the code has no influence on the execution. Typically used show a progress indicator (see this in action in the next example).
*** +:after+ =&gt; +code+ Evaluates the +code+ after launching the request. Note that this is different from the +:success+ or +:complete+ callback (covered in the next section) since those are triggered after the request is completed, while the code snippet passed to +:after+ is evaluated after the remote call is made. A common example is to disable elements on the page or otherwise prevent further action while the request is completed.
@@ -115,8 +115,8 @@ link_to_remote "Update record",
This generates a remote link which adds 2 parameters to the standard URL generated by Rails, taken from the page (contained in the elements matched by the 'status' and 'completed' DOM id).
** *Callbacks* Since an AJAX call is typically asynchronous, as it's name suggests (this is not a rule, and you can fire a synchronous request - see the last option, +:type+) your only way of communicating with a request once it is fired is via specifying callbacks. There are six options at your disposal (in fact 508, counting all possible response types, but these six are the most frequent and therefore specified by a constant):
-*** +:loading:+ =&gt; +code+ The request is in the process of receiving the data, but the transfer is not completed yet.
-*** +:loaded:+ =&gt; +code+ The transfer is completed, but the data is not processed and returned yet
+*** +:loading:+ =&gt; +code+ The request is in the process of receiving the data, but the transfer is not completed yet.
+*** +:loaded:+ =&gt; +code+ The transfer is completed, but the data is not processed and returned yet
*** +:interactive:+ =&gt; +code+ One step after +:loaded+: The data is fully received and being processed
*** +:success:+ =&gt; +code+ The data is fully received, parsed and the server responded with "200 OK"
*** +:failure:+ =&gt; +code+ The data is fully received, parsed and the server responded with *anything* but "200 OK" (typically 404 or 500, but in general with any status code ranging from 100 to 509)
@@ -143,15 +143,15 @@ link_to_remote "Add new item",
** If you specify the +href+ parameter, the AJAX link will degrade gracefully, i.e. the link will point to the URL even if JavaScript is disabled in the client browser
** +link_to_remote+ gains it's AJAX behavior by specifying the remote call in the onclick handler of the link. If you supply +html_options[:onclick]+ you override the default behavior, so use this with care!
-We are finished with +link_to_remote+. I know this is quite a lot to digest for one helper function, but remember, these options are common for all the rest of the Rails view helpers, so we will take a look at the differences / additional parameters in the next sections.
+We are finished with +link_to_remote+. I know this is quite a lot to digest for one helper function, but remember, these options are common for all the rest of the Rails view helpers, so we will take a look at the differences / additional parameters in the next sections.
h4. AJAX Forms
There are three different ways of adding AJAX forms to your view using Rails Prototype helpers. They are slightly different, but striving for the same goal: instead of submitting the form using the standard HTTP request/response cycle, it is submitted asynchronously, thus not reloading the page. These methods are the following:
* +remote_form_for+ (and it's alias +form_remote_for+) is tied to Rails most tightly of the three since it takes a resource, model or array of resources (in case of a nested resource) as a parameter.
-* +form_remote_tag+ AJAXifies the form by serializing and sending it's data in the background
-* +submit_to_remote+ and +button_to_remote+ is more rarely used than the previous two. Rather than creating an AJAX form, you add a button/input
+* +form_remote_tag+ AJAXifies the form by serializing and sending it's data in the background
+* +submit_to_remote+ and +button_to_remote+ is more rarely used than the previous two. Rather than creating an AJAX form, you add a button/input
Let's se them in action one by one!
@@ -161,7 +161,7 @@ h5. +form_remote_tag+
h5. +submit_to_remote+
-h4. Observing Elements
+h4. Observing Elements
h5. +observe_field+
@@ -186,10 +186,10 @@ In the last section we sent some AJAX requests to the server, and inserted the H
h4. Javascript without RJS
First we'll check out how to send JavaScript to the server manually. You are practically never going to need this, but it's interesting to understand what's going on under the hood.
-
+
<ruby>
def javascript_test
- render :text => "alert('Hello, world!')",
+ render :text => "alert('Hello, world!')",
:content_type => "text/javascript"
end
</ruby>
@@ -207,14 +207,14 @@ def javascript_test
render :update do |page|
page.alert "Hello from inline RJS"
end
-end
+end
</ruby>
-The above code snippet does exactly the same as the one in the previous section - going about it much more elegantly though. You don't need to worry about headers,write ugly JavaScript code into a string etc. When the first parameter to +render+ is +:update+, Rails expects a block with a single parameter (+page+ in our case, which is the traditional naming convention) which is an instance of the JavaScriptGenerator:"http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html" object. As it's name suggests, JavaScriptGenerator is responsible for generating JavaScript from your Ruby code. You can execute multiple method calls on the +page+ instance - it's all turned into JavaScript code and sent to the server with the appropriate Content Type, "text/javascript".
+The above code snippet does exactly the same as the one in the previous section - going about it much more elegantly though. You don't need to worry about headers,write ugly JavaScript code into a string etc. When the first parameter to +render+ is +:update+, Rails expects a block with a single parameter (+page+ in our case, which is the traditional naming convention) which is an instance of the JavaScriptGenerator:"http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html" object. As it's name suggests, JavaScriptGenerator is responsible for generating JavaScript from your Ruby code. You can execute multiple method calls on the +page+ instance - it's all turned into JavaScript code and sent to the server with the appropriate Content Type, "text/javascript".
h4. RJS Templates
-If you don't want to clutter your controllers with view code (especially when your inline RJS is more than a few lines), you can move your RJS code to a template file. RJS templates should go to the +/app/views/+ directory, just as +.html.erb+ or any other view files of the appropriate controller, conventionally named +js.rjs+.
+If you don't want to clutter your controllers with view code (especially when your inline RJS is more than a few lines), you can move your RJS code to a template file. RJS templates should go to the +/app/views/+ directory, just as +.html.erb+ or any other view files of the appropriate controller, conventionally named +js.rjs+.
To rewrite the above example, you can leave the body of the action empty, and create a RJS template named +javascript_test.js.rjs+, containing the following line:
@@ -265,7 +265,7 @@ The third parameter can either be a string, or a hash of options to be passed to
page.insert_html :top, :result, :partial => "the_answer"
</ruby>
-You can replace the contents (innerHTML) of an element with the +replace_html+ method. The only difference is that since it's clear where should the new content go, there is no need for a position parameter - so +replace_html+ takes only two arguments,
+You can replace the contents (innerHTML) of an element with the +replace_html+ method. The only difference is that since it's clear where should the new content go, there is no need for a position parameter - so +replace_html+ takes only two arguments,
the DOM id of the element you wish to modify and a string or a hash of options to be passed to ActionView::Base#render.
h6. Delay
@@ -273,7 +273,7 @@ h6. Delay
You can delay the execution of a block of code with +delay+:
<ruby>
-page.delay(10) { page.alert('Hey! Just waited 10 seconds') }
+page.delay(10) { page.alert('Hey! Just waited 10 seconds') }
</ruby>
+delay+ takes one parameter (time to wait in seconds) and a block which will be executed after the specified time has passed - whatever else follows a +page.delay+ line is executed immediately, the delay affects only the code in the block.
@@ -283,7 +283,7 @@ h6. Reloading and Redirecting
You can reload the page with the +reload+ method:
<ruby>
-page.reload
+page.reload
</ruby>
When using AJAX, you can't rely on the standard +redirect_to+ controller method - you have to use the +page+'s instance method, also called +redirect_to+:
@@ -292,7 +292,7 @@ When using AJAX, you can't rely on the standard +redirect_to+ controller method
page.redirect_to some_url
</ruby>
-h6. Generating Arbitrary JavaScript
+h6. Generating Arbitrary JavaScript
Sometimes even the full power of RJS is not enough to accomplish everything, but you still don't want to drop to pure JavaScript. A nice golden mean is offered by the combination of +<<+, +assign+ and +call+ methods:
diff --git a/railties/guides/source/api_documentation_guidelines.textile b/railties/guides/source/api_documentation_guidelines.textile
index 9f201de49b..d2ccb6475e 100644
--- a/railties/guides/source/api_documentation_guidelines.textile
+++ b/railties/guides/source/api_documentation_guidelines.textile
@@ -25,7 +25,7 @@ end
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.
-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?
+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?
The proper names of Rails components have a space in between the words, like "Active Support". +ActiveRecord+ is a Ruby module, whereas Active Record is an ORM. Historically there has been lack of consistency regarding this, but we checked with David when docrails started. All Rails documentation consistently refer to Rails components by their proper name, and if in your next blog post or presentation you remember this tidbit and take it into account that'd be fenomenal :).
@@ -125,7 +125,7 @@ def copy_instance_variables_from(object, exclude = [])
end
</ruby>
-WARNING: Using a pair of +&#43;...&#43;+ for fixed-width font only works with *words*; that is: anything matching <tt>\A\w&#43;\z</tt>. For anything else use +&lt;tt&gt;...&lt;/tt&gt;+, notably symbols, setters, inline snippets, etc:
+WARNING: Using a pair of +&#43;...&#43;+ for fixed-width font only works with *words*; that is: anything matching <tt>\A\w&#43;\z</tt>. For anything else use +&lt;tt&gt;...&lt;/tt&gt;+, notably symbols, setters, inline snippets, etc:
h4. Regular Font
diff --git a/railties/guides/source/association_basics.textile b/railties/guides/source/association_basics.textile
index fd1e7f4baf..079bb4b6b2 100644
--- a/railties/guides/source/association_basics.textile
+++ b/railties/guides/source/association_basics.textile
@@ -1401,8 +1401,8 @@ person = Person.create(:name => 'honda')
post = Post.create(:name => 'a1')
person.posts << post
person.posts << post
-person.posts.inspect # => [#<Post id: 7, name: "a1">]
-Reading.all.inspect # => [#<Reading id: 16, person_id: 7, post_id: 7>, #<Reading id: 17, person_id: 7, post_id: 7>]
+person.posts.inspect # => [#<Post id: 7, name: "a1">]
+Reading.all.inspect # => [#<Reading id: 16, person_id: 7, post_id: 7>, #<Reading id: 17, person_id: 7, post_id: 7>]
</ruby>
In the above case there are still two readings. However +person.posts+ shows only one post because the collection loads only unique records.
diff --git a/railties/guides/source/caching_with_rails.textile b/railties/guides/source/caching_with_rails.textile
index 6dee4b9c61..ff672d8695 100644
--- a/railties/guides/source/caching_with_rails.textile
+++ b/railties/guides/source/caching_with_rails.textile
@@ -98,7 +98,7 @@ You can also use +:if+ (or +:unless+) to pass a Proc that specifies when the act
You can modify the default action cache path by passing a +:cache_path+ option. This will be passed directly to +ActionCachePath.path_for+. This is handy for actions with multiple possible routes that should be cached differently. If a block is given, it is called with the current controller instance.
-Finally, if you are using memcached, you can also pass +:expires_in+. In fact, all parameters not used by +caches_action+ are sent to the underlying cache store.
+Finally, if you are using memcached, you can also pass +:expires_in+. In fact, all parameters not used by +caches_action+ are sent to the underlying cache store.
INFO: Action caching runs in an after filter. Thus, invalid requests won't generate spurious cache entries as long as you halt them. Typically, a redirection in some before filter that checks request preconditions does the job.
@@ -242,12 +242,12 @@ Rails 2.1 and above provide +ActiveSupport::Cache::Store+ which can be used to c
The default cache stores provided with Rails include:
-1) +ActiveSupport::Cache::MemoryStore+: A cache store implementation which stores everything into memory in the same process. If you're running multiple Ruby on Rails server processes (which is the case if you're using mongrel_cluster or Phusion Passenger), then this means that your Rails server process instances won't be able to share cache data with each other. If your application never performs manual cache item expiry (e.g. when you‘re using generational cache keys), then using +MemoryStore+ is ok. Otherwise, consider carefully whether you should be using this cache store.
+1) +ActiveSupport::Cache::MemoryStore+: A cache store implementation which stores everything into memory in the same process. If you're running multiple Ruby on Rails server processes (which is the case if you're using mongrel_cluster or Phusion Passenger), then this means that your Rails server process instances won't be able to share cache data with each other. If your application never performs manual cache item expiry (e.g. when you‘re using generational cache keys), then using +MemoryStore+ is ok. Otherwise, consider carefully whether you should be using this cache store.
+MemoryStore+ is not only able to store strings, but also arbitrary Ruby objects.
+MemoryStore+ is not thread-safe. Use +SynchronizedMemoryStore+ instead if you need thread-safety.
-
+
<ruby>
ActionController::Base.cache_store = :memory_store
</ruby>
@@ -280,7 +280,7 @@ It also accepts a hash of additional options:
The read and write methods of the +MemCacheStore+ accept an options hash too. When reading you can specify +:raw => true+ to prevent the object being marshaled (by default this is false which means the raw value in the cache is passed to +Marshal.load+ before being returned to you.)
-When writing to the cache it is also possible to specify +:raw => true+ means the value is not passed to +Marshal.dump+ before being stored in the cache (by default this is false).
+When writing to the cache it is also possible to specify +:raw => true+ means the value is not passed to +Marshal.dump+ before being stored in the cache (by default this is false).
The write method also accepts an +:unless_exist+ flag which determines whether the memcached add (when true) or set (when false) method is used to store the item in the cache and an +:expires_in+ option that specifies the time-to-live for the cached item in seconds.
@@ -367,7 +367,7 @@ h3. Advanced Caching
Along with the built-in mechanisms outlined above, a number of excellent plugins exist to help with finer grained control over caching. These include Chris Wanstrath's excellent cache_fu plugin (more info "here": http://errtheblog.com/posts/57-kickin-ass-w-cachefu) and Evan Weaver's interlock plugin (more info "here": http://blog.evanweaver.com/articles/2007/12/13/better-rails-caching/). Both of these plugins play nice with memcached and are a must-see for anyone
seriously considering optimizing their caching needs.
-Also the new "Cache money":http://github.com/nkallen/cache-money/tree/master plugin is supposed to be mad cool.
+Also the new "Cache money":http://github.com/nkallen/cache-money/tree/master plugin is supposed to be mad cool.
h3. References
diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile
index fb625f7a44..cbdfda9215 100644
--- a/railties/guides/source/command_line.textile
+++ b/railties/guides/source/command_line.textile
@@ -35,7 +35,7 @@ WARNING: You know you need the rails gem installed by typing +gem install rails+
<shell>
$ rails new commandsapp
- create
+ create
create README
create .gitignore
create Rakefile
@@ -570,7 +570,7 @@ h5. +test:+ Rails tests
INFO: A good description of unit testing in Rails is given in "A Guide to Testing Rails Applications":testing.html
-Rails comes with a test suite called Test::Unit. It is through the use of tests that Rails itself is so stable, and the slew of people working on Rails can prove that everything works as it should.
+Rails comes with a test suite called Test::Unit. It is through the use of tests that Rails itself is so stable, and the slew of people working on Rails can prove that everything works as it should.
The +test:+ namespace helps in running the different tests you will (hopefully!) write.
diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile
index 9e0c7cd060..81ef910822 100644
--- a/railties/guides/source/configuring.textile
+++ b/railties/guides/source/configuring.textile
@@ -51,15 +51,15 @@ h4. Rails General Configuration
* +config.dependency_loading+ enables or disables dependency loading during the request cycle. Setting dependency_loading to _true_ will allow new classes to be loaded during a request and setting it to _false_ will disable this behavior.
-* +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in +load_paths+.
+* +config.eager_load_paths+ accepts an array of paths from which Rails will eager load on boot if cache classes is enabled. All elements of this array must also be in +load_paths+.
* +config.load_once_paths+ accepts an array of paths from which Rails will automatically load from only once. All elements of this array must also be in +load_paths+.
-* +config.load_paths+ accepts an array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list.
+* +config.load_paths+ accepts an array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list.
-* +config.log_level+ defines the verbosity of the Rails logger. In production mode, this defaults to +:info+. In development mode, it defaults to +:debug+.
+* +config.log_level+ defines the verbosity of the Rails logger. In production mode, this defaults to +:info+. In development mode, it defaults to +:debug+.
-* +config.log_path+ overrides the path to the log file to use. Defaults to +log/#{environment}.log+ (e.g. log/development.log or log/production.log).
+* +config.log_path+ overrides the path to the log file to use. Defaults to +log/#{environment}.log+ (e.g. log/development.log or log/production.log).
* +config.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then used to log information from Action Controller. Set to nil to disable logging.
@@ -73,7 +73,7 @@ h4. Rails General Configuration
* +config.preload_frameworks+ enables or disables preloading all frameworks at startup.
-* +config.reload_plugins+ enables or disables plugin reloading.
+* +config.reload_plugins+ enables or disables plugin reloading.
* +config.root_path+ configures the root path of the application.
diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile
index ffb0310816..270fbe76d2 100644
--- a/railties/guides/source/getting_started.textile
+++ b/railties/guides/source/getting_started.textile
@@ -475,13 +475,13 @@ After the console loads, you can use it to work with your application's models:
<shell>
>> p = Post.new(:content => "A new post")
-=> #<Post id: nil, name: nil, title: nil,
+=> #<Post id: nil, name: nil, title: nil,
content: "A new post", created_at: nil,
updated_at: nil>
>> p.save
=> false
>> p.errors
-=> #<OrderedHash { :title=>["can't be blank",
+=> #<OrderedHash { :title=>["can't be blank",
"is too short (minimum is 5 characters)"],
:name=>["can't be blank"] }>
</shell>
@@ -742,7 +742,7 @@ def update
respond_to do |format|
if @post.update_attributes(params[:post])
- format.html { redirect_to(@post,
+ format.html { redirect_to(@post,
:notice => 'Post was successfully updated.') }
format.xml { head :ok }
else
@@ -1056,7 +1056,7 @@ Then in the +app/views/posts/show.html.erb+ you can change it to look like the f
</p>
<h2>Comments</h2>
-<%= render :partial => "comments/comment",
+<%= render :partial => "comments/comment",
:collection => @post.comments %>
<h2>Add a comment:</h2>
@@ -1127,7 +1127,7 @@ Then you make the +app/views/posts/show.html.erb+ look like the following:
</p>
<h2>Comments</h2>
-<%= render :partial => "comments/comment",
+<%= render :partial => "comments/comment",
:collection => @post.comments %>
<h2>Add a comment:</h2>
@@ -1213,15 +1213,15 @@ Rails provides a very simple HTTP authentication system that will work nicely in
<ruby>
class ApplicationController < ActionController::Base
protect_from_forgery
-
+
private
-
+
def authenticate
authenticate_or_request_with_http_basic do |user_name, password|
user_name == 'admin' && password == 'password'
end
end
-
+
end
</ruby>
@@ -1381,7 +1381,7 @@ Finally, we will edit the <tt>app/views/posts/show.html.erb</tt> template to sho
</p>
<h2>Comments</h2>
-<%= render :partial => "comments/comment",
+<%= render :partial => "comments/comment",
:collection => @post.comments %>
<h2>Add a comment:</h2>
@@ -1405,7 +1405,7 @@ Open up <tt>app/helpers/posts_helper.rb</tt> and add the following:
<erb>
module PostsHelper
def join_tags(post)
- post.tags.map { |t| t.name }.join(", ")
+ post.tags.map { |t| t.name }.join(", ")
end
end
</erb>
@@ -1436,7 +1436,7 @@ Now you can edit the view in <tt>app/views/posts/show.html.erb</tt> to look like
</p>
<h2>Comments</h2>
-<%= render :partial => "comments/comment",
+<%= render :partial => "comments/comment",
:collection => @post.comments %>
<h2>Add a comment:</h2>
diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile
index 63d22db485..1af51af80e 100644
--- a/railties/guides/source/i18n.textile
+++ b/railties/guides/source/i18n.textile
@@ -518,7 +518,7 @@ es:
title: "Título"
</yaml>
-you can look up the +books.index.title+ value *inside* +app/views/books/index.html.erb+ template like this (note the dot):
+you can look up the +books.index.title+ value *inside* +app/views/books/index.html.erb+ template like this (note the dot):
<ruby>
<%= t '.title' %>
diff --git a/railties/guides/source/initialization.textile b/railties/guides/source/initialization.textile
index f80c00b280..4e257d2e00 100644
--- a/railties/guides/source/initialization.textile
+++ b/railties/guides/source/initialization.textile
@@ -229,7 +229,7 @@ This file goes on to define some classes that will be automatically loaded using
<ruby>
require "active_support/inflector/methods"
require "active_support/lazy_load_hooks"
-
+
module ActiveSupport
module Autoload
def self.extended(base)
@@ -250,7 +250,7 @@ This file goes on to define some classes that will be automatically loaded using
end
super const_name, location
end
-
+
...
end
end
@@ -337,7 +337,7 @@ As you can see for the duration of the +eager_autoload+ block the class variable
autoload :I18n, "active_support/i18n"
</ruby>
-So we know the ones in +eager_autoload+ are eagerly loaded and it does this by storing them in an +@@autoloads+ hash object and then loading them via +eager_autoload!+ which is called via the +preload_frameworks+ initializer defined in _railties/lib/rails/application/bootstrap.rb_.
+So we know the ones in +eager_autoload+ are eagerly loaded and it does this by storing them in an +@@autoloads+ hash object and then loading them via +eager_autoload!+ which is called via the +preload_frameworks+ initializer defined in _railties/lib/rails/application/bootstrap.rb_.
The classes and modules that are not +eager_autoload+'d are automatically loaded as they are references
@@ -423,16 +423,16 @@ Now that Rails has required Action Dispatch and it has required Rack, Rails can
<ruby>
module Rails
class Server < ::Rack::Server
-
+
...
-
+
def initialize(*)
super
set_environment
end
-
+
...
-
+
def set_environment
ENV["RAILS_ENV"] ||= options[:environment]
end
@@ -486,7 +486,7 @@ And +default_options+ like this:
:AccessLog => [],
:config => "config.ru"
}
- end
+ end
</ruby>
Here it is important to note that the default environment is _development_. After +Rack::Server#initialize+ has done its thing it returns to +Rails::Server#initialize+ which calls +set_environment+:
@@ -752,7 +752,7 @@ If you wish to know more about how they're deprecated see the +require 'active_s
h4. +require 'rails/log_subscriber'+
-The +Rails::LogSubscriber+ provides a central location for logging in Rails 3 so as to not slow down the main thread. When you call one of the logging methods (+info+, +debug+, +warn+, +error+, +fatal+ or +unknown+) from the +Rails::LogSubscriber+ class or one of its subclasses this will notify the Rails logger to log this call in the fashion you specify, but will not write it to the file. The file writing is done at the end of the request, courtesy of the +Rails::Rack::Logger+ middleware.
+The +Rails::LogSubscriber+ provides a central location for logging in Rails 3 so as to not slow down the main thread. When you call one of the logging methods (+info+, +debug+, +warn+, +error+, +fatal+ or +unknown+) from the +Rails::LogSubscriber+ class or one of its subclasses this will notify the Rails logger to log this call in the fashion you specify, but will not write it to the file. The file writing is done at the end of the request, courtesy of the +Rails::Rack::Logger+ middleware.
Each Railtie defines its own class that descends from +Rails::LogSubscriber+ with each defining its own methods for logging individual tasks.
@@ -821,7 +821,7 @@ TODO: Quotify.
<plain>
Active Record connects business objects and database tables to create a persistable domain model where logic and data are presented in one wrapping. It's an implementation of the object-relational mapping (ORM) pattern by the same name as described by Martin Fowler:
- "An object that wraps a row in a database table or view, encapsulates
+ "An object that wraps a row in a database table or view, encapsulates
the database access, and adds domain logic on that data."
Active Record's main contribution to the pattern is to relieve the original of two stunting problems:
@@ -910,7 +910,7 @@ h5. +require 'active_record'+
Back the initial require from the _railtie.rb_.
-The _active_support_ and _active_model_ requires are again just an insurance for if we're loading Active Record outside of the scope of Rails. In _active_record.rb_ the ActiveRecord +Module+ is initialized and in it there is defined a couple of +autoloads+ and +eager_autoloads+.
+The _active_support_ and _active_model_ requires are again just an insurance for if we're loading Active Record outside of the scope of Rails. In _active_record.rb_ the ActiveRecord +Module+ is initialized and in it there is defined a couple of +autoloads+ and +eager_autoloads+.
There's a new method here called +autoload_under+ which is defined in +ActiveSupport::Autoload+. This sets the autoload path to temporarily be the specified path, in this case +relation+ for the +autoload+'d classes inside the block.
@@ -935,7 +935,7 @@ Inside the Active Record Railtie the +ActiveRecord::Railtie+ class is defined:
<ruby>
module ActiveRecord
class Railtie < Rails::Railtie
-
+
...
end
end
@@ -964,8 +964,8 @@ This Railtie is +require+'d by Active Record's Railtie.
From the Active Model readme:
<plain>
- Prior to Rails 3.0, if a plugin or gem developer wanted to be able to have an object interact with Action Pack helpers, it was required to either copy chunks of code from Rails, or monkey patch entire helpers to make them handle objects that did not look like Active Record. This generated code duplication and fragile applications that broke on upgrades.
-
+ Prior to Rails 3.0, if a plugin or gem developer wanted to be able to have an object interact with Action Pack helpers, it was required to either copy chunks of code from Rails, or monkey patch entire helpers to make them handle objects that did not look like Active Record. This generated code duplication and fragile applications that broke on upgrades.
+
Active Model is a solution for this problem.
Active Model provides a known set of interfaces that your objects can implement to then present a common interface to the Action Pack helpers.
@@ -999,7 +999,7 @@ This first makes a couple of requires:
require "action_view/railtie"
</ruby>
-The _action_controller_ file is explained in the very next section. The require to _rails_ is requiring the already-required _railties/lib/rails.rb_. If you wish to know about the require to _action_view/railtie_ this is explained in the Action View Railtie section.
+The _action_controller_ file is explained in the very next section. The require to _rails_ is requiring the already-required _railties/lib/rails.rb_. If you wish to know about the require to _action_view/railtie_ this is explained in the Action View Railtie section.
h5. +require 'action_controller+
@@ -1009,7 +1009,7 @@ h5. +require 'abstract_controller'+
+AbstractController+ provides the functionality of TODO.
-This file is in _actionpack/lib/abstract_controller.rb_ and begins by attempting to add the path to Active Support to the load path, which it would succeed in if it wasn't already set by anything loaded before it. In this case, it's not going to be set due to Arel already loading it in (TODO: right?).
+This file is in _actionpack/lib/abstract_controller.rb_ and begins by attempting to add the path to Active Support to the load path, which it would succeed in if it wasn't already set by anything loaded before it. In this case, it's not going to be set due to Arel already loading it in (TODO: right?).
The next thing in this file four +require+ calls:
@@ -1146,9 +1146,9 @@ For an explanation of this file _activesupport/lib/active_support/core_ext/class
h5. +require 'active_support/deprecation/proxy_wrappers'+
-This file, _activesupport/lib/active_support/deprecation/proxy_wrappers.rb_, defines a couple of deprecation classes, which are +DeprecationProxy+, +DeprecationObjectProxy+, +DeprecationInstanceVariableProxy+, +DeprecationConstantProxy+ which are all namespaced into +ActiveSupport::Deprecation+. These last three are all subclasses of +DeprecationProxy+.
+This file, _activesupport/lib/active_support/deprecation/proxy_wrappers.rb_, defines a couple of deprecation classes, which are +DeprecationProxy+, +DeprecationObjectProxy+, +DeprecationInstanceVariableProxy+, +DeprecationConstantProxy+ which are all namespaced into +ActiveSupport::Deprecation+. These last three are all subclasses of +DeprecationProxy+.
-Why do we mention them here? Beside the obvious-by-now fact that we're covering just about everything about the initialization process in this guide, if you're deprecating something in your library and you use Active Support, you too can use the +DeprecationProxy+ class (and it's subclasses) too.
+Why do we mention them here? Beside the obvious-by-now fact that we're covering just about everything about the initialization process in this guide, if you're deprecating something in your library and you use Active Support, you too can use the +DeprecationProxy+ class (and it's subclasses) too.
h6. +DeprecationProxy+
@@ -1177,7 +1177,7 @@ This class is used only in _railties/lib/rails/deprecation.rb_, loaded further o
end).new
</ruby>
-There is similar definitions for the other constants of +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+. All three of these constants are in the midst of being deprecated (most likely in Rails 3.1) so Rails will tell you if you reference them that they're deprecated using the +DeprecationProxy+ class. Whenever you call +RAILS_ROOT+ this will raise a warning, telling you: "RAILS_ROOT is deprecated! Use Rails.root instead".... TODO: investigate if simply calling it does raise this warning. This same rule applies to +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+, their new alternatives are +Rails.env+ and +Rails.logger+ respectively.
+There is similar definitions for the other constants of +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+. All three of these constants are in the midst of being deprecated (most likely in Rails 3.1) so Rails will tell you if you reference them that they're deprecated using the +DeprecationProxy+ class. Whenever you call +RAILS_ROOT+ this will raise a warning, telling you: "RAILS_ROOT is deprecated! Use Rails.root instead".... TODO: investigate if simply calling it does raise this warning. This same rule applies to +RAILS_ENV+ and +RAILS_DEFAULT_LOGGER+, their new alternatives are +Rails.env+ and +Rails.logger+ respectively.
h6. +DeprecatedObjectProxy+
@@ -1203,7 +1203,7 @@ This makes more sense in the wider scope of the initializer:
end
</ruby>
-+ActionController::Routing::Routes+ was the previous constant used in defining routes in Rails 2 applications, now it's simply a method on +Rails.application+ rather than it's own individual class: +Rails.application.routes+. Both of these still call the +draw+ method on the returned object to end up defining the routes.
++ActionController::Routing::Routes+ was the previous constant used in defining routes in Rails 2 applications, now it's simply a method on +Rails.application+ rather than it's own individual class: +Rails.application.routes+. Both of these still call the +draw+ method on the returned object to end up defining the routes.
h6. +DeprecatedInstanceVariableProxy+
@@ -1362,7 +1362,7 @@ Here again we have the addition of the path to Active Support to the load path a
And these have already been required. If you wish to know what these files do go to the explanation of each in the "Common Includes" section. TODO: link to them!
-This file goes on to +require 'action_pack'+ which consists of all this code (comments stripped):
+This file goes on to +require 'action_pack'+ which consists of all this code (comments stripped):
<ruby>
require 'action_pack/version'
@@ -1445,11 +1445,11 @@ After including +ActiveSupport::Benchmarkable+, the helpers which we have declar
h5. +ActionView::Rendering+
-This module, from _actionpack/lib/action_view/render/rendering.rb_ defines a method you may be a little too familiar with: +render+. This is the +render+ use for rendering all kinds of things, such as partials, templates and text.
+This module, from _actionpack/lib/action_view/render/rendering.rb_ defines a method you may be a little too familiar with: +render+. This is the +render+ use for rendering all kinds of things, such as partials, templates and text.
h5. +ActionView::Partials+
-This module, from _actionpack/lib/action_view/render/partials.rb_, defines +ActionView::Partials::PartialRenderer+ which you can probably guess is used for rendering partials.
+This module, from _actionpack/lib/action_view/render/partials.rb_, defines +ActionView::Partials::PartialRenderer+ which you can probably guess is used for rendering partials.
h5. +ActionView::Layouts+
@@ -1487,7 +1487,7 @@ Next, the Railtie itself is defined:
end
end
end
-</ruby>
+</ruby>
The +ActionView::LogSubscriber+ sets up a method called +render_template+ which is called when a template is rendered. TODO: Templates only or partials and layouts also? I would imagine these fall under the templates category, but there needs to research to ensure this is correct.
@@ -1502,7 +1502,7 @@ are used to consolidate code for sending out forgotten passwords, welcome
wishes on signup, invoices for billing, and any other use case that requires
a written notification to either a person or another system.
-Action Mailer is in essence a wrapper around Action Controller and the
+Action Mailer is in essence a wrapper around Action Controller and the
Mail gem. It provides a way to make emails using templates in the same
way that Action Controller renders views using templates.
@@ -1580,7 +1580,7 @@ which is used by the +ActionMailer::MailerHelper+ method +block_format+:
:columns => 72, :first_indent => 2, :body_indent => 2, :text => paragraph
).format
}.join("\n")
-
+
# Make list points stand on their own line
formatted.gsub!(/[ ]*([*]+) ([^*]*)/) { |s| " #{$1} #{$2.strip}\n" }
formatted.gsub!(/[ ]*([#]+) ([^#]*)/) { |s| " #{$1} #{$2.strip}\n" }
@@ -1687,7 +1687,7 @@ There is only one initializer defined here: +set_configs+. This is covered later
h4. ActionDispatch Railtie
-ActionDispatch handles all dispatch work for Rails. It interfaces with Action Controller to determine what action to undertake when a request comes in. TODO: I would quote the README but it is strangely absent. Flyin' blind here!
+ActionDispatch handles all dispatch work for Rails. It interfaces with Action Controller to determine what action to undertake when a request comes in. TODO: I would quote the README but it is strangely absent. Flyin' blind here!
The ActionDispatch Railtie was previously required when we called +require 'rails'+, but we will cover the Railtie here too.
@@ -1817,7 +1817,7 @@ This +called_from+ setting looks a little overwhelming to begin with, but the sh
base.send(:include, self::Configurable)
subclasses << base
end
- end
+ end
</ruby>
Again, +YourApp::Application+ will return false for +abstract_railtie+ and so the code inside the +unless+ will be ran. The first line:
@@ -1886,7 +1886,7 @@ Now that we've covered the boot process of Rails the next line best to cover wou
Rails::Server.start
</ruby>
-The keen-eyed observer will note that this +when+ also specifies the argument could also be simply +'s'+ thereby making the full command +rails s+. This is the same with the other commands with +generate+ becoming +g+, +console+ becoming +c+ and +dbconsole+ becoming +db+.
+The keen-eyed observer will note that this +when+ also specifies the argument could also be simply +'s'+ thereby making the full command +rails s+. This is the same with the other commands with +generate+ becoming +g+, +console+ becoming +c+ and +dbconsole+ becoming +db+.
This code here ensures we are at the +ROOT_PATH+ of our application (this constant was defined in _script/rails_) and then calls +Rails::Server.start+. +Rails::Server+ descends from +Rack::Server+ which is defined in the rack gem. The +Rails::Server.start+ method is defined like this:
@@ -1997,7 +1997,7 @@ Finally! We've arrived at +default_options+ which leads into our next point quit
end
</ruby>
-We're not debugging anything, so there goes the first 7 lines, we're not warning, nor are we including, requiring, daemonising or writing out a pid file. That's everything except the final line, which calls +run+ with the +wrapped_app+ which is then defined like this:
+We're not debugging anything, so there goes the first 7 lines, we're not warning, nor are we including, requiring, daemonising or writing out a pid file. That's everything except the final line, which calls +run+ with the +wrapped_app+ which is then defined like this:
<ruby>
def wrapped_app
@@ -2051,7 +2051,7 @@ First this reads your config file and checks it for +#\+ at the beginning. This
require ::File.expand_path('../config/environment', __FILE__)
run YourApp::Application.instance
-
+
</ruby>
TODO: Is the above correct? I am simply guessing!
@@ -2246,7 +2246,7 @@ The method +find_with_root_flag+ is defined on +Rails::Engine+ (the superclass o
Pathname.new(root).expand_path : Pathname.new(root).realpath
end
</ruby>
-
+
+called_from+ goes through the +caller+ which is the stacktrace of the current thread, in the case of your application it would go a little like this:
<pre>
@@ -2274,7 +2274,7 @@ The method +find_with_root_flag+ is defined on +Rails::Engine+ (the superclass o
end
</ruby>
-The +call_stack+ here is the +caller+ output shown previously, minus everything after the first +:+ on all the lines. The first path that matches this is _/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta1/lib/rails_. Yours may vary slightly, but should always end in _railties-x.x.x/lib/rails_.
+The +call_stack+ here is the +caller+ output shown previously, minus everything after the first +:+ on all the lines. The first path that matches this is _/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta1/lib/rails_. Yours may vary slightly, but should always end in _railties-x.x.x/lib/rails_.
The code in +find_root_with_flag+ will go up this directory structure until it reaches the top, which in this case is +/+.
@@ -2302,7 +2302,7 @@ At the root of the system it looks for +config.ru+. TODO: Why? Obviously it's no
@serve_static_assets = true
@time_zone = "UTC"
@consider_all_requests_local = true
- end
+ end
</ruby>
The +super+ method here is the +initialize+ method in +Rails::Engine::Configuration+:
@@ -2604,7 +2604,7 @@ The +plugins+ method it calls is a little more complex:
</ruby>
When we call +@config.paths.vendor.plugins+ it will return +"vendor/plugins"+.
-
+
If you've defined specific plugin requirements for your application in _config/application.rb_ by using this code:
@@ -2725,7 +2725,7 @@ Now we finally have all the +initializers+ we can go through them and call +run+
end
</ruby>
-You may remember that the +@context+ in this code is +YourApp::Application+ and calling +instance_exec+ on this class will make a new instance of it and execute the code within the +&block+ passed to it. This code within the block is the code from all the initializers.
+You may remember that the +@context+ in this code is +YourApp::Application+ and calling +instance_exec+ on this class will make a new instance of it and execute the code within the +&block+ passed to it. This code within the block is the code from all the initializers.
h3. Bootstrap Initializers
@@ -2759,15 +2759,15 @@ We've seen +config.paths+ before when loading the plugins and they're explained
<ruby>
module Rails
class << self
-
+
...
-
+
def env
@_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development")
end
-
+
...
-
+
end
end
</ruby>
@@ -2953,7 +2953,7 @@ This is where it gets loaded. The +eager_autoload!+ method is defined like this:
end
</ruby>
-With +@@autoloads+ being
+With +@@autoloads+ being
* load_all_active_support
@@ -3144,9 +3144,9 @@ h4. +ActionDispatch::MiddlewareStack.new+
<ruby>
module ActionDispatch
class MiddlewareStack < Array
-
+
...
-
+
def initialize(*args, &block)
super(*args)
block.call(self) if block_given?
@@ -3188,9 +3188,9 @@ This +initialize+ method also is in a class who's ancestry is important so once
<ruby>
module ActionController
class Middleware < Metal
-
+
...
-
+
def initialize(app)
super()
@_app = app
@@ -3207,9 +3207,9 @@ This is another subclassed class, this time from +ActionController::AbstractCont
<ruby>
class Metal < AbstractController::Base
-
+
...
-
+
def initialize(*)
@_headers = {}
super
@@ -3217,7 +3217,7 @@ This is another subclassed class, this time from +ActionController::AbstractCont
end
</ruby>
-The single +*+ in the argument listing means we can accept any number of arguments, we just don't care what they are.
+The single +*+ in the argument listing means we can accept any number of arguments, we just don't care what they are.
h4. +AbstractController::Base.initialize+
@@ -3232,7 +3232,7 @@ This may be anti-climatic, but the initialize method here just returns an +Abstr
h4. +ActionDispatch::MiddlewareStack.use+
-Now we're back to this method, from our foray into the depths of how +Middleware.new+ works, we've showed that it is an instance of +AbstractController::Base+. Therefore it does
+Now we're back to this method, from our foray into the depths of how +Middleware.new+ works, we've showed that it is an instance of +AbstractController::Base+. Therefore it does
TODO: ELABORATE ON THIS SECTION, including explaining what all the pieces of middleware do. Then explain how the default_middleware_stack does what it does, whatever that is.
@@ -3309,7 +3309,7 @@ In a standard Rails application we have this in our _config/environments/develop
end
</ruby>
-It's a little bit sneaky here, but +configure+ is +alias+'d to +class_eval+ on subclasses of +Rails::Application+ which of course includes +YourApp::Application+. This means that the code inside the +configure do+ block will be evaled within the context of +YourApp::Application+. The +config+ method here is the one mentioned before: the +Rails::Application::Configuration+ object. The methods on it should look familiar too: they're the ones that had +attr_accessor+ and +attr_writer+ definitions.
+It's a little bit sneaky here, but +configure+ is +alias+'d to +class_eval+ on subclasses of +Rails::Application+ which of course includes +YourApp::Application+. This means that the code inside the +configure do+ block will be evaled within the context of +YourApp::Application+. The +config+ method here is the one mentioned before: the +Rails::Application::Configuration+ object. The methods on it should look familiar too: they're the ones that had +attr_accessor+ and +attr_writer+ definitions.
The ones down the bottom, +config.action_controller+, +config.action_view+ and +config.action_mailer+ aren't defined by +attr_accessor+ or +attr_writer+, rather they're undefined methods and therefore will trigger the +method_missing+ on the +Rails::Application::Configuration+ option.
@@ -3381,7 +3381,7 @@ I'm going to show you two methods since the third one, +self.plugin_name+, calls
@plugins ||= []
@plugins << klass unless klass == Plugin
end
-
+
def self.plugins
@plugins
end
@@ -3472,7 +3472,7 @@ h5. +Rack::Handler::WEBrick+
This class is subclassed from +WEBrick::HTTPServlet::AbstractServlet+ which is a class that comes with the Ruby standard library. This is the magical class that serves the requests and deals with the comings (requests) and goings (responses) for your server.
-+Rack::Server+ has handlers for the request and by default the handler for a _rails server_ server is
++Rack::Server+ has handlers for the request and by default the handler for a _rails server_ server is
h3. Cruft!
@@ -3706,7 +3706,7 @@ This file is _activesupport/lib/active_support/inflector.rb_ and makes a couple
require 'active_support/core_ext/string/inflections'
</ruby>
-The files included here define methods for modifying strings, such as +transliterate+ which will convert a Unicode string to its ASCII version, +parameterize+ for making strings into url-safe versions, +camelize+ for camel-casing a string such as +string_other+ into +StringOther+ and +ordinalize+ converting a string such as +101+ into +101st+. More information about these methods can be found in the Active Support Core Extensions Guide. TODO: Link to AS Guide.
+The files included here define methods for modifying strings, such as +transliterate+ which will convert a Unicode string to its ASCII version, +parameterize+ for making strings into url-safe versions, +camelize+ for camel-casing a string such as +string_other+ into +StringOther+ and +ordinalize+ converting a string such as +101+ into +101st+. More information about these methods can be found in the Active Support Core Extensions Guide. TODO: Link to AS Guide.
h4. +require 'active_support/core_ext/module/delegation'+
@@ -3715,7 +3715,7 @@ _activesupport/lib/active_support/core_ext/module/delegation.rb_ defines the +de
<ruby>
class Client < ActiveRecord::Base
has_one :address
-
+
delegate :address_line_1, :to => :address
end
</ruby>
@@ -3736,7 +3736,7 @@ h4. +require 'active_support/core_ext/class/attribute_accessors'+
The file, _activesupport/lib/active_support/core_ext/class/attribute_accessors.rb_, defines the class accessor methods +cattr_writer+, +cattr_reader+ and +cattr_accessor+. +cattr_accessor+ defines a +cattr_reader+ and +cattr_writer+ for the symbol passed in. These methods work by defining class variables when you call their dynamic methods.
-Throughout the Railties there a couple of common includes. They are listed here for your convenience.
+Throughout the Railties there a couple of common includes. They are listed here for your convenience.
h4. +require 'active_support/core_ext/module/attr_internal+
diff --git a/railties/guides/source/layouts_and_rendering.textile b/railties/guides/source/layouts_and_rendering.textile
index b9a201e5f0..fe5b4c8773 100644
--- a/railties/guides/source/layouts_and_rendering.textile
+++ b/railties/guides/source/layouts_and_rendering.textile
@@ -143,7 +143,7 @@ def update
end
</ruby>
-If the call to +update_attributes+ fails, calling the +update+ action in this controller will render the +edit.html.erb+ template belonging to the same controller.
+If the call to +update_attributes+ fails, calling the +update+ action in this controller will render the +edit.html.erb+ template belonging to the same controller.
If you prefer, you can use a symbol instead of a string to specify the action to render:
@@ -200,7 +200,7 @@ render "/u/apps/warehouse_app/current/app/views/products/show"
Rails determines that this is a file render because of the leading slash character. To be explicit, you can use the +:file+ option (which was required on Rails 2.2 and earlier):
<ruby>
-render :file =>
+render :file =>
"/u/apps/warehouse_app/current/app/views/products/show"
</ruby>
@@ -240,7 +240,7 @@ h5. Using +render+ with +:inline+
The +render+ method can do without a view completely, if you're willing to use the +:inline+ option to supply ERB as part of the method call. This is perfectly valid:
<ruby>
-render :inline =>
+render :inline =>
"<% products.each do |p| %><p><%= p.name %><p><% end %>"
</ruby>
@@ -249,7 +249,7 @@ WARNING: There is seldom any good reason to use this option. Mixing ERB into you
By default, inline rendering uses ERb. You can force it to use Builder instead with the +:type+ option:
<ruby>
-render :inline =>
+render :inline =>
"xml.p {'Horrid coding practice!'}", :type => :builder
</ruby>
@@ -676,7 +676,7 @@ h5. Linking to Feeds with +auto_discovery_link_tag+
The +auto_discovery_link_tag+ helper builds HTML that most browsers and newsreaders can use to detect the presences of RSS or ATOM feeds. It takes the type of the link (+:rss+ or +:atom+), a hash of options that are passed through to url_for, and a hash of options for the tag:
<erb>
-<%= auto_discovery_link_tag(:rss, {:action => "feed"},
+<%= auto_discovery_link_tag(:rss, {:action => "feed"},
{:title => "RSS Feed"}) %>
</erb>
@@ -739,7 +739,7 @@ If you're loading multiple javascript files, you can create a better user experi
By default, the combined file will be delivered as +javascripts/all.js+. You can specify a location for the cached asset file instead:
<erb>
-<%= javascript_include_tag "main", "columns",
+<%= javascript_include_tag "main", "columns",
:cache => 'cache/main/display' %>
</erb>
@@ -798,7 +798,7 @@ If you're loading multiple CSS files, you can create a better user experience by
By default, the combined file will be delivered as +stylesheets/all.css+. You can specify a location for the cached asset file instead:
<erb>
-<%= stylesheet_link_tag "main", "columns",
+<%= stylesheet_link_tag "main", "columns",
:cache => 'cache/main/display' %>
</erb>
@@ -1085,7 +1085,7 @@ Partials are very useful in rendering collections. When you pass a collection to
<p>Product Name: <%= product.name %></p>
</erb>
-When a partial is called with a pluralized collection, then the individual instances of the partial have access to the member of the collection being rendered via a variable named after the partial. In this case, the partial is +_product+, and within the +_product+ partial, you can refer to +product+ to get the instance that is being rendered.
+When a partial is called with a pluralized collection, then the individual instances of the partial have access to the member of the collection being rendered via a variable named after the partial. In this case, the partial is +_product+, and within the +_product+ partial, you can refer to +product+ to get the instance that is being rendered.
In Rails 3.0 there is also a shorthand for this, assuming +@posts+ is a collection of +post+ instances, you can simply do in the +index.html.erb+:
@@ -1132,7 +1132,7 @@ With this change, you can access an instance of the +@products+ collection as th
You can also pass in arbitrary local variables to any partial you are rendering with the +:locals => {}+ option:
<erb>
-<%= render :partial => 'products', :collection => @products,
+<%= render :partial => 'products', :collection => @products,
:as => :item, :locals => {:title => "Products Page"} %>
</erb>
diff --git a/railties/guides/source/nested_model_forms.textile b/railties/guides/source/nested_model_forms.textile
index 39b0c32f24..1d44da4df1 100644
--- a/railties/guides/source/nested_model_forms.textile
+++ b/railties/guides/source/nested_model_forms.textile
@@ -63,7 +63,7 @@ class Person
def address
Address.new
end
-
+
def address_attributes=(attributes)
# ...
end
@@ -77,7 +77,7 @@ class Person
def projects
[Project.new, Project.new]
end
-
+
def projects_attributes=(attributes)
# ...
end
@@ -101,7 +101,7 @@ class PeopleController < ActionController:Base
@person.built_address
2.times { @person.projects.build }
end
-
+
def create
@person = Person.new(params[:person])
if @person.save
@@ -142,7 +142,7 @@ Now add a nested form for the +address+ association:
<erb>
<%= form_for @person do |f| %>
<%= f.text_field :name %>
-
+
<%= f.fields_for :address do |af| %>
<%= f.text_field :street %>
<% end %>
@@ -154,7 +154,7 @@ This generates:
<html>
<form action="/people" class="new_person" id="new_person" method="post">
<input id="person_name" name="person[name]" size="30" type="text" />
-
+
<input id="person_address_attributes_street" name="person[address_attributes][street]" size="30" type="text" />
</form>
</html>
@@ -183,7 +183,7 @@ The form code for an association collection is pretty similar to that of a singl
<erb>
<%= form_for @person do |f| %>
<%= f.text_field :name %>
-
+
<%= f.fields_for :projects do |pf| %>
<%= f.text_field :name %>
<% end %>
@@ -195,7 +195,7 @@ Which generates:
<html>
<form action="/people" class="new_person" id="new_person" method="post">
<input id="person_name" name="person[name]" size="30" type="text" />
-
+
<input id="person_projects_attributes_0_name" name="person[projects_attributes][0][name]" size="30" type="text" />
<input id="person_projects_attributes_1_name" name="person[projects_attributes][1][name]" size="30" type="text" />
</form>
diff --git a/railties/guides/source/plugins.textile b/railties/guides/source/plugins.textile
index 82f2276153..f89043f216 100644
--- a/railties/guides/source/plugins.textile
+++ b/railties/guides/source/plugins.textile
@@ -323,7 +323,7 @@ Finally, create the +core_ext.rb+ file and add the +to_squawk+ method:
<ruby>
# vendor/plugins/yaffle/lib/yaffle/core_ext.rb
-
+
String.class_eval do
def to_squawk
"squawk! #{self}".strip
diff --git a/railties/guides/source/rails_application_templates.textile b/railties/guides/source/rails_application_templates.textile
index 1bf9cfec33..bc7b151dfe 100644
--- a/railties/guides/source/rails_application_templates.textile
+++ b/railties/guides/source/rails_application_templates.textile
@@ -79,7 +79,7 @@ plugin 'authentication', :git => 'git://github.com/foor/bar.git'
You can even install plugins as git submodules :
<ruby>
-plugin 'authentication', :git => 'git://github.com/foor/bar.git',
+plugin 'authentication', :git => 'git://github.com/foor/bar.git',
:submodule => true
</ruby>
@@ -103,7 +103,7 @@ class Object
def not_nil?
!nil?
end
-
+
def not_blank?
!blank?
end
diff --git a/railties/guides/source/routing.textile b/railties/guides/source/routing.textile
index 625941ba31..d92c66cfd2 100644
--- a/railties/guides/source/routing.textile
+++ b/railties/guides/source/routing.textile
@@ -501,7 +501,7 @@ class BlacklistConstraint
end
TwitterClone::Application.routes.draw do
- match "*path" => "blacklist#index",
+ match "*path" => "blacklist#index",
:constraints => BlacklistConstraint.new
end
</ruby>
@@ -765,7 +765,7 @@ formatted_users GET /users.:format {:controller=>"users", :action=>"index"}
You may restrict the listing to the routes that map to a particular controller setting the +CONTROLLER+ environment variable:
<shell>
-$ CONTROLLER=users rake routes
+$ CONTROLLER=users rake routes
</shell>
TIP: You'll find that the output from +rake routes+ is much more readable if you widen your terminal window until the output lines don't wrap.
diff --git a/railties/guides/source/security.textile b/railties/guides/source/security.textile
index 6372c606b7..4656cf4e40 100644
--- a/railties/guides/source/security.textile
+++ b/railties/guides/source/security.textile
@@ -401,7 +401,7 @@ Note that this vulnerability is not restricted to database columns. Any setter
class Child < ActiveRecord::Base
belongs_to :person
- end
+ end
</ruby>
As a result, the vulnerability is extended beyond simply exposing column assignment, allowing attackers the ability to create entirely new records in referenced tables (children in this case).
diff --git a/railties/guides/w3c_validator.rb b/railties/guides/w3c_validator.rb
index 4da48bf3fb..da5200c0b7 100644
--- a/railties/guides/w3c_validator.rb
+++ b/railties/guides/w3c_validator.rb
@@ -21,7 +21,7 @@
#
# Separate many using commas:
#
-# # validates only
+# # validates only
# ONLY=assoc,migrations rake validate_guides
#
# ---------------------------------------------------------------------------
@@ -32,13 +32,13 @@ include W3CValidators
module RailsGuides
class Validator
-
+
def validate
validator = MarkupValidator.new
STDOUT.sync = true
errors_on_guides = {}
- guides_to_validate.each do |f|
+ guides_to_validate.each do |f|
results = validator.validate_file(f)
if results.validity
@@ -48,10 +48,10 @@ module RailsGuides
errors_on_guides[f] = results.errors
end
end
-
+
show_results(errors_on_guides)
end
-
+
private
def guides_to_validate
guides = Dir["./guides/output/*.html"]
@@ -65,13 +65,13 @@ module RailsGuides
prefixes.any? {|p| guide.start_with?("./guides/output/#{p}")}
end
end
-
+
def show_results(error_list)
if error_list.size == 0
puts "\n\nAll checked guides validate OK!"
else
error_summary = error_detail = ""
-
+
error_list.each_pair do |name, errors|
error_summary += "\n #{name}"
error_detail += "\n\n #{name} has #{errors.size} validation error(s):\n"
@@ -79,12 +79,12 @@ module RailsGuides
error_detail += "\n "+error.to_s.gsub("\n", "")
end
end
-
+
puts "\n\nThere are #{error_list.size} guides with validation errors:\n" + error_summary
puts "\nHere are the detailed errors for each guide:" + error_detail
end
end
-
+
end
end
diff --git a/railties/lib/rails/code_statistics.rb b/railties/lib/rails/code_statistics.rb
index 740d8a1767..57e29a0045 100644
--- a/railties/lib/rails/code_statistics.rb
+++ b/railties/lib/rails/code_statistics.rb
@@ -12,7 +12,7 @@ class CodeStatistics #:nodoc:
print_header
@pairs.each { |pair| print_line(pair.first, @statistics[pair.first]) }
print_splitter
-
+
if @total
print_line("Total", @total)
print_splitter
@@ -29,7 +29,7 @@ class CodeStatistics #:nodoc:
def calculate_directory_statistics(directory, pattern = /.*\.rb$/)
stats = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 }
- Dir.foreach(directory) do |file_name|
+ Dir.foreach(directory) do |file_name|
if File.stat(directory + "/" + file_name).directory? and (/^\./ !~ file_name)
newstats = calculate_directory_statistics(directory + "/" + file_name, pattern)
stats.each { |k, v| stats[k] += newstats[k] }
@@ -85,10 +85,10 @@ class CodeStatistics #:nodoc:
start = if TEST_TYPES.include? name
"| #{name.ljust(20)} "
else
- "| #{name.ljust(20)} "
+ "| #{name.ljust(20)} "
end
- puts start +
+ puts start +
"| #{statistics["lines"].to_s.rjust(5)} " +
"| #{statistics["codelines"].to_s.rjust(5)} " +
"| #{statistics["classes"].to_s.rjust(7)} " +
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb
index fdfceb14ce..f97f3db588 100644
--- a/railties/lib/rails/generators/base.rb
+++ b/railties/lib/rails/generators/base.rb
@@ -81,7 +81,7 @@ module Rails
# guessed based on class invokes hook_for, as noticed in the example above.
# This can be customized with two options: :base and :as.
#
- # Let's suppose you are creating a generator that needs to invoke the
+ # Let's suppose you are creating a generator that needs to invoke the
# controller generator from test unit. Your first attempt is:
#
# class AwesomeGenerator < Rails::Generators::Base
diff --git a/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js b/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js
index 066ee5909c..c81e6c7d5f 100644
--- a/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js
+++ b/railties/lib/rails/generators/rails/app/templates/public/javascripts/effects.js
@@ -150,7 +150,7 @@ var Effect = {
toggle: function(element, effect, options) {
element = $(element);
effect = (effect || 'appear').toLowerCase();
-
+
return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({
queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
}, options || {}));
diff --git a/railties/lib/rails/generators/rails/generator/USAGE b/railties/lib/rails/generators/rails/generator/USAGE
index d8c3f7f634..d68539e4a6 100644
--- a/railties/lib/rails/generators/rails/generator/USAGE
+++ b/railties/lib/rails/generators/rails/generator/USAGE
@@ -1,6 +1,6 @@
Description:
Stubs out a new generator at lib/generators. Pass the generator name, either
- CamelCased or under_scored, as an argument.
+ CamelCased or under_scored, as an argument.
Example:
`rails generate generator Awesome`
diff --git a/railties/lib/rails/generators/rails/migration/USAGE b/railties/lib/rails/generators/rails/migration/USAGE
index d21c81b760..af74963b01 100644
--- a/railties/lib/rails/generators/rails/migration/USAGE
+++ b/railties/lib/rails/generators/rails/migration/USAGE
@@ -18,12 +18,12 @@ Example:
This will create the AddTitleBodyToPost in db/migrate/20080514090912_add_title_body_to_post.rb with
this in the Up migration:
- add_column :posts, :title, :string
- add_column :posts, :body, :text
+ add_column :posts, :title, :string
+ add_column :posts, :body, :text
add_column :posts, :published, :boolean
And this in the Down migration:
- remove_column :posts, :published
- remove_column :posts, :body
+ remove_column :posts, :published
+ remove_column :posts, :body
remove_column :posts, :title
diff --git a/railties/lib/rails/generators/rails/plugin/USAGE b/railties/lib/rails/generators/rails/plugin/USAGE
index 00a429c585..1bcfcf190d 100644
--- a/railties/lib/rails/generators/rails/plugin/USAGE
+++ b/railties/lib/rails/generators/rails/plugin/USAGE
@@ -1,6 +1,6 @@
Description:
Stubs out a new plugin at vendor/plugins. Pass the plugin name, either
- CamelCased or under_scored, as an argument.
+ CamelCased or under_scored, as an argument.
Example:
`rails generate plugin BrowserFilters`
diff --git a/railties/lib/rails/generators/rails/resource/resource_generator.rb b/railties/lib/rails/generators/rails/resource/resource_generator.rb
index fc070026d6..8a943013d3 100644
--- a/railties/lib/rails/generators/rails/resource/resource_generator.rb
+++ b/railties/lib/rails/generators/rails/resource/resource_generator.rb
@@ -16,9 +16,9 @@ module Rails
def add_resource_route
return if options[:actions].present?
- route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
+ route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
route_config << "resources :#{file_name.pluralize}"
- route_config << " end" * class_path.size
+ route_config << " end" * class_path.size
route route_config
end
end
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb
index be229cc9a2..8d5132a5ca 100644
--- a/railties/lib/rails/plugin.rb
+++ b/railties/lib/rails/plugin.rb
@@ -16,7 +16,7 @@ module Rails
# Besides this conceptual difference, the only difference between Rails::Engine and
# Rails::Plugin is that plugins automatically load the file "init.rb" at the plugin
# root during the boot process.
- #
+ #
class Plugin < Engine
def self.inherited(base)
raise "You cannot inherit from Rails::Plugin"
diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb
index 8a6e2716dc..2684552701 100644
--- a/railties/lib/rails/railtie.rb
+++ b/railties/lib/rails/railtie.rb
@@ -48,7 +48,7 @@ module Rails
# # lib/my_gem/railtie.rb
# require 'my_gem'
# require 'rails'
- #
+ #
# module MyGem
# class Railtie < Rails::Railtie
# end
@@ -121,7 +121,7 @@ module Rails
# described here can be used in all three.
#
# Be sure to look at the documentation of those specific classes for more information.
- #
+ #
class Railtie
autoload :Configurable, "rails/railtie/configurable"
autoload :Configuration, "rails/railtie/configuration"
diff --git a/railties/lib/rails/script_rails_loader.rb b/railties/lib/rails/script_rails_loader.rb
index 91672e5d81..7054089614 100644
--- a/railties/lib/rails/script_rails_loader.rb
+++ b/railties/lib/rails/script_rails_loader.rb
@@ -17,11 +17,11 @@ module Rails
rescue SystemCallError
# could not chdir, no problem just return
end
-
+
def self.in_rails_application?
File.exists?(SCRIPT_RAILS)
end
-
+
def self.in_rails_application_subdirectory?(path = Pathname.new(Dir.pwd))
File.exists?(File.join(path, SCRIPT_RAILS)) || !path.root? && in_rails_application_subdirectory?(path.parent)
end
diff --git a/railties/lib/rails/tasks/documentation.rake b/railties/lib/rails/tasks/documentation.rake
index c1b1a41d48..7aefbb49b0 100644
--- a/railties/lib/rails/tasks/documentation.rake
+++ b/railties/lib/rails/tasks/documentation.rake
@@ -4,15 +4,15 @@ require 'rake/rdoctask'
class RDocTaskWithoutDescriptions < Rake::RDocTask
def define
task rdoc_task_name
-
+
task rerdoc_task_name => [clobber_task_name, rdoc_task_name]
-
+
task clobber_task_name do
rm_r rdoc_dir rescue nil
end
-
+
task :clobber => [clobber_task_name]
-
+
directory @rdoc_dir
task rdoc_task_name => [rdoc_target]
file rdoc_target => @rdoc_files + [Rake.application.rakefile] do
diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb
index 340ce67511..ecf7904c39 100644
--- a/railties/test/application/loading_test.rb
+++ b/railties/test/application/loading_test.rb
@@ -18,10 +18,10 @@ class LoadingTest < Test::Unit::TestCase
validates_acceptance_of :title, :accept => "omg"
end
MODEL
-
+
require "#{rails_root}/config/environment"
setup_ar!
-
+
p = Post.create(:title => 'omg')
assert_equal 1, Post.count
assert_equal 'omg', p.title
@@ -73,7 +73,7 @@ class LoadingTest < Test::Unit::TestCase
end
protected
-
+
def setup_ar!
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
ActiveRecord::Migration.verbose = false
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index d6e100ffe3..454c9511d8 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -14,7 +14,7 @@ module ApplicationTests
app_file "lib/tasks/app.rake", <<-RUBY
$task_loaded = Rake::Task.task_defined?("db:create:all")
RUBY
-
+
require "#{app_path}/config/environment"
::Rails.application.load_tasks
assert $task_loaded
diff --git a/railties/test/generators/actions_test.rb b/railties/test/generators/actions_test.rb
index 0472ca73a8..f5473333ed 100644
--- a/railties/test/generators/actions_test.rb
+++ b/railties/test/generators/actions_test.rb
@@ -88,7 +88,7 @@ class ActionsTest < Rails::Generators::TestCase
assert_deprecated do
action :gem, 'thoughtbot-factory_girl', :require_as => 'factory_girl', :source => 'http://gems.github.com'
- end
+ end
assert_file 'Gemfile', /gem "mislav\-will\-paginate", :require => "will\-paginate"/
assert_file 'Gemfile', /source "http:\/\/gems\.github\.com"/
@@ -103,7 +103,7 @@ class ActionsTest < Rails::Generators::TestCase
end
assert_deprecated do
- action :gem, 'rspec-rails', :only => %w(development test)
+ action :gem, 'rspec-rails', :only => %w(development test)
end
assert_file 'Gemfile', /gem "rspec", :group => \["development", "test"\]/
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index 08cfb585f9..849c8001f4 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -79,7 +79,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
reserved_words = %w[application destroy plugin runner test]
reserved_words.each do |reserved|
content = capture(:stderr){ run_generator [File.join(destination_root, reserved)] }
- assert_equal "Invalid application name #{reserved}. Please give a name which does not match one of the reserved rails words.\n", content
+ assert_equal "Invalid application name #{reserved}. Please give a name which does not match one of the reserved rails words.\n", content
end
end
diff --git a/railties/test/railties/railtie_test.rb b/railties/test/railties/railtie_test.rb
index db0fd87491..6715003d3d 100644
--- a/railties/test/railties/railtie_test.rb
+++ b/railties/test/railties/railtie_test.rb
@@ -132,7 +132,7 @@ module RailtiesTest
require "#{app_path}/config/environment"
assert $ran_block
end
-
+
test "we can change our environment if we want to" do
begin
original_env = Rails.env
diff --git a/railties/test/script_rails_loader_test.rb b/railties/test/script_rails_loader_test.rb
index 2a87e5cb58..3ccc147749 100644
--- a/railties/test/script_rails_loader_test.rb
+++ b/railties/test/script_rails_loader_test.rb
@@ -2,21 +2,21 @@ require 'abstract_unit'
require 'rails/script_rails_loader'
class ScriptRailsLoaderTest < ActiveSupport::TestCase
-
+
test "is in a rails application if script/rails exists" do
File.stubs(:exists?).returns(true)
assert Rails::ScriptRailsLoader.in_rails_application?
end
-
+
test "is in a rails application if parent directory has script/rails" do
File.stubs(:exists?).with("/foo/bar/script/rails").returns(false)
File.stubs(:exists?).with("/foo/script/rails").returns(true)
assert Rails::ScriptRailsLoader.in_rails_application_subdirectory?(Pathname.new("/foo/bar"))
end
-
+
test "is not in a rails application if at the root directory and doesn't have script/rails" do
Pathname.any_instance.stubs(:root?).returns true
assert !Rails::ScriptRailsLoader.in_rails_application?
end
-
+
end \ No newline at end of file