radiant 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of radiant might be problematic. Click here for more details.
- data/CHANGELOG +33 -1
- data/CONTRIBUTORS +15 -2
- data/INSTALL +9 -7
- data/README +11 -7
- data/app/controllers/admin/layouts_controller.rb +5 -2
- data/app/controllers/admin/pages_controller.rb +8 -5
- data/app/controllers/admin/snippets_controller.rb +5 -2
- data/app/controllers/application_controller.rb +7 -0
- data/app/helpers/admin/node_helper.rb +2 -2
- data/app/helpers/application_helper.rb +2 -2
- data/app/models/radiant/config.rb +36 -4
- data/app/models/standard_tags.rb +1 -1
- data/app/views/admin/layouts/index.html.haml +15 -12
- data/app/views/admin/page_parts/_page_part.html.haml +2 -2
- data/app/views/admin/pages/index.html.haml +1 -1
- data/app/views/admin/snippets/_form.html.haml +1 -1
- data/app/views/admin/snippets/index.html.haml +14 -10
- data/config/database.db2.yml +20 -0
- data/config/environment.rb +4 -4
- data/config/environments/test.rb +1 -2
- data/features/support/env.rb +2 -1
- data/lib/generators/extension/extension_generator.rb +5 -0
- data/lib/generators/extension/templates/RSpecRakefile +11 -8
- data/lib/generators/extension/templates/cucumber.yml +1 -0
- data/lib/generators/extension/templates/cucumber_env.rb +16 -0
- data/lib/generators/extension/templates/cucumber_paths.rb +14 -0
- data/lib/generators/extension/templates/extension.rb +1 -1
- data/lib/generators/instance/instance_generator.rb +1 -1
- data/lib/generators/instance/templates/databases/db2.yml +40 -0
- data/lib/generators/instance/templates/instance_environment.rb +6 -6
- data/lib/local_time.rb +3 -9
- data/lib/radiant.rb +1 -1
- data/lib/radiant/cache.rb +10 -8
- data/lib/radiant/extension.rb +36 -0
- data/lib/radiant/extension/script.rb +1 -1
- data/lib/radiant/extension_loader.rb +5 -1
- data/lib/radiant/initializer.rb +52 -4
- data/lib/task_support.rb +33 -0
- data/lib/tasks/cucumber.rake +5 -1
- data/lib/tasks/radiant_config.rake +18 -0
- data/lib/tasks/release.rake +1 -0
- data/public/javascripts/admin/admin.js +1 -1
- data/spec/controllers/admin/layouts_controller_spec.rb +18 -12
- data/spec/controllers/admin/pages_controller_spec.rb +35 -29
- data/spec/controllers/admin/snippets_controller_spec.rb +11 -5
- data/spec/controllers/admin/welcome_controller_spec.rb +1 -1
- data/spec/controllers/application_controller_spec.rb +18 -0
- data/spec/fixtures/radiant_config.yml +10 -0
- data/spec/generators/extension_generator_spec.rb +12 -0
- data/spec/helpers/admin/node_helper_spec.rb +6 -0
- data/spec/helpers/application_helper_spec.rb +1 -1
- data/spec/lib/radiant/extension_loader_spec.rb +17 -0
- data/spec/lib/radiant/extension_spec.rb +28 -0
- data/spec/lib/radiant/initializer_spec.rb +34 -0
- data/spec/lib/task_support_spec.rb +42 -0
- data/spec/models/page_spec.rb +6 -2
- data/spec/models/radiant/config_spec.rb +42 -1
- data/spec/models/standard_tags_spec.rb +2 -2
- data/test/fixtures/extensions/01_basic/app/metal/basic_metal.rb +9 -0
- data/test/fixtures/extensions/02_overriding/app/metal/basic_metal.rb +9 -0
- data/vendor/extensions/textile_filter/textile.html +2 -2
- data/vendor/plugins/dataset/CHANGELOG +2 -1
- data/vendor/plugins/dataset/Rakefile +3 -0
- data/vendor/plugins/dataset/VERSION.yml +2 -2
- data/vendor/plugins/dataset/dataset.gemspec +9 -3
- data/vendor/plugins/dataset/lib/dataset.rb +3 -0
- data/vendor/radius/lib/radius.rb +5 -0
- data/vendor/radius/test/radius_test.rb +6 -0
- data/vendor/rails/actionmailer/CHANGELOG +8 -0
- data/vendor/rails/actionmailer/Rakefile +3 -2
- data/vendor/rails/actionmailer/lib/action_mailer/base.rb +2 -1
- data/vendor/rails/actionmailer/lib/action_mailer/version.rb +1 -1
- data/vendor/rails/actionmailer/test/abstract_unit.rb +0 -3
- data/vendor/rails/actionmailer/test/mail_service_test.rb +3 -2
- data/vendor/rails/actionpack/CHANGELOG +16 -0
- data/vendor/rails/actionpack/Rakefile +5 -3
- data/vendor/rails/actionpack/lib/action_controller.rb +2 -7
- data/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +13 -3
- data/vendor/rails/actionpack/lib/action_controller/base.rb +12 -3
- data/vendor/rails/actionpack/lib/action_controller/caching.rb +1 -1
- data/vendor/rails/actionpack/lib/action_controller/caching/actions.rb +9 -1
- data/vendor/rails/actionpack/lib/action_controller/caching/sweeper.rb +45 -0
- data/vendor/rails/actionpack/lib/action_controller/caching/sweeping.rb +0 -42
- data/vendor/rails/actionpack/lib/action_controller/cookies.rb +1 -1
- data/vendor/rails/actionpack/lib/action_controller/dispatcher.rb +21 -6
- data/vendor/rails/actionpack/lib/action_controller/failsafe.rb +40 -6
- data/vendor/rails/actionpack/lib/action_controller/flash.rb +11 -3
- data/vendor/rails/actionpack/lib/action_controller/http_authentication.rb +7 -3
- data/vendor/rails/actionpack/lib/action_controller/integration.rb +5 -12
- data/vendor/rails/actionpack/lib/action_controller/middlewares.rb +0 -1
- data/vendor/rails/actionpack/lib/action_controller/params_parser.rb +6 -0
- data/vendor/rails/actionpack/lib/action_controller/reloader.rb +47 -7
- data/vendor/rails/actionpack/lib/action_controller/request.rb +6 -2
- data/vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb +2 -1
- data/vendor/rails/actionpack/lib/action_controller/resources.rb +17 -13
- data/vendor/rails/actionpack/lib/action_controller/response.rb +8 -2
- data/vendor/rails/actionpack/lib/action_controller/routing.rb +3 -0
- data/vendor/rails/actionpack/lib/action_controller/routing/route_set.rb +20 -6
- data/vendor/rails/actionpack/lib/action_controller/streaming.rb +4 -2
- data/vendor/rails/actionpack/lib/action_controller/test_process.rb +9 -1
- data/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +1 -1
- data/vendor/rails/actionpack/lib/action_pack/version.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/helpers.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb +21 -9
- data/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb +2 -2
- data/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb +26 -12
- data/vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb +71 -1
- data/vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb +10 -4
- data/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +7 -7
- data/vendor/rails/actionpack/lib/action_view/helpers/scriptaculous_helper.rb +5 -5
- data/vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb +23 -14
- data/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb +2 -2
- data/vendor/rails/actionpack/lib/action_view/locale/en.yml +4 -0
- data/vendor/rails/actionpack/lib/action_view/paths.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/template.rb +22 -33
- data/vendor/rails/actionpack/test/abstract_unit.rb +17 -1
- data/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb +3 -3
- data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +27 -0
- data/vendor/rails/actionpack/test/controller/caching_test.rb +40 -1
- data/vendor/rails/actionpack/test/controller/cookie_test.rb +16 -0
- data/vendor/rails/actionpack/test/controller/dispatcher_test.rb +59 -18
- data/vendor/rails/actionpack/test/controller/failsafe_test.rb +60 -0
- data/vendor/rails/actionpack/test/controller/filter_params_test.rb +3 -1
- data/vendor/rails/actionpack/test/controller/flash_test.rb +6 -1
- data/vendor/rails/actionpack/test/controller/http_basic_authentication_test.rb +25 -0
- data/vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb +63 -9
- data/vendor/rails/actionpack/test/controller/integration_test.rb +31 -3
- data/vendor/rails/actionpack/test/controller/rack_test.rb +18 -1
- data/vendor/rails/actionpack/test/controller/redirect_test.rb +4 -1
- data/vendor/rails/actionpack/test/controller/reloader_test.rb +124 -0
- data/vendor/rails/actionpack/test/controller/render_test.rb +19 -9
- data/vendor/rails/actionpack/test/controller/request/json_params_parsing_test.rb +24 -4
- data/vendor/rails/actionpack/test/controller/request/multipart_params_parsing_test.rb +1 -62
- data/vendor/rails/actionpack/test/controller/request/test_request_test.rb +35 -0
- data/vendor/rails/actionpack/test/controller/request/url_encoded_params_parsing_test.rb +0 -38
- data/vendor/rails/actionpack/test/controller/request/xml_params_parsing_test.rb +15 -0
- data/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb +6 -5
- data/vendor/rails/actionpack/test/controller/request_test.rb +218 -230
- data/vendor/rails/actionpack/test/controller/resources_test.rb +52 -0
- data/vendor/rails/actionpack/test/controller/routing_test.rb +28 -2
- data/vendor/rails/actionpack/test/controller/send_file_test.rb +12 -2
- data/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb +9 -32
- data/vendor/rails/actionpack/test/controller/test_test.rb +8 -0
- data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +29 -3
- data/vendor/rails/actionpack/test/fixtures/failsafe/500.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/absolute/test.css +23 -0
- data/vendor/rails/actionpack/test/fixtures/public/absolute/test.js +63 -0
- data/vendor/rails/actionpack/test/template/active_record_helper_test.rb +1 -1
- data/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +46 -0
- data/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb +29 -0
- data/vendor/rails/actionpack/test/template/form_helper_test.rb +143 -6
- data/vendor/rails/actionpack/test/template/form_options_helper_i18n_test.rb +27 -0
- data/vendor/rails/actionpack/test/template/form_options_helper_test.rb +56 -0
- data/vendor/rails/actionpack/test/template/form_tag_helper_test.rb +23 -6
- data/vendor/rails/actionpack/test/template/prototype_helper_test.rb +11 -11
- data/vendor/rails/actionpack/test/template/template_test.rb +32 -0
- data/vendor/rails/actionpack/test/template/text_helper_test.rb +23 -0
- data/vendor/rails/actionpack/test/template/url_helper_test.rb +8 -0
- data/vendor/rails/activerecord/CHANGELOG +18 -0
- data/vendor/rails/activerecord/Rakefile +26 -9
- data/vendor/rails/activerecord/examples/performance.rb +162 -0
- data/vendor/rails/activerecord/lib/active_record/associations.rb +104 -35
- data/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +10 -5
- data/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb +2 -2
- data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb +22 -4
- data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +5 -1
- data/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +16 -0
- data/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +1 -0
- data/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +13 -3
- data/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb +15 -9
- data/vendor/rails/activerecord/lib/active_record/autosave_association.rb +15 -9
- data/vendor/rails/activerecord/lib/active_record/base.rb +34 -31
- data/vendor/rails/activerecord/lib/active_record/batches.rb +23 -15
- data/vendor/rails/activerecord/lib/active_record/calculations.rb +7 -13
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +16 -2
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +2 -2
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +7 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +17 -8
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +98 -35
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +15 -0
- data/vendor/rails/activerecord/lib/active_record/dirty.rb +1 -1
- data/vendor/rails/activerecord/lib/active_record/fixtures.rb +14 -11
- data/vendor/rails/activerecord/lib/active_record/i18n_interpolation_deprecation.rb +1 -1
- data/vendor/rails/activerecord/lib/active_record/locale/en.yml +4 -0
- data/vendor/rails/activerecord/lib/active_record/named_scope.rb +3 -8
- data/vendor/rails/activerecord/lib/active_record/reflection.rb +1 -1
- data/vendor/rails/activerecord/lib/active_record/schema_dumper.rb +6 -3
- data/vendor/rails/activerecord/lib/active_record/serialization.rb +3 -2
- data/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb +10 -18
- data/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb +6 -2
- data/vendor/rails/activerecord/lib/active_record/session_store.rb +9 -1
- data/vendor/rails/activerecord/lib/active_record/timestamp.rb +39 -9
- data/vendor/rails/activerecord/lib/active_record/validations.rb +149 -80
- data/vendor/rails/activerecord/lib/active_record/version.rb +1 -1
- data/vendor/rails/activerecord/test/cases/adapter_test.rb +12 -0
- data/vendor/rails/activerecord/test/cases/associations/belongs_to_associations_test.rb +102 -22
- data/vendor/rails/activerecord/test/cases/associations/eager_load_nested_include_test.rb +5 -5
- data/vendor/rails/activerecord/test/cases/associations/eager_test.rb +12 -0
- data/vendor/rails/activerecord/test/cases/associations/habtm_join_table_test.rb +56 -0
- data/vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb +62 -2
- data/vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb +46 -1
- data/vendor/rails/activerecord/test/cases/associations/has_one_through_associations_test.rb +18 -1
- data/vendor/rails/activerecord/test/cases/associations/inner_join_association_test.rb +5 -0
- data/vendor/rails/activerecord/test/cases/associations/join_model_test.rb +4 -4
- data/vendor/rails/activerecord/test/cases/autosave_association_test.rb +22 -0
- data/vendor/rails/activerecord/test/cases/base_test.rb +51 -6
- data/vendor/rails/activerecord/test/cases/calculations_test.rb +14 -14
- data/vendor/rails/activerecord/test/cases/column_definition_test.rb +34 -0
- data/vendor/rails/activerecord/test/cases/copy_table_test_sqlite.rb +5 -5
- data/vendor/rails/activerecord/test/cases/dirty_test.rb +10 -0
- data/vendor/rails/activerecord/test/cases/finder_test.rb +21 -50
- data/vendor/rails/activerecord/test/cases/fixtures_test.rb +6 -1
- data/vendor/rails/activerecord/test/cases/helper.rb +1 -2
- data/vendor/rails/activerecord/test/cases/i18n_test.rb +5 -0
- data/vendor/rails/activerecord/test/cases/json_serialization_test.rb +57 -57
- data/vendor/rails/activerecord/test/cases/method_scoping_test.rb +14 -4
- data/vendor/rails/activerecord/test/cases/migration_test.rb +39 -11
- data/vendor/rails/activerecord/test/cases/modules_test.rb +42 -0
- data/vendor/rails/activerecord/test/cases/named_scope_test.rb +6 -4
- data/vendor/rails/activerecord/test/cases/pk_test.rb +18 -0
- data/vendor/rails/activerecord/test/cases/reflection_test.rb +7 -7
- data/vendor/rails/activerecord/test/cases/schema_dumper_test.rb +35 -7
- data/vendor/rails/activerecord/test/cases/schema_test_postgresql.rb +76 -0
- data/vendor/rails/activerecord/test/cases/timestamp_test.rb +75 -0
- data/vendor/rails/activerecord/test/cases/validations_i18n_test.rb +656 -624
- data/vendor/rails/activerecord/test/cases/validations_test.rb +12 -2
- data/vendor/rails/activerecord/test/cases/xml_serialization_test.rb +20 -0
- data/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite +0 -0
- data/vendor/rails/activerecord/test/fixtures/fixture_database.sqlite3 +0 -0
- data/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite +0 -0
- data/vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite3 +0 -0
- data/vendor/rails/activerecord/test/fixtures/posts.yml +3 -0
- data/vendor/rails/activerecord/test/models/author.rb +5 -0
- data/vendor/rails/activerecord/test/models/comment.rb +5 -1
- data/vendor/rails/activerecord/test/models/company.rb +9 -7
- data/vendor/rails/activerecord/test/models/company_in_module.rb +1 -1
- data/vendor/rails/activerecord/test/models/contract.rb +5 -0
- data/vendor/rails/activerecord/test/models/developer.rb +10 -0
- data/vendor/rails/activerecord/test/models/essay.rb +3 -0
- data/vendor/rails/activerecord/test/models/organization.rb +2 -0
- data/vendor/rails/activerecord/test/models/pet.rb +1 -1
- data/vendor/rails/activerecord/test/models/project.rb +1 -1
- data/vendor/rails/activerecord/test/models/reply.rb +2 -1
- data/vendor/rails/activerecord/test/models/topic.rb +1 -2
- data/vendor/rails/activerecord/test/models/toy.rb +2 -0
- data/vendor/rails/activerecord/test/schema/postgresql_specific_schema.rb +13 -2
- data/vendor/rails/activerecord/test/schema/schema.rb +19 -0
- data/vendor/rails/activeresource/CHANGELOG +16 -0
- data/vendor/rails/activeresource/Rakefile +3 -2
- data/vendor/rails/activeresource/lib/active_resource/base.rb +89 -9
- data/vendor/rails/activeresource/lib/active_resource/connection.rb +73 -8
- data/vendor/rails/activeresource/lib/active_resource/exceptions.rb +66 -0
- data/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb +2 -2
- data/vendor/rails/activeresource/lib/active_resource/validations.rb +20 -4
- data/vendor/rails/activeresource/lib/active_resource/version.rb +1 -1
- data/vendor/rails/activeresource/test/abstract_unit.rb +1 -3
- data/vendor/rails/activeresource/test/base/load_test.rb +16 -1
- data/vendor/rails/activeresource/test/base_errors_test.rb +56 -19
- data/vendor/rails/activeresource/test/base_test.rb +147 -0
- data/vendor/rails/activeresource/test/connection_test.rb +42 -0
- data/vendor/rails/activeresource/test/debug.log +7974 -0
- data/vendor/rails/activeresource/test/fixtures/proxy.rb +4 -0
- data/vendor/rails/activesupport/CHANGELOG +13 -0
- data/vendor/rails/activesupport/lib/active_support/all.rb +8 -0
- data/vendor/rails/activesupport/lib/active_support/cache.rb +14 -1
- data/vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb +16 -10
- data/vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb +1 -1
- data/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb +1 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb +2 -1
- data/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb +2 -4
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +14 -4
- data/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb +4 -2
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +2 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb +19 -5
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/model_naming.rb +8 -6
- data/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb +15 -9
- data/vendor/rails/activesupport/lib/active_support/core_ext/string.rb +1 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb +29 -5
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/bytesize.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb +7 -7
- data/vendor/rails/activesupport/lib/active_support/deprecation.rb +9 -9
- data/vendor/rails/activesupport/lib/active_support/duration.rb +4 -2
- data/vendor/rails/activesupport/lib/active_support/json.rb +1 -22
- data/vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb +38 -0
- data/vendor/rails/activesupport/lib/active_support/json/backends/yaml.rb +88 -0
- data/vendor/rails/activesupport/lib/active_support/json/decoding.rb +23 -72
- data/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb +9 -8
- data/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb +9 -8
- data/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb +14 -9
- data/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb +4 -2
- data/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb +21 -11
- data/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb +4 -2
- data/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb +16 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb +6 -2
- data/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb +4 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb +5 -32
- data/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb +2 -2
- data/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb +9 -8
- data/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb +4 -2
- data/vendor/rails/activesupport/lib/active_support/json/encoding.rb +80 -9
- data/vendor/rails/activesupport/lib/active_support/memoizable.rb +1 -1
- data/vendor/rails/activesupport/lib/active_support/message_verifier.rb +16 -3
- data/vendor/rails/activesupport/lib/active_support/multibyte.rb +30 -6
- data/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +23 -17
- data/vendor/rails/activesupport/lib/active_support/multibyte/utils.rb +61 -0
- data/vendor/rails/activesupport/lib/active_support/ordered_hash.rb +28 -0
- data/vendor/rails/activesupport/lib/active_support/test_case.rb +9 -8
- data/vendor/rails/activesupport/lib/active_support/testing/deprecation.rb +2 -0
- data/vendor/rails/activesupport/lib/active_support/time_with_zone.rb +9 -8
- data/vendor/rails/activesupport/lib/active_support/vendor.rb +6 -7
- data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +0 -1
- data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +0 -1
- data/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +0 -1
- data/vendor/rails/activesupport/lib/active_support/vendor/{memcache-client-1.6.5 → memcache-client-1.7.4}/memcache.rb +242 -70
- data/vendor/rails/activesupport/lib/active_support/version.rb +1 -1
- data/vendor/rails/activesupport/lib/active_support/xml_mini/jdom.rb +162 -0
- data/vendor/rails/railties/CHANGELOG +10 -0
- data/vendor/rails/railties/Rakefile +13 -9
- data/vendor/rails/railties/bin/about +2 -2
- data/vendor/rails/railties/bin/console +1 -1
- data/vendor/rails/railties/bin/dbconsole +1 -1
- data/vendor/rails/railties/bin/destroy +1 -1
- data/vendor/rails/railties/bin/generate +1 -1
- data/vendor/rails/railties/bin/performance/benchmarker +1 -1
- data/vendor/rails/railties/bin/performance/profiler +1 -1
- data/vendor/rails/railties/bin/plugin +1 -1
- data/vendor/rails/railties/bin/runner +1 -1
- data/vendor/rails/railties/bin/server +1 -1
- data/vendor/rails/railties/builtin/rails_info/rails/info.rb +4 -2
- data/vendor/rails/railties/configs/initializers/new_rails_defaults.rb +2 -0
- data/vendor/rails/railties/configs/routes.rb +1 -1
- data/vendor/rails/railties/configs/seeds.rb +7 -0
- data/vendor/rails/railties/environments/boot.rb +1 -1
- data/vendor/rails/railties/guides/files/javascripts/code_highlighter.js +188 -0
- data/vendor/rails/railties/guides/files/javascripts/guides.js +8 -0
- data/vendor/rails/railties/guides/files/javascripts/highlighters.js +90 -0
- data/vendor/rails/railties/guides/files/stylesheets/main.css +441 -0
- data/vendor/rails/railties/guides/files/stylesheets/print.css +52 -0
- data/vendor/rails/railties/guides/files/stylesheets/reset.css +43 -0
- data/vendor/rails/railties/guides/files/stylesheets/style.css +13 -0
- data/vendor/rails/railties/guides/files/stylesheets/syntax.css +31 -0
- data/vendor/rails/railties/guides/images/belongs_to.png +0 -0
- data/vendor/rails/railties/guides/images/book_icon.gif +0 -0
- data/vendor/rails/railties/guides/images/bullet.gif +0 -0
- data/vendor/rails/railties/guides/images/chapters_icon.gif +0 -0
- data/vendor/rails/railties/guides/images/check_bullet.gif +0 -0
- data/vendor/rails/railties/guides/images/credits_pic_blank.gif +0 -0
- data/vendor/rails/railties/guides/images/csrf.png +0 -0
- data/vendor/rails/railties/guides/images/customized_error_messages.png +0 -0
- data/vendor/rails/railties/guides/images/error_messages.png +0 -0
- data/vendor/rails/railties/guides/images/feature_tile.gif +0 -0
- data/vendor/rails/railties/guides/images/footer_tile.gif +0 -0
- data/vendor/rails/railties/guides/images/fxn.jpg +0 -0
- data/vendor/rails/railties/guides/images/grey_bullet.gif +0 -0
- data/vendor/rails/railties/guides/images/habtm.png +0 -0
- data/vendor/rails/railties/guides/images/has_many.png +0 -0
- data/vendor/rails/railties/guides/images/has_many_through.png +0 -0
- data/vendor/rails/railties/guides/images/has_one.png +0 -0
- data/vendor/rails/railties/guides/images/has_one_through.png +0 -0
- data/vendor/rails/railties/guides/images/header_backdrop.png +0 -0
- data/vendor/rails/railties/guides/images/header_tile.gif +0 -0
- data/vendor/rails/railties/guides/images/i18n/demo_localized_pirate.png +0 -0
- data/vendor/rails/railties/guides/images/i18n/demo_translated_en.png +0 -0
- data/vendor/rails/railties/guides/images/i18n/demo_translated_pirate.png +0 -0
- data/vendor/rails/railties/guides/images/i18n/demo_translation_missing.png +0 -0
- data/vendor/rails/railties/guides/images/i18n/demo_untranslated.png +0 -0
- data/vendor/rails/railties/guides/images/icons/README +5 -0
- data/vendor/rails/railties/guides/images/icons/callouts/1.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/10.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/11.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/12.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/13.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/14.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/15.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/2.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/3.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/4.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/5.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/6.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/7.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/8.png +0 -0
- data/vendor/rails/railties/guides/images/icons/callouts/9.png +0 -0
- data/vendor/rails/railties/guides/images/icons/caution.png +0 -0
- data/vendor/rails/railties/guides/images/icons/example.png +0 -0
- data/vendor/rails/railties/guides/images/icons/home.png +0 -0
- data/vendor/rails/railties/guides/images/icons/important.png +0 -0
- data/vendor/rails/railties/guides/images/icons/next.png +0 -0
- data/vendor/rails/railties/guides/images/icons/note.png +0 -0
- data/vendor/rails/railties/guides/images/icons/prev.png +0 -0
- data/vendor/rails/railties/guides/images/icons/tip.png +0 -0
- data/vendor/rails/railties/guides/images/icons/up.png +0 -0
- data/vendor/rails/railties/guides/images/icons/warning.png +0 -0
- data/vendor/rails/railties/guides/images/nav_arrow.gif +0 -0
- data/vendor/rails/railties/guides/images/polymorphic.png +0 -0
- data/vendor/rails/railties/guides/images/posts_index.png +0 -0
- data/vendor/rails/railties/guides/images/rails_guides_logo.gif +0 -0
- data/vendor/rails/railties/guides/images/rails_logo_remix.gif +0 -0
- data/vendor/rails/railties/guides/images/rails_welcome.png +0 -0
- data/vendor/rails/railties/guides/images/session_fixation.png +0 -0
- data/vendor/rails/railties/guides/images/tab_grey.gif +0 -0
- data/vendor/rails/railties/guides/images/tab_info.gif +0 -0
- data/vendor/rails/railties/guides/images/tab_note.gif +0 -0
- data/vendor/rails/railties/guides/images/tab_red.gif +0 -0
- data/vendor/rails/railties/guides/images/tab_yellow.gif +0 -0
- data/vendor/rails/railties/guides/images/tab_yellow.png +0 -0
- data/vendor/rails/railties/guides/images/validation_error_messages.png +0 -0
- data/vendor/rails/railties/guides/rails_guides.rb +42 -0
- data/vendor/rails/railties/guides/rails_guides/generator.rb +138 -0
- data/vendor/rails/railties/guides/rails_guides/helpers.rb +34 -0
- data/vendor/rails/railties/guides/rails_guides/indexer.rb +55 -0
- data/vendor/rails/railties/guides/rails_guides/textile_extensions.rb +41 -0
- data/vendor/rails/railties/guides/source/2_2_release_notes.textile +422 -0
- data/vendor/rails/railties/guides/source/2_3_release_notes.textile +610 -0
- data/vendor/rails/railties/guides/source/action_controller_overview.textile +776 -0
- data/vendor/rails/railties/guides/source/action_mailer_basics.textile +424 -0
- data/vendor/rails/railties/guides/source/active_record_basics.textile +135 -0
- data/vendor/rails/railties/guides/source/active_record_querying.textile +969 -0
- data/vendor/rails/railties/guides/source/activerecord_validations_callbacks.textile +1086 -0
- data/vendor/rails/railties/guides/source/association_basics.textile +1781 -0
- data/vendor/rails/railties/guides/source/caching_with_rails.textile +524 -0
- data/vendor/rails/railties/guides/source/command_line.textile +589 -0
- data/vendor/rails/railties/guides/source/configuring.textile +234 -0
- data/vendor/rails/railties/guides/source/contribute.textile +71 -0
- data/vendor/rails/railties/guides/source/contributing_to_rails.textile +239 -0
- data/vendor/rails/railties/guides/source/credits.erb.textile +52 -0
- data/vendor/rails/railties/guides/source/debugging_rails_applications.textile +709 -0
- data/vendor/rails/railties/guides/source/form_helpers.textile +766 -0
- data/vendor/rails/railties/guides/source/getting_started.textile +1297 -0
- data/vendor/rails/railties/guides/source/i18n.textile +912 -0
- data/vendor/rails/railties/guides/source/index.erb.textile +124 -0
- data/vendor/rails/railties/guides/source/layout.html.erb +103 -0
- data/vendor/rails/railties/guides/source/layouts_and_rendering.textile +979 -0
- data/vendor/rails/railties/guides/source/migrations.textile +591 -0
- data/vendor/rails/railties/guides/source/nested_model_forms.textile +222 -0
- data/vendor/rails/railties/guides/source/performance_testing.textile +531 -0
- data/vendor/rails/railties/guides/source/plugins.textile +1512 -0
- data/vendor/rails/railties/guides/source/rails_on_rack.textile +309 -0
- data/vendor/rails/railties/guides/source/routing.textile +903 -0
- data/vendor/rails/railties/guides/source/security.textile +986 -0
- data/vendor/rails/railties/guides/source/testing.textile +951 -0
- data/vendor/rails/railties/lib/commands/dbconsole.rb +8 -4
- data/vendor/rails/railties/lib/commands/performance/profiler.rb +1 -1
- data/vendor/rails/railties/lib/initializer.rb +27 -4
- data/vendor/rails/railties/lib/rails/gem_dependency.rb +35 -6
- data/vendor/rails/railties/lib/rails/plugin.rb +12 -0
- data/vendor/rails/railties/lib/rails/plugin/loader.rb +7 -0
- data/vendor/rails/railties/lib/rails/rack/metal.rb +1 -1
- data/vendor/rails/railties/lib/rails/version.rb +1 -1
- data/vendor/rails/railties/lib/rails_generator/base.rb +1 -1
- data/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb +5 -0
- data/vendor/rails/railties/lib/rails_generator/generators/applications/app/template_runner.rb +1 -1
- data/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb +9 -2
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +1 -0
- data/vendor/rails/railties/lib/tasks/databases.rake +17 -4
- data/vendor/rails/railties/lib/tasks/gems.rake +19 -6
- data/vendor/rails/railties/lib/tasks/routes.rake +4 -3
- data/vendor/rails/railties/lib/test_help.rb +4 -1
- metadata +158 -58
- data/spec/lib/local_time_spec.rb +0 -40
- data/vendor/rails/actionpack/lib/action_controller/rewindable_input.rb +0 -28
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack.rb +0 -89
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/adapter/camping.rb +0 -22
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/handler.rb +0 -37
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/abstract/request.rb +0 -37
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/basic.rb +0 -58
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/md5.rb +0 -124
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/nonce.rb +0 -51
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/params.rb +0 -55
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/digest/request.rb +0 -40
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/auth/openid.rb +0 -480
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/builder.rb +0 -63
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/cascade.rb +0 -36
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/chunked.rb +0 -49
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/commonlogger.rb +0 -61
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/conditionalget.rb +0 -45
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_length.rb +0 -29
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/content_type.rb +0 -23
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/deflater.rb +0 -85
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/directory.rb +0 -153
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/file.rb +0 -88
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler.rb +0 -48
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/cgi.rb +0 -61
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/evented_mongrel.rb +0 -8
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/fastcgi.rb +0 -89
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/lsws.rb +0 -55
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/mongrel.rb +0 -84
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/scgi.rb +0 -59
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb +0 -8
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/thin.rb +0 -18
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/handler/webrick.rb +0 -67
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/head.rb +0 -19
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lint.rb +0 -462
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lobster.rb +0 -65
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/lock.rb +0 -16
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/methodoverride.rb +0 -27
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mime.rb +0 -204
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/mock.rb +0 -160
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/recursive.rb +0 -57
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/reloader.rb +0 -64
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/request.rb +0 -241
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/response.rb +0 -179
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/abstract/id.rb +0 -142
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/cookie.rb +0 -91
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/memcache.rb +0 -109
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/session/pool.rb +0 -100
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showexceptions.rb +0 -349
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/showstatus.rb +0 -106
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/static.rb +0 -38
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/urlmap.rb +0 -55
- data/vendor/rails/actionpack/lib/action_controller/vendor/rack-1.0/rack/utils.rb +0 -392
@@ -143,6 +143,8 @@ module ActiveRecord
|
|
143
143
|
end
|
144
144
|
|
145
145
|
# Remove all records from this association
|
146
|
+
#
|
147
|
+
# See delete for more info.
|
146
148
|
def delete_all
|
147
149
|
load_target
|
148
150
|
delete(@target)
|
@@ -200,12 +202,13 @@ module ActiveRecord
|
|
200
202
|
end
|
201
203
|
end
|
202
204
|
|
203
|
-
# Destroy +records+ and remove from this association calling
|
204
|
-
# and +after_remove+ callbacks.
|
205
|
+
# Destroy +records+ and remove them from this association calling
|
206
|
+
# +before_remove+ and +after_remove+ callbacks.
|
205
207
|
#
|
206
|
-
# Note this method will
|
207
|
-
# +:dependent+ option.
|
208
|
+
# Note that this method will _always_ remove records from the database
|
209
|
+
# ignoring the +:dependent+ option.
|
208
210
|
def destroy(*records)
|
211
|
+
records = find(records) if records.any? {|record| record.kind_of?(Fixnum) || record.kind_of?(String)}
|
209
212
|
remove_records(records) do |records, old_records|
|
210
213
|
old_records.each { |record| record.destroy }
|
211
214
|
end
|
@@ -226,7 +229,9 @@ module ActiveRecord
|
|
226
229
|
self
|
227
230
|
end
|
228
231
|
|
229
|
-
# Destory all the records from this association
|
232
|
+
# Destory all the records from this association.
|
233
|
+
#
|
234
|
+
# See destroy for more info.
|
230
235
|
def destroy_all
|
231
236
|
load_target
|
232
237
|
destroy(@target)
|
@@ -169,8 +169,8 @@ module ActiveRecord
|
|
169
169
|
end
|
170
170
|
|
171
171
|
# Forwards the call to the reflection class.
|
172
|
-
def sanitize_sql(sql)
|
173
|
-
@reflection.klass.send(:sanitize_sql, sql)
|
172
|
+
def sanitize_sql(sql, table_name = @reflection.klass.quoted_table_name)
|
173
|
+
@reflection.klass.send(:sanitize_sql, sql, table_name)
|
174
174
|
end
|
175
175
|
|
176
176
|
# Assigns the ID of the owner to the corresponding foreign key in +record+.
|
@@ -14,7 +14,7 @@ module ActiveRecord
|
|
14
14
|
|
15
15
|
if record.nil?
|
16
16
|
if counter_cache_name && !@owner.new_record?
|
17
|
-
@reflection.klass.decrement_counter(counter_cache_name,
|
17
|
+
@reflection.klass.decrement_counter(counter_cache_name, previous_record_id) if @owner[@reflection.primary_key_name]
|
18
18
|
end
|
19
19
|
|
20
20
|
@target = @owner[@reflection.primary_key_name] = nil
|
@@ -27,7 +27,7 @@ module ActiveRecord
|
|
27
27
|
end
|
28
28
|
|
29
29
|
@target = (AssociationProxy === record ? record.target : record)
|
30
|
-
@owner[@reflection.primary_key_name] = record
|
30
|
+
@owner[@reflection.primary_key_name] = record_id(record) unless record.new_record?
|
31
31
|
@updated = true
|
32
32
|
end
|
33
33
|
|
@@ -41,18 +41,36 @@ module ActiveRecord
|
|
41
41
|
|
42
42
|
private
|
43
43
|
def find_target
|
44
|
-
@reflection.
|
44
|
+
find_method = if @reflection.options[:primary_key]
|
45
|
+
"find_by_#{@reflection.options[:primary_key]}"
|
46
|
+
else
|
47
|
+
"find"
|
48
|
+
end
|
49
|
+
@reflection.klass.send(find_method,
|
45
50
|
@owner[@reflection.primary_key_name],
|
46
51
|
:select => @reflection.options[:select],
|
47
52
|
:conditions => conditions,
|
48
53
|
:include => @reflection.options[:include],
|
49
54
|
:readonly => @reflection.options[:readonly]
|
50
|
-
)
|
55
|
+
) if @owner[@reflection.primary_key_name]
|
51
56
|
end
|
52
57
|
|
53
58
|
def foreign_key_present
|
54
59
|
!@owner[@reflection.primary_key_name].nil?
|
55
60
|
end
|
61
|
+
|
62
|
+
def record_id(record)
|
63
|
+
record.send(@reflection.options[:primary_key] || :id)
|
64
|
+
end
|
65
|
+
|
66
|
+
def previous_record_id
|
67
|
+
@previous_record_id ||= if @reflection.options[:primary_key]
|
68
|
+
previous_record = @owner.send(@reflection.name)
|
69
|
+
previous_record.nil? ? nil : previous_record.id
|
70
|
+
else
|
71
|
+
@owner[@reflection.primary_key_name]
|
72
|
+
end
|
73
|
+
end
|
56
74
|
end
|
57
75
|
end
|
58
76
|
end
|
data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
CHANGED
@@ -7,7 +7,7 @@ module ActiveRecord
|
|
7
7
|
else
|
8
8
|
@target = (AssociationProxy === record ? record.target : record)
|
9
9
|
|
10
|
-
@owner[@reflection.primary_key_name] = record
|
10
|
+
@owner[@reflection.primary_key_name] = record_id(record)
|
11
11
|
@owner[@reflection.options[:foreign_type]] = record.class.base_class.name.to_s
|
12
12
|
|
13
13
|
@updated = true
|
@@ -41,6 +41,10 @@ module ActiveRecord
|
|
41
41
|
!@owner[@reflection.primary_key_name].nil?
|
42
42
|
end
|
43
43
|
|
44
|
+
def record_id(record)
|
45
|
+
record.send(@reflection.options[:primary_key] || :id)
|
46
|
+
end
|
47
|
+
|
44
48
|
def association_class
|
45
49
|
@owner[@reflection.options[:foreign_type]] ? @owner[@reflection.options[:foreign_type]].constantize : nil
|
46
50
|
end
|
data/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module Associations
|
3
3
|
class HasAndBelongsToManyAssociation < AssociationCollection #:nodoc:
|
4
|
+
def initialize(owner, reflection)
|
5
|
+
super
|
6
|
+
@primary_key_list = {}
|
7
|
+
end
|
8
|
+
|
4
9
|
def create(attributes = {})
|
5
10
|
create_record(attributes) { |record| insert_record(record) }
|
6
11
|
end
|
@@ -17,6 +22,12 @@ module ActiveRecord
|
|
17
22
|
@reflection.reset_column_information
|
18
23
|
end
|
19
24
|
|
25
|
+
def has_primary_key?
|
26
|
+
return @has_primary_key unless @has_primary_key.nil?
|
27
|
+
@has_primary_key = (ActiveRecord::Base.connection.supports_primary_key? &&
|
28
|
+
ActiveRecord::Base.connection.primary_key(@reflection.options[:join_table]))
|
29
|
+
end
|
30
|
+
|
20
31
|
protected
|
21
32
|
def construct_find_options!(options)
|
22
33
|
options[:joins] = @join_sql
|
@@ -29,6 +40,11 @@ module ActiveRecord
|
|
29
40
|
end
|
30
41
|
|
31
42
|
def insert_record(record, force = true, validate = true)
|
43
|
+
if has_primary_key?
|
44
|
+
raise ActiveRecord::ConfigurationError,
|
45
|
+
"Primary key is not allowed in a has_and_belongs_to_many join table (#{@reflection.options[:join_table]})."
|
46
|
+
end
|
47
|
+
|
32
48
|
if record.new_record?
|
33
49
|
if force
|
34
50
|
record.save!
|
@@ -74,6 +74,7 @@ module ActiveRecord
|
|
74
74
|
"#{@reflection.primary_key_name} = NULL",
|
75
75
|
"#{@reflection.primary_key_name} = #{owner_quoted_id} AND #{@reflection.klass.primary_key} IN (#{ids})"
|
76
76
|
)
|
77
|
+
@owner.class.update_counters(@owner.id, cached_counter_attribute_name => -records.size) if has_cached_counter?
|
77
78
|
end
|
78
79
|
end
|
79
80
|
|
data/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb
CHANGED
@@ -17,7 +17,17 @@ module ActiveRecord
|
|
17
17
|
|
18
18
|
def create(attrs = nil)
|
19
19
|
transaction do
|
20
|
-
|
20
|
+
object = if attrs
|
21
|
+
@reflection.klass.send(:with_scope, :create => attrs) {
|
22
|
+
@reflection.create_association
|
23
|
+
}
|
24
|
+
else
|
25
|
+
@reflection.create_association
|
26
|
+
end
|
27
|
+
raise_on_type_mismatch(object)
|
28
|
+
add_record_to_target_with_callbacks(object) do |r|
|
29
|
+
insert_record(object, false)
|
30
|
+
end
|
21
31
|
object
|
22
32
|
end
|
23
33
|
end
|
@@ -44,7 +54,7 @@ module ActiveRecord
|
|
44
54
|
options[:select] = construct_select(options[:select])
|
45
55
|
options[:from] ||= construct_from
|
46
56
|
options[:joins] = construct_joins(options[:joins])
|
47
|
-
options[:include] = @reflection.source_reflection.options[:include] if options[:include].nil?
|
57
|
+
options[:include] = @reflection.source_reflection.options[:include] if options[:include].nil? && @reflection.source_reflection.options[:include]
|
48
58
|
end
|
49
59
|
|
50
60
|
def insert_record(record, force = true, validate = true)
|
@@ -96,7 +106,7 @@ module ActiveRecord
|
|
96
106
|
# Construct attributes for :through pointing to owner and associate.
|
97
107
|
def construct_join_attributes(associate)
|
98
108
|
# TODO: revist this to allow it for deletion, supposing dependent option is supported
|
99
|
-
raise ActiveRecord::
|
109
|
+
raise ActiveRecord::HasManyThroughCantAssociateThroughHasOneOrManyReflection.new(@owner, @reflection) if [:has_one, :has_many].include?(@reflection.source_reflection.macro)
|
100
110
|
join_attributes = construct_owner_attributes(@reflection.through_reflection).merge(@reflection.source_reflection.primary_key_name => associate.id)
|
101
111
|
if @reflection.options[:source_type]
|
102
112
|
join_attributes.merge!(@reflection.source_reflection.options[:foreign_type] => associate.class.base_class.name.to_s)
|
data/vendor/rails/activerecord/lib/active_record/associations/has_one_through_association.rb
CHANGED
@@ -1,31 +1,37 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module Associations
|
3
3
|
class HasOneThroughAssociation < HasManyThroughAssociation
|
4
|
-
|
4
|
+
|
5
5
|
def create_through_record(new_value) #nodoc:
|
6
6
|
klass = @reflection.through_reflection.klass
|
7
7
|
|
8
8
|
current_object = @owner.send(@reflection.through_reflection.name)
|
9
|
-
|
9
|
+
|
10
10
|
if current_object
|
11
|
-
current_object.update_attributes(construct_join_attributes(new_value))
|
12
|
-
|
13
|
-
@owner.
|
11
|
+
new_value ? current_object.update_attributes(construct_join_attributes(new_value)) : current_object.destroy
|
12
|
+
elsif new_value
|
13
|
+
if @owner.new_record?
|
14
|
+
self.target = new_value
|
15
|
+
through_association = @owner.send(:association_instance_get, @reflection.through_reflection.name)
|
16
|
+
through_association.build(construct_join_attributes(new_value))
|
17
|
+
else
|
18
|
+
@owner.send(@reflection.through_reflection.name, klass.create(construct_join_attributes(new_value)))
|
19
|
+
end
|
14
20
|
end
|
15
21
|
end
|
16
|
-
|
22
|
+
|
17
23
|
private
|
18
24
|
def find(*args)
|
19
25
|
super(args.merge(:limit => 1))
|
20
26
|
end
|
21
|
-
|
27
|
+
|
22
28
|
def find_target
|
23
29
|
super.first
|
24
30
|
end
|
25
31
|
|
26
32
|
def reset_target!
|
27
33
|
@target = nil
|
28
|
-
end
|
29
|
-
end
|
34
|
+
end
|
35
|
+
end
|
30
36
|
end
|
31
37
|
end
|
@@ -249,9 +249,10 @@ module ActiveRecord
|
|
249
249
|
unless valid = association.valid?
|
250
250
|
if reflection.options[:autosave]
|
251
251
|
unless association.marked_for_destruction?
|
252
|
-
association.errors.
|
253
|
-
|
254
|
-
|
252
|
+
association.errors.each_error do |attribute, error|
|
253
|
+
error = error.dup
|
254
|
+
error.attribute = "#{reflection.name}_#{attribute}"
|
255
|
+
errors.add(error) unless errors.on(error.attribute)
|
255
256
|
end
|
256
257
|
end
|
257
258
|
else
|
@@ -311,11 +312,13 @@ module ActiveRecord
|
|
311
312
|
# ActiveRecord::Base after the AutosaveAssociation module, which it does by default.
|
312
313
|
def save_has_one_association(reflection)
|
313
314
|
if (association = association_instance_get(reflection.name)) && !association.target.nil?
|
314
|
-
|
315
|
+
autosave = reflection.options[:autosave]
|
316
|
+
|
317
|
+
if autosave && association.marked_for_destruction?
|
315
318
|
association.destroy
|
316
|
-
elsif new_record? || association.new_record? || association[reflection.primary_key_name] != id ||
|
319
|
+
elsif new_record? || association.new_record? || association[reflection.primary_key_name] != id || autosave
|
317
320
|
association[reflection.primary_key_name] = id
|
318
|
-
association.save(
|
321
|
+
association.save(!autosave)
|
319
322
|
end
|
320
323
|
end
|
321
324
|
end
|
@@ -330,13 +333,16 @@ module ActiveRecord
|
|
330
333
|
# ActiveRecord::Base after the AutosaveAssociation module, which it does by default.
|
331
334
|
def save_belongs_to_association(reflection)
|
332
335
|
if association = association_instance_get(reflection.name)
|
333
|
-
|
336
|
+
autosave = reflection.options[:autosave]
|
337
|
+
|
338
|
+
if autosave && association.marked_for_destruction?
|
334
339
|
association.destroy
|
335
340
|
else
|
336
|
-
association.save(
|
341
|
+
association.save(!autosave) if association.new_record? || autosave
|
337
342
|
|
338
343
|
if association.updated?
|
339
|
-
|
344
|
+
association_id = association.send(reflection.options[:primary_key] || :id)
|
345
|
+
self[reflection.primary_key_name] = association_id
|
340
346
|
# TODO: Removing this code doesn't seem to matter…
|
341
347
|
if reflection.options[:polymorphic]
|
342
348
|
self[reflection.options[:foreign_type]] = association.class.base_class.name.to_s
|
@@ -687,14 +687,9 @@ module ActiveRecord #:nodoc:
|
|
687
687
|
# Person.exists?(['name LIKE ?', "%#{query}%"])
|
688
688
|
# Person.exists?
|
689
689
|
def exists?(id_or_conditions = {})
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
:conditions => expand_id_conditions(id_or_conditions),
|
694
|
-
:limit => 1
|
695
|
-
),
|
696
|
-
"#{name} Exists"
|
697
|
-
).size > 0
|
690
|
+
find_initial(
|
691
|
+
:select => "#{quoted_table_name}.#{primary_key}",
|
692
|
+
:conditions => expand_id_conditions(id_or_conditions)) ? true : false
|
698
693
|
end
|
699
694
|
|
700
695
|
# Creates an object (or multiple objects) and saves it to the database, if validations pass.
|
@@ -736,12 +731,12 @@ module ActiveRecord #:nodoc:
|
|
736
731
|
# ==== Parameters
|
737
732
|
#
|
738
733
|
# * +id+ - This should be the id or an array of ids to be updated.
|
739
|
-
# * +attributes+ - This should be a
|
734
|
+
# * +attributes+ - This should be a hash of attributes to be set on the object, or an array of hashes.
|
740
735
|
#
|
741
736
|
# ==== Examples
|
742
737
|
#
|
743
738
|
# # Updating one record:
|
744
|
-
# Person.update(15,
|
739
|
+
# Person.update(15, :user_name => 'Samuel', :group => 'expert')
|
745
740
|
#
|
746
741
|
# # Updating multiple records:
|
747
742
|
# people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy" } }
|
@@ -1369,7 +1364,7 @@ module ActiveRecord #:nodoc:
|
|
1369
1364
|
end
|
1370
1365
|
defaults << options[:default] if options[:default]
|
1371
1366
|
defaults.flatten!
|
1372
|
-
defaults << attribute_key_name.humanize
|
1367
|
+
defaults << attribute_key_name.to_s.humanize
|
1373
1368
|
options[:count] ||= 1
|
1374
1369
|
I18n.translate(defaults.shift, options.merge(:default => defaults, :scope => [:activerecord, :attributes]))
|
1375
1370
|
end
|
@@ -2168,7 +2163,7 @@ module ActiveRecord #:nodoc:
|
|
2168
2163
|
# default_scope :order => 'last_name, first_name'
|
2169
2164
|
# end
|
2170
2165
|
def default_scope(options = {})
|
2171
|
-
self.default_scoping << { :find => options, :create =>
|
2166
|
+
self.default_scoping << { :find => options, :create => options[:conditions].is_a?(Hash) ? options[:conditions] : {} }
|
2172
2167
|
end
|
2173
2168
|
|
2174
2169
|
# Test whether the given method and optional key are scoped.
|
@@ -2228,12 +2223,12 @@ module ActiveRecord #:nodoc:
|
|
2228
2223
|
# ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'"
|
2229
2224
|
# { :name => "foo'bar", :group_id => 4 } returns "name='foo''bar' and group_id='4'"
|
2230
2225
|
# "name='foo''bar' and group_id='4'" returns "name='foo''bar' and group_id='4'"
|
2231
|
-
def sanitize_sql_for_conditions(condition)
|
2226
|
+
def sanitize_sql_for_conditions(condition, table_name = quoted_table_name)
|
2232
2227
|
return nil if condition.blank?
|
2233
2228
|
|
2234
2229
|
case condition
|
2235
2230
|
when Array; sanitize_sql_array(condition)
|
2236
|
-
when Hash; sanitize_sql_hash_for_conditions(condition)
|
2231
|
+
when Hash; sanitize_sql_hash_for_conditions(condition, table_name)
|
2237
2232
|
else condition
|
2238
2233
|
end
|
2239
2234
|
end
|
@@ -2299,20 +2294,24 @@ module ActiveRecord #:nodoc:
|
|
2299
2294
|
# And for value objects on a composed_of relationship:
|
2300
2295
|
# { :address => Address.new("123 abc st.", "chicago") }
|
2301
2296
|
# # => "address_street='123 abc st.' and address_city='chicago'"
|
2302
|
-
def sanitize_sql_hash_for_conditions(attrs,
|
2297
|
+
def sanitize_sql_hash_for_conditions(attrs, default_table_name = quoted_table_name)
|
2303
2298
|
attrs = expand_hash_conditions_for_aggregates(attrs)
|
2304
2299
|
|
2305
2300
|
conditions = attrs.map do |attr, value|
|
2301
|
+
table_name = default_table_name
|
2302
|
+
|
2306
2303
|
unless value.is_a?(Hash)
|
2307
2304
|
attr = attr.to_s
|
2308
2305
|
|
2309
2306
|
# Extract table name from qualified attribute names.
|
2310
2307
|
if attr.include?('.')
|
2311
|
-
|
2312
|
-
|
2308
|
+
attr_table_name, attr = attr.split('.', 2)
|
2309
|
+
attr_table_name = connection.quote_table_name(attr_table_name)
|
2310
|
+
else
|
2311
|
+
attr_table_name = table_name
|
2313
2312
|
end
|
2314
2313
|
|
2315
|
-
attribute_condition("#{
|
2314
|
+
attribute_condition("#{attr_table_name}.#{connection.quote_column_name(attr)}", value)
|
2316
2315
|
else
|
2317
2316
|
sanitize_sql_hash_for_conditions(value, connection.quote_table_name(attr.to_s))
|
2318
2317
|
end
|
@@ -3033,16 +3032,22 @@ module ActiveRecord #:nodoc:
|
|
3033
3032
|
|
3034
3033
|
def execute_callstack_for_multiparameter_attributes(callstack)
|
3035
3034
|
errors = []
|
3036
|
-
callstack.each do |name,
|
3037
|
-
|
3038
|
-
|
3039
|
-
|
3040
|
-
|
3041
|
-
|
3035
|
+
callstack.each do |name, values_with_empty_parameters|
|
3036
|
+
begin
|
3037
|
+
klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass
|
3038
|
+
# in order to allow a date to be set without a year, we must keep the empty values.
|
3039
|
+
# Otherwise, we wouldn't be able to distinguish it from a date with an empty day.
|
3040
|
+
values = values_with_empty_parameters.reject(&:nil?)
|
3041
|
+
|
3042
|
+
if values.empty?
|
3043
|
+
send(name + "=", nil)
|
3044
|
+
else
|
3045
|
+
|
3042
3046
|
value = if Time == klass
|
3043
3047
|
instantiate_time_object(name, values)
|
3044
3048
|
elsif Date == klass
|
3045
3049
|
begin
|
3050
|
+
values = values_with_empty_parameters.collect do |v| v.nil? ? 1 : v end
|
3046
3051
|
Date.new(*values)
|
3047
3052
|
rescue ArgumentError => ex # if Date.new raises an exception on an invalid date
|
3048
3053
|
instantiate_time_object(name, values).to_date # we instantiate Time object and convert it back to a date thus using Time's logic in handling invalid dates
|
@@ -3052,9 +3057,9 @@ module ActiveRecord #:nodoc:
|
|
3052
3057
|
end
|
3053
3058
|
|
3054
3059
|
send(name + "=", value)
|
3055
|
-
rescue => ex
|
3056
|
-
errors << AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name)
|
3057
3060
|
end
|
3061
|
+
rescue => ex
|
3062
|
+
errors << AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name)
|
3058
3063
|
end
|
3059
3064
|
end
|
3060
3065
|
unless errors.empty?
|
@@ -3070,17 +3075,15 @@ module ActiveRecord #:nodoc:
|
|
3070
3075
|
attribute_name = multiparameter_name.split("(").first
|
3071
3076
|
attributes[attribute_name] = [] unless attributes.include?(attribute_name)
|
3072
3077
|
|
3073
|
-
|
3074
|
-
|
3075
|
-
[ find_parameter_position(multiparameter_name), type_cast_attribute_value(multiparameter_name, value) ]
|
3076
|
-
end
|
3078
|
+
parameter_value = value.empty? ? nil : type_cast_attribute_value(multiparameter_name, value)
|
3079
|
+
attributes[attribute_name] << [ find_parameter_position(multiparameter_name), parameter_value ]
|
3077
3080
|
end
|
3078
3081
|
|
3079
3082
|
attributes.each { |name, values| attributes[name] = values.sort_by{ |v| v.first }.collect { |v| v.last } }
|
3080
3083
|
end
|
3081
3084
|
|
3082
3085
|
def type_cast_attribute_value(multiparameter_name, value)
|
3083
|
-
multiparameter_name =~ /\([0-9]*([
|
3086
|
+
multiparameter_name =~ /\([0-9]*([if])\)/ ? value.send("to_" + $1) : value
|
3084
3087
|
end
|
3085
3088
|
|
3086
3089
|
def find_parameter_position(multiparameter_name)
|