spree 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree might be problematic. Click here for more details.
- data/CHANGELOG +47 -0
- data/CONTRIBUTORS +27 -0
- data/INSTALL +27 -0
- data/{starter-app/vendor/plugins/spree/LICENSE → LICENSE} +0 -0
- data/{README.txt → README} +0 -0
- data/Rakefile +11 -4
- data/{starter-app/vendor/plugins/spree/app → app}/controllers/account_controller.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/controllers/admin/base_controller.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/controllers/admin/categories_controller.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/controllers/admin/images_controller.rb +0 -0
- data/app/controllers/admin/inventory_units_controller.rb +27 -0
- data/{starter-app/vendor/plugins/spree/app → app}/controllers/admin/option_types_controller.rb +0 -0
- data/app/controllers/admin/orders_controller.rb +272 -0
- data/{starter-app/vendor/plugins/spree/app → app}/controllers/admin/overview_controller.rb +0 -0
- data/app/controllers/admin/products_controller.rb +169 -0
- data/{starter-app/vendor/plugins/spree/app → app}/controllers/admin/reports_controller.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/controllers/admin/users_controller.rb +0 -0
- data/app/controllers/application.rb +24 -0
- data/app/controllers/cart_controller.rb +44 -0
- data/app/controllers/checkout_controller.rb +180 -0
- data/app/controllers/spree/base_controller.rb +47 -0
- data/{starter-app/vendor/plugins/spree/app → app}/controllers/store_controller.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/account_helper.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/admin/base_helper.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/admin/categories_helper.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/admin/option_values_helper.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/admin/orders_helper.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/admin/overview_helper.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/admin/products_helper.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/admin/users_helper.rb +0 -0
- data/app/helpers/application_helper.rb +9 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/cart_helper.rb +0 -0
- data/app/helpers/checkout_helper.rb +14 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/search_helper.rb +0 -0
- data/app/helpers/spree/base_helper.rb +105 -0
- data/{starter-app/vendor/plugins/spree/app → app}/helpers/store_helper.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/address.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/cart.rb +0 -0
- data/app/models/cart_item.rb +29 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/category.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/country.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/credit_card.rb +0 -0
- data/app/models/image.rb +13 -0
- data/app/models/inventory_level.rb +19 -0
- data/app/models/inventory_unit.rb +49 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/line_item.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/option_type.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/option_value.rb +0 -0
- data/app/models/order.rb +88 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/order_mailer.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/order_operation.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/payment.rb +0 -0
- data/app/models/product.rb +64 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/product_option_type.rb +0 -0
- data/{starter-app/app → app}/models/role.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/search_criteria.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/state.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/tax_treatment.rb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/models/txn.rb +0 -0
- data/{starter-app/app → app}/models/user.rb +0 -0
- data/app/models/variant.rb +11 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/account/index.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/account/login.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/account/signup.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/categories/_form.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/categories/edit.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/categories/list.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/categories/new.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/images/new.html.erb +0 -0
- data/app/views/admin/inventory_units/adjust.html.erb +32 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/option_types/_form.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/option_types/_new_option_value.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/option_types/_option_values.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/option_types/edit.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/option_types/index.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/option_types/new.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/option_types/select.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/orders/_address.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/orders/index.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/orders/show.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/overview/index.rhtml +0 -0
- data/app/views/admin/products/_form.rhtml +70 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/products/_menu.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/products/_new_variant.rhtml +0 -0
- data/app/views/admin/products/_option_types.rhtml +42 -0
- data/app/views/admin/products/_variants.rhtml +50 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/products/edit.rhtml +0 -0
- data/app/views/admin/products/index.rhtml +62 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/products/new.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/reports/index.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/reports/sales_total.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/users/_form.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/users/_menu.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/users/edit.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/users/index.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/users/new.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/admin/users/show.rhtml +0 -0
- data/app/views/cart/index.rhtml +49 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/checkout/_address.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/checkout/_address_ro.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/checkout/_cart_item.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/checkout/_extra.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/checkout/addresses.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/checkout/cvv.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/checkout/empty_cart.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/checkout/final_confirmation.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/checkout/incomplete.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/checkout/thank_you.rhtml +0 -0
- data/app/views/layouts/admin.rhtml +70 -0
- data/app/views/layouts/application.rhtml +50 -0
- data/app/views/layouts/products.rhtml +19 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/layouts/simple.rhtml +0 -0
- data/app/views/order_mailer/cancel.rhtml +15 -0
- data/app/views/order_mailer/confirm.rhtml +18 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/shared/_images.html.erb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/shared/_order_details.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/shared/_paginate.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/shared/_report_criteria.rhtml +0 -0
- data/{starter-app/app → app}/views/shared/_store_menu.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/shared/_tax_treatments.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/store/_image.html.erb +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/store/_products.rhtml +0 -0
- data/{starter-app/vendor/plugins/spree/app → app}/views/store/_thumbnails.html.erb +0 -0
- data/app/views/store/list.rhtml +14 -0
- data/app/views/store/show.rhtml +60 -0
- data/bin/spree +35 -144
- data/config/boot.rb +148 -0
- data/{starter-app/config → config}/database.yml +0 -0
- data/config/environment.rb +143 -0
- data/config/environments/development.rb +24 -0
- data/{starter-app/config → config}/environments/production.rb +0 -0
- data/{starter-app/config → config}/environments/test.rb +0 -0
- data/config/routes.rb +31 -0
- data/db/development_structure.sql +267 -0
- data/{starter-app/vendor/plugins/spree/db → db}/migrate/001_create_addresses.rb +0 -0
- data/{starter-app/vendor/plugins/spree/db → db}/migrate/002_create_cart_items.rb +0 -0
- data/{starter-app/vendor/plugins/spree/db → db}/migrate/003_create_carts.rb +0 -0
- data/{starter-app/vendor/plugins/spree/db → db}/migrate/004_create_categories.rb +0 -0
- data/{starter-app/vendor/plugins/spree/db → db}/migrate/005_create_categories_products.rb +0 -0
- data/{starter-app/vendor/plugins/spree/db → db}/migrate/006_create_line_items.rb +0 -0
- data/{starter-app/vendor/plugins/spree/db → db}/migrate/007_create_option_values.rb +0 -0
- data/db/migrate/008_create_orders.rb +23 -0
- data/db/migrate/009_create_products.rb +16 -0
- data/{starter-app/vendor/plugins/spree/db → db}/migrate/010_create_txns.rb +0 -0
- data/db/migrate/011_create_variants.rb +12 -0
- data/{starter-app/vendor/plugins/spree/db → db}/migrate/012_create_tax_treatments.rb +0 -0
- data/{starter-app/vendor/plugins/spree/db/migrate/014_create_countries.rb → db/migrate/013_create_countries.rb} +0 -0
- data/{starter-app/vendor/plugins/spree/db/migrate/015_create_states.rb → db/migrate/014_create_states.rb} +0 -0
- data/{starter-app/vendor/plugins/spree/db/migrate/016_create_option_types.rb → db/migrate/015_create_option_types.rb} +0 -0
- data/{starter-app/vendor/plugins/spree/db/migrate/017_create_product_option_types.rb → db/migrate/016_create_product_option_types.rb} +0 -0
- data/{starter-app/vendor/plugins/spree/db/migrate/018_create_option_values_variants.rb → db/migrate/017_create_option_values_variants.rb} +0 -0
- data/db/migrate/018_create_images.rb +20 -0
- data/{starter-app/vendor/plugins/spree/db/migrate/020_create_credit_cards.rb → db/migrate/019_create_credit_cards.rb} +0 -0
- data/{starter-app/vendor/plugins/spree/db/migrate/021_create_order_operations.rb → db/migrate/020_create_order_operations.rb} +0 -0
- data/db/migrate/021_create_inventory_units.rb +15 -0
- data/{starter-app/db/migrate/001_create_users.rb → db/migrate/022_create_users.rb} +0 -0
- data/{starter-app/db/migrate/002_create_roles.rb → db/migrate/023_create_roles.rb} +0 -0
- data/{starter-app/db → db}/sample/addresses.yml +0 -0
- data/{starter-app/db → db}/sample/categories.yml +0 -0
- data/{starter-app/db → db}/sample/countries.yml +0 -0
- data/db/sample/credit_cards.yml +12 -0
- data/db/sample/images.yml +300 -0
- data/{starter-app/vendor/plugins/spree/assets/images/products → db/sample/images}/ror_bag.jpg +0 -0
- data/{starter-app/vendor/plugins/spree/assets/images/products → db/sample/images}/ror_baseball_jersey.jpg +0 -0
- data/{starter-app/vendor/plugins/spree/assets/images/products → db/sample/images}/ror_jr_spaghetti.jpg +0 -0
- data/{starter-app/vendor/plugins/spree/assets/images/products → db/sample/images}/ror_mug.jpg +0 -0
- data/{starter-app/vendor/plugins/spree/assets/images/products → db/sample/images}/ror_ringer_tshirt.jpg +0 -0
- data/{starter-app/vendor/plugins/spree/assets/images/products → db/sample/images}/ror_stein.jpg +0 -0
- data/{starter-app/vendor/plugins/spree/assets/images/products → db/sample/images}/ror_tote.jpg +0 -0
- data/db/sample/inventory_units.yml +98 -0
- data/db/sample/line_items.yml +25 -0
- data/{starter-app/db → db}/sample/option_types.yml +0 -0
- data/{starter-app/db → db}/sample/option_values.yml +0 -0
- data/db/sample/orders.yml +15 -0
- data/{starter-app/db → db}/sample/product_option_types.yml +0 -0
- data/{starter-app/db → db}/sample/products.yml +0 -0
- data/{starter-app/db → db}/sample/roles.yml +0 -0
- data/{starter-app/db → db}/sample/states.yml +0 -0
- data/{starter-app/db → db}/sample/txns.yml +0 -0
- data/{starter-app/db → db}/sample/users.yml +0 -0
- data/db/sample/variants.yml +61 -0
- data/{starter-app/lib → lib}/authenticated_system.rb +0 -0
- data/{starter-app/lib → lib}/authenticated_test_helper.rb +0 -0
- data/{starter-app/lib → lib}/custom_fixtures.rb +0 -0
- data/{starter-app/vendor/plugins/spree/lib/shipping → lib}/flat_rate.rb +0 -0
- data/{starter-app/vendor/plugins/spree/lib → lib}/format.rb +0 -0
- data/lib/generators/instance/instance_generator.rb +129 -0
- data/lib/generators/instance/templates/databases/mysql.yml +47 -0
- data/lib/generators/instance/templates/databases/postgresql.yml +44 -0
- data/lib/generators/instance/templates/databases/sqlite3.yml +16 -0
- data/lib/generators/instance/templates/databases/sqlserver.yml +20 -0
- data/lib/generators/instance/templates/demo_mongrel_cluster.yml +7 -0
- data/lib/generators/instance/templates/demo_robots.txt +2 -0
- data/lib/generators/instance/templates/instance_boot.rb +148 -0
- data/lib/generators/instance/templates/instance_environment.rb +136 -0
- data/lib/generators/instance/templates/instance_generate +16 -0
- data/lib/generators/instance/templates/instance_rakefile +3 -0
- data/lib/generators/instance/templates/instance_routes.rb +1 -0
- data/{starter-app/lib → lib}/hijacker.rb +0 -0
- data/lib/plugins/extension_patches/init.rb +7 -0
- data/lib/plugins/extension_patches/lib/fixture_loading_extension.rb +80 -0
- data/lib/plugins/extension_patches/lib/mailer_hack.rb +8 -0
- data/lib/plugins/extension_patches/lib/routing_extension.rb +37 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/CHANGELOG +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/README +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/init.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/lib/paginating_find.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/lib/paging_enumerator.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/lib/paging_helper.rb +0 -0
- data/{starter-app → lib/plugins/paginating_find/test_app}/Rakefile +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/app/controllers/application.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/config/boot.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/config/database.yml +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/config/environment.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/config/environments/test.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/config/routes.rb +0 -0
- data/{starter-app → lib/plugins/paginating_find/test_app}/script/breakpointer +0 -0
- data/{starter-app → lib/plugins/paginating_find/test_app}/script/console +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/test/fixtures/articles.yml +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/test/fixtures/authors.yml +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/test/fixtures/edits.yml +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/test/fixtures/models.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/test/test_helper.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/test/unit/abstract_test.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/test/unit/group_test.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/test/unit/paginating_find_test.rb +0 -0
- data/{starter-app/vendor → lib}/plugins/paginating_find/test_app/test/unit/paging_enumerator_test.rb +0 -0
- data/{starter-app/lib → lib}/role_requirement_system.rb +0 -0
- data/{starter-app/lib → lib}/role_requirement_test_helper.rb +0 -0
- data/lib/sales_tax.rb +26 -0
- data/lib/spree.rb +22 -0
- data/{starter-app/vendor/plugins/spree/lib/gateway → lib/spree}/bogus_gateway.rb +0 -0
- data/lib/spree/initializer.rb +154 -0
- data/lib/spree/setup.rb +146 -0
- data/lib/tasks/database.rake +35 -0
- data/lib/tasks/environments.rake +11 -0
- data/lib/tasks/instance.rake +26 -0
- data/lib/tasks/release.rake +98 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0001/ror_tote.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0001/ror_tote_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0001/ror_tote_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0001/ror_tote_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0002/ror_tote_back.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0002/ror_tote_back_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0002/ror_tote_back_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0002/ror_tote_back_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0003/ror_bag.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0003/ror_bag_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0003/ror_bag_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0003/ror_bag_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0004/ror_baseball.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0004/ror_baseball_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0004/ror_baseball_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0004/ror_baseball_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0005/ror_baseball_back.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0005/ror_baseball_back_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0005/ror_baseball_back_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0005/ror_baseball_back_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0006/ror_jr_spaghetti.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0006/ror_jr_spaghetti_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0006/ror_jr_spaghetti_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0006/ror_jr_spaghetti_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0007/ror_mug.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0007/ror_mug_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0007/ror_mug_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0007/ror_mug_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0008/ror_mug_back.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0008/ror_mug_back_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0008/ror_mug_back_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0008/ror_mug_back_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0009/ror_ringer.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0009/ror_ringer_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0009/ror_ringer_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0009/ror_ringer_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0010/ror_ringer_back.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0010/ror_ringer_back_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0010/ror_ringer_back_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0010/ror_ringer_back_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0011/ror_stein.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0011/ror_stein_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0011/ror_stein_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0011/ror_stein_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0012/ror_stein_back.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0012/ror_stein_back_mini.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0012/ror_stein_back_product.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/sample/products/0000/0012/ror_stein_back_small.jpeg +0 -0
- data/{starter-app/lib → lib}/tasks/spree_sample_data.rake +0 -0
- data/{starter-app/log → log}/README +0 -0
- data/{starter-app/public → public}/.htaccess +0 -0
- data/{starter-app/public → public}/404.html +0 -0
- data/{starter-app/public → public}/500.html +0 -0
- data/{starter-app/public → public}/dispatch.cgi +0 -0
- data/{starter-app/public → public}/dispatch.fcgi +0 -0
- data/{starter-app/public → public}/dispatch.rb +0 -0
- data/{starter-app/public → public}/favicon.ico +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public}/images/amex_cid.gif +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public}/images/calendar_date_select/calendar.gif +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public}/images/creditcard.gif +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public}/images/discover_cid.gif +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public}/images/master_cid.jpg +0 -0
- data/{starter-app/public → public}/images/rails.png +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public}/images/spinner.gif +0 -0
- data/{starter-app/public → public}/images/spree.jpg +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public}/images/spree/progress.gif +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public}/images/spree/spinner.gif +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public}/images/spree/spree.jpg +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public}/images/visa_cid.gif +0 -0
- data/{starter-app/public → public}/javascripts/application.js +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public}/javascripts/calendar_date_select/calendar_date_select.js +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public}/javascripts/calendar_date_select/format_american.js +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public}/javascripts/calendar_date_select/format_euro_24hr.js +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public}/javascripts/calendar_date_select/format_finnish.js +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public}/javascripts/calendar_date_select/format_hyphen_ampm.js +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public}/javascripts/calendar_date_select/format_italian.js +0 -0
- data/{starter-app/public → public}/javascripts/controls.js +0 -0
- data/{starter-app/public → public}/javascripts/dragdrop.js +0 -0
- data/{starter-app/public → public}/javascripts/effects.js +0 -0
- data/{starter-app/public → public}/javascripts/prototype.js +0 -0
- data/public/plugin_assets/README +5 -0
- data/public/plugin_assets/calendar_date_select/images/calendar_date_select/calendar.gif +0 -0
- data/public/plugin_assets/calendar_date_select/javascripts/calendar_date_select/calendar_date_select.js +439 -0
- data/public/plugin_assets/calendar_date_select/javascripts/calendar_date_select/format_american.js +34 -0
- data/public/plugin_assets/calendar_date_select/javascripts/calendar_date_select/format_euro_24hr.js +7 -0
- data/public/plugin_assets/calendar_date_select/javascripts/calendar_date_select/format_finnish.js +24 -0
- data/public/plugin_assets/calendar_date_select/javascripts/calendar_date_select/format_hyphen_ampm.js +36 -0
- data/public/plugin_assets/calendar_date_select/javascripts/calendar_date_select/format_italian.js +24 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public/plugin_assets/calendar_date_select}/javascripts/calendar_date_select/locale/fi.js +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public/plugin_assets/calendar_date_select}/stylesheets/calendar_date_select/blue.css +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public/plugin_assets/calendar_date_select}/stylesheets/calendar_date_select/default.css +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public/plugin_assets/calendar_date_select}/stylesheets/calendar_date_select/plain.css +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public/plugin_assets/calendar_date_select}/stylesheets/calendar_date_select/red.css +0 -0
- data/{starter-app/vendor/plugins/calendar_date_select/public → public/plugin_assets/calendar_date_select}/stylesheets/calendar_date_select/silver.css +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/404.html +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/500.html +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/dispatch.cgi +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/dispatch.fcgi +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/dispatch.rb +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/favicon.ico +0 -0
- data/public/plugin_assets/spree/images/amex_cid.gif +0 -0
- data/public/plugin_assets/spree/images/creditcard.gif +0 -0
- data/public/plugin_assets/spree/images/discover_cid.gif +0 -0
- data/public/plugin_assets/spree/images/master_cid.jpg +0 -0
- data/public/plugin_assets/spree/images/products/ror_bag.jpg +0 -0
- data/public/plugin_assets/spree/images/products/ror_baseball_jersey.jpg +0 -0
- data/public/plugin_assets/spree/images/products/ror_jr_spaghetti.jpg +0 -0
- data/public/plugin_assets/spree/images/products/ror_mug.jpg +0 -0
- data/public/plugin_assets/spree/images/products/ror_ringer_tshirt.jpg +0 -0
- data/public/plugin_assets/spree/images/products/ror_stein.jpg +0 -0
- data/public/plugin_assets/spree/images/products/ror_tote.jpg +0 -0
- data/{starter-app/vendor/plugins/attachment_fu/test/fixtures/files → public/plugin_assets/spree/images}/rails.png +0 -0
- data/public/plugin_assets/spree/images/spinner.gif +0 -0
- data/public/plugin_assets/spree/images/spree/progress.gif +0 -0
- data/public/plugin_assets/spree/images/spree/spinner.gif +0 -0
- data/public/plugin_assets/spree/images/spree/spree.jpg +0 -0
- data/public/plugin_assets/spree/images/spree/spree_logo142x65.gif +0 -0
- data/public/plugin_assets/spree/images/spree/spree_logo245x112.gif +0 -0
- data/public/plugin_assets/spree/images/visa_cid.gif +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/javascripts/application.js +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/javascripts/controls.js +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/javascripts/dragdrop.js +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/javascripts/effects.js +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/javascripts/lowpro.js +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/javascripts/prototype.js +0 -0
- data/{starter-app/public → public/plugin_assets/spree}/robots.txt +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/stylesheets/cart/_controller.css +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/stylesheets/checkout/_controller.css +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/stylesheets/fullscreen.css +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/stylesheets/orders/_controller.css +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/stylesheets/products/_controller.css +0 -0
- data/public/plugin_assets/spree/stylesheets/spree-admin.css +355 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/stylesheets/spree.css +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public/plugin_assets/spree}/stylesheets/store/_controller.css +0 -0
- data/{starter-app/vendor/plugins/spree/assets → public}/robots.txt +0 -0
- data/{starter-app/public → public}/stylesheets/application.css +0 -0
- data/public/stylesheets/calendar_date_select/blue.css +130 -0
- data/public/stylesheets/calendar_date_select/default.css +135 -0
- data/public/stylesheets/calendar_date_select/plain.css +128 -0
- data/public/stylesheets/calendar_date_select/red.css +135 -0
- data/public/stylesheets/calendar_date_select/silver.css +133 -0
- data/public/stylesheets/cart/_controller.css +71 -0
- data/{starter-app/public/stylesheets/checkout/_controller.css → public/stylesheets/checkout/_controller-override.css} +0 -0
- data/public/stylesheets/checkout/_controller.css +31 -0
- data/public/stylesheets/fullscreen.css +63 -0
- data/public/stylesheets/orders/_controller.css +3 -0
- data/public/stylesheets/products/_controller.css +38 -0
- data/public/stylesheets/spree-admin.css +355 -0
- data/public/stylesheets/spree.css +66 -0
- data/public/stylesheets/store/_controller.css +23 -0
- data/{starter-app/script → script}/about +0 -0
- data/{starter-app/vendor/plugins/paginating_find/test_app/script → script}/breakpointer +0 -0
- data/{starter-app/vendor/plugins/paginating_find/test_app/script → script}/console +0 -0
- data/script/destroy +2 -13
- data/script/generate +2 -13
- data/{starter-app/script → script}/performance/benchmarker +0 -0
- data/{starter-app/script → script}/performance/profiler +0 -0
- data/{starter-app/script → script}/plugin +0 -0
- data/{starter-app/script → script}/process/inspector +0 -0
- data/{starter-app/script → script}/process/reaper +0 -0
- data/{starter-app/script → script}/process/spawner +0 -0
- data/{starter-app/script → script}/runner +0 -0
- data/{starter-app/script → script}/server +0 -0
- data/{starter-app/script → script}/spec +0 -0
- data/{starter-app/script → script}/spec_server +0 -0
- data/spec/helpers/spree/base_helper_spec.rb +6 -0
- data/{starter-app/spec → spec}/models/cart_item_spec.rb +0 -0
- data/{starter-app/spec → spec}/models/cart_spec.rb +0 -0
- data/spec/models/inventory_unit_spec.rb +18 -0
- data/{starter-app/spec → spec}/models/line_item_spec.rb +0 -0
- data/spec/models/product_spec.rb +48 -0
- data/{starter-app/spec → spec}/rcov.opts +0 -0
- data/{starter-app/spec → spec}/spec.opts +0 -0
- data/{starter-app/spec → spec}/spec_helper.rb +0 -0
- data/spree.tmproj +444 -0
- data/{starter-app/stories → stories}/all.rb +0 -0
- data/{starter-app/stories → stories}/helper.rb +0 -0
- data/vendor/extensions/bogus_gateway/LICENSE +26 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_list/README +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_list/init.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_list/lib/active_record/acts/list.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_list/test/list_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_tree/README +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_tree/Rakefile +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_tree/init.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_tree/lib/active_record/acts/tree.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_tree/test/abstract_unit.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_tree/test/acts_as_tree_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_tree/test/database.yml +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
- data/{starter-app/vendor → vendor}/plugins/acts_as_tree/test/schema.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/CHANGELOG +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/README +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/Rakefile +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/amazon_s3.yml.tpl +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/init.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/install.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/lib/geometry.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/db_file_backend.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/file_system_backend.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/image_science_processor.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/mini_magick_processor.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/lib/technoweenie/attachment_fu/processors/rmagick_processor.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/amazon_s3.yml +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/backends/db_file_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/backends/file_system_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/backends/remote/s3_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/base_attachment_tests.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/basic_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/database.yml +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/extra_attachment_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/fixtures/attachment.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/fixtures/files/fake/rails.png +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/fixtures/files/foo.txt +0 -0
- data/{starter-app/vendor/plugins/spree/assets/images → vendor/plugins/attachment_fu/test/fixtures/files}/rails.png +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/geometry_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/processors/image_science_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/processors/mini_magick_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/processors/rmagick_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/schema.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/test_helper.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/attachment_fu/test/validation_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/CHANGELOG +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/MIT-LICENSE +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/README +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/init.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/js_test/functional/cds_test.html +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/js_test/prototype.js +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/js_test/test.css +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/js_test/unit/cds_helper_methods.html +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/js_test/unittest.js +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/lib/calendar_date_select.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/lib/includes_helper.rb +0 -0
- data/vendor/plugins/calendar_date_select/public/images/calendar_date_select/calendar.gif +0 -0
- data/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/calendar_date_select.js +439 -0
- data/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_american.js +34 -0
- data/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_euro_24hr.js +7 -0
- data/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_finnish.js +24 -0
- data/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_hyphen_ampm.js +36 -0
- data/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/format_italian.js +24 -0
- data/vendor/plugins/calendar_date_select/public/javascripts/calendar_date_select/locale/fi.js +10 -0
- data/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/blue.css +130 -0
- data/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/default.css +135 -0
- data/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/plain.css +128 -0
- data/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/red.css +135 -0
- data/vendor/plugins/calendar_date_select/public/stylesheets/calendar_date_select/silver.css +133 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/test/functional/calendar_date_select_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/test/functional/helper_methods_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/calendar_date_select/test/test_helper.rb +0 -0
- data/vendor/plugins/enumerable_constants/README +4 -0
- data/vendor/plugins/enumerable_constants/Rakefile +22 -0
- data/vendor/plugins/enumerable_constants/init.rb +1 -0
- data/{starter-app/vendor/plugins/rspec_on_rails/generators/rspec/templates/previous_failures.txt → vendor/plugins/enumerable_constants/install.rb} +0 -0
- data/vendor/plugins/enumerable_constants/lib/enumerable_constants.rb +204 -0
- data/vendor/plugins/enumerable_constants/tasks/enumerable_constants_tasks.rake +4 -0
- data/vendor/plugins/enumerable_constants/test/enumerable_constants_test.rb +8 -0
- data/{starter-app/vendor → vendor}/plugins/in_place_editing/README +0 -0
- data/{starter-app/vendor → vendor}/plugins/in_place_editing/Rakefile +0 -0
- data/{starter-app/vendor → vendor}/plugins/in_place_editing/init.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/in_place_editing/lib/in_place_editing.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/in_place_editing/lib/in_place_macros_helper.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/in_place_editing/test/in_place_editing_test.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/MIT-LICENSE +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/README +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/Rakefile +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec/CHANGES +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec/rspec_generator.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec/templates/all_stories.rb +0 -0
- data/{starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/_partial.rhtml → vendor/plugins/rspec_on_rails/generators/rspec/templates/previous_failures.txt} +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec/templates/rcov.opts +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec/templates/script/spec +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec/templates/script/spec_server +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec/templates/spec.opts +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec/templates/spec_helper.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec/templates/stories_helper.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_controller/USAGE +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_controller/rspec_controller_generator.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_controller/templates/controller_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_controller/templates/helper_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_controller/templates/view_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_model/USAGE +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_model/rspec_model_generator.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_model/templates/model_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_scaffold/rspec_scaffold_generator.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_scaffold/templates/controller_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_scaffold/templates/edit_erb_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_scaffold/templates/helper_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_scaffold/templates/index_erb_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_scaffold/templates/new_erb_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_scaffold/templates/routing_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/generators/rspec_scaffold/templates/show_erb_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/init.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/autotest/discover.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/autotest/rails_rspec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/example.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/example/assigns_hash_proxy.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/example/controller_example_group.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/example/functional_example_group.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/example/helper_example_group.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/example/ivar_proxy.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/example/model_example_group.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/example/rails_example_group.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/example/render_observer.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/example/view_example_group.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/extensions.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/base.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/rescue.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/extensions/action_controller/test_response.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/extensions/action_view/base.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/extensions/active_record/base.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/extensions/object.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/example/configuration.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/extensions/spec/matchers/have.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/matchers.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/matchers/assert_select.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/matchers/have_text.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/matchers/redirect_to.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/matchers/render_template.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/story_adapter.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/lib/spec/rails/version.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/autotest/mappings_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/autotest/rails_rspec_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/configuration_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/controller_isolation_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/controller_spec_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/example_group_factory_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/helper_spec_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/ivar_proxy_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/model_spec_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/shared_behaviour_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/test_unit_assertion_accessibility_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/example/view_spec_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/extensions/action_controller_rescue_action_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/extensions/action_view_base_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/extensions/active_record_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/matchers/assert_select_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/matchers/description_generation_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/matchers/errors_on_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/matchers/have_text_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/matchers/redirect_to_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/matchers/render_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/mocks/mock_model_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/sample_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/spec_server_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails/spec_spec.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/rails_suite.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec/spec_helper.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/controllers/action_view_base_spec_controller.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/controllers/controller_spec_controller.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/controllers/redirect_spec_controller.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/controllers/render_spec_controller.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/controllers/rjs_spec_controller.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/helpers/explicit_helper.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/helpers/more_explicit_helper.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/helpers/plugin_application_helper.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/helpers/view_spec_helper.rb +0 -0
- data/{starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml → vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/_partial.rhtml} +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_flash_after_session_reset.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_flash_before_session_reset.rhtml +0 -0
- data/{starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/_a_partial.rhtml → vendor/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_setting_the_assigns_hash.rhtml} +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_with_errors_in_template.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/controller_spec/action_with_template.rhtml +0 -0
- data/{starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rhtml → vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/_a_partial.rhtml} +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.js.rjs +0 -0
- data/{starter-app/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_used_twice.rhtml → vendor/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rhtml} +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/render_spec/some_action.rjs +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/rjs_spec/_replacement_partial.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/rjs_spec/hide_div.rjs +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/rjs_spec/hide_page_element.rjs +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/rjs_spec/insert_html.rjs +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace.rjs +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace_html.rjs +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/rjs_spec/replace_html_with_partial.rjs +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/rjs_spec/visual_effect.rjs +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/rjs_spec/visual_toggle_effect.rjs +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/tag_spec/no_tags.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/tag_spec/single_div_with_no_attributes.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/tag_spec/single_div_with_one_attribute.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial.rhtml +0 -0
- data/vendor/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_used_twice.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_with_local_variable.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/_partial_with_sub_partial.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/_spacer.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/accessor.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/entry_form.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/explicit_helper.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/foo/show.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/implicit_helper.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/multiple_helpers.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial_using_collection.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/spec_resources/views/view_spec/template_with_partial_with_array.rhtml +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/stories/all.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/stories/helper.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/stories/steps/people.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/stories/transactions_should_rollback +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/stories/transactions_should_rollback.rb +0 -0
- data/{starter-app/vendor → vendor}/plugins/rspec_on_rails/tasks/rspec.rake +0 -0
- data/vendor/rails/TAG_rel_2-0-2 +0 -0
- data/vendor/rails/actionmailer/CHANGELOG +325 -0
- data/vendor/rails/actionmailer/MIT-LICENSE +21 -0
- data/vendor/rails/actionmailer/README +145 -0
- data/vendor/rails/actionmailer/Rakefile +96 -0
- data/vendor/rails/actionmailer/install.rb +30 -0
- data/vendor/rails/actionmailer/lib/action_mailer.rb +52 -0
- data/vendor/rails/actionmailer/lib/action_mailer/adv_attr_accessor.rb +30 -0
- data/vendor/rails/actionmailer/lib/action_mailer/base.rb +603 -0
- data/vendor/rails/actionmailer/lib/action_mailer/helpers.rb +111 -0
- data/vendor/rails/actionmailer/lib/action_mailer/mail_helper.rb +19 -0
- data/vendor/rails/actionmailer/lib/action_mailer/part.rb +110 -0
- data/vendor/rails/actionmailer/lib/action_mailer/part_container.rb +51 -0
- data/vendor/rails/actionmailer/lib/action_mailer/quoting.rb +59 -0
- data/vendor/rails/actionmailer/lib/action_mailer/test_case.rb +59 -0
- data/vendor/rails/actionmailer/lib/action_mailer/test_helper.rb +67 -0
- data/vendor/rails/actionmailer/lib/action_mailer/utils.rb +8 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor.rb +14 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/text-format-0.6.3/text/format.rb +1466 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail.rb +4 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/Makefile +19 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/address.rb +245 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/attachments.rb +47 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/base64.rb +52 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/compat.rb +39 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/config.rb +71 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/core_extensions.rb +67 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/encode.rb +481 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/facade.rb +552 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/header.rb +931 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/info.rb +35 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/interface.rb +540 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/loader.rb +1 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/mail.rb +462 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/mailbox.rb +435 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/mbox.rb +1 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/net.rb +282 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/obsolete.rb +137 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/parser.rb +1475 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/parser.y +381 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/port.rb +379 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/quoting.rb +142 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/scanner.rb +43 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/scanner_r.rb +263 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/stringio.rb +279 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/tmail.rb +1 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/utils.rb +281 -0
- data/vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.1.0/tmail/version.rb +38 -0
- data/vendor/rails/actionmailer/lib/action_mailer/version.rb +9 -0
- data/vendor/rails/actionmailer/lib/actionmailer.rb +1 -0
- data/vendor/rails/actionmailer/test/abstract_unit.rb +49 -0
- data/vendor/rails/actionmailer/test/delivery_method_test.rb +51 -0
- data/vendor/rails/actionmailer/test/fixtures/first_mailer/share.erb +1 -0
- data/vendor/rails/actionmailer/test/fixtures/first_mailer/share.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_example_helper.erb +1 -0
- data/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_example_helper.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper.erb +1 -0
- data/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper_method.erb +1 -0
- data/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_helper_method.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_mail_helper.erb +5 -0
- data/vendor/rails/actionmailer/test/fixtures/helper_mailer/use_mail_helper.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/helpers/example_helper.rb +5 -0
- data/vendor/rails/actionmailer/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.erb +1 -0
- data/vendor/rails/actionmailer/test/fixtures/path.with.dots/funky_path_mailer/multipart_with_template_path_with_dots.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/path.with.dots/multipart_with_template_path_with_dots.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_base64_decoded_string +0 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_base64_encoded_string +1 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email +14 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email10 +20 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email12 +32 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email13 +29 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email2 +114 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email3 +70 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email4 +59 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email5 +19 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email6 +20 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email7 +66 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email8 +47 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email9 +28 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email_quoted_with_0d0a +14 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email_with_invalid_characters_in_content_type +104 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email_with_nested_attachment +100 -0
- data/vendor/rails/actionmailer/test/fixtures/raw_email_with_partially_quoted_subject +14 -0
- data/vendor/rails/actionmailer/test/fixtures/second_mailer/share.erb +1 -0
- data/vendor/rails/actionmailer/test/fixtures/second_mailer/share.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/templates/signed_up.erb +3 -0
- data/vendor/rails/actionmailer/test/fixtures/templates/signed_up.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/_subtemplate.text.plain.erb +1 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/custom_templating_extension.text.html.haml +6 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/custom_templating_extension.text.plain.haml +6 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.ignored.erb +1 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.ignored.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.html.erb +10 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.html.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.plain.erb +2 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.plain.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.erb +1 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/implicitly_multipart_example.text.yaml.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/included_subtemplate.text.plain.erb +1 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/rxml_template.builder +2 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/rxml_template.rxml +2 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/signed_up.erb +3 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/signed_up.rhtml +0 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/signed_up_with_url.erb +5 -0
- data/vendor/rails/actionmailer/test/fixtures/test_mailer/signed_up_with_url.rhtml +0 -0
- data/vendor/rails/actionmailer/test/mail_helper_test.rb +95 -0
- data/vendor/rails/actionmailer/test/mail_render_test.rb +122 -0
- data/vendor/rails/actionmailer/test/mail_service_test.rb +939 -0
- data/vendor/rails/actionmailer/test/quoting_test.rb +111 -0
- data/vendor/rails/actionmailer/test/test_helper_test.rb +117 -0
- data/vendor/rails/actionmailer/test/tmail_test.rb +22 -0
- data/vendor/rails/actionmailer/test/url_test.rb +76 -0
- data/vendor/rails/actionpack/CHANGELOG +4606 -0
- data/vendor/rails/actionpack/MIT-LICENSE +21 -0
- data/vendor/rails/actionpack/README +469 -0
- data/vendor/rails/actionpack/RUNNING_UNIT_TESTS +24 -0
- data/vendor/rails/actionpack/Rakefile +153 -0
- data/vendor/rails/actionpack/install.rb +30 -0
- data/vendor/rails/actionpack/lib/action_controller.rb +79 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions.rb +69 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions/dom_assertions.rb +39 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions/model_assertions.rb +19 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +166 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions/routing_assertions.rb +143 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb +640 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions/tag_assertions.rb +130 -0
- data/vendor/rails/actionpack/lib/action_controller/base.rb +1295 -0
- data/vendor/rails/actionpack/lib/action_controller/benchmarking.rb +94 -0
- data/vendor/rails/actionpack/lib/action_controller/caching.rb +683 -0
- data/vendor/rails/actionpack/lib/action_controller/cgi_ext.rb +16 -0
- data/vendor/rails/actionpack/lib/action_controller/cgi_ext/cookie.rb +106 -0
- data/vendor/rails/actionpack/lib/action_controller/cgi_ext/query_extension.rb +22 -0
- data/vendor/rails/actionpack/lib/action_controller/cgi_ext/session.rb +73 -0
- data/vendor/rails/actionpack/lib/action_controller/cgi_ext/stdinput.rb +23 -0
- data/vendor/rails/actionpack/lib/action_controller/cgi_process.rb +221 -0
- data/vendor/rails/actionpack/lib/action_controller/components.rb +165 -0
- data/vendor/rails/actionpack/lib/action_controller/cookies.rb +84 -0
- data/vendor/rails/actionpack/lib/action_controller/dispatcher.rb +195 -0
- data/vendor/rails/actionpack/lib/action_controller/filters.rb +767 -0
- data/vendor/rails/actionpack/lib/action_controller/flash.rb +177 -0
- data/vendor/rails/actionpack/lib/action_controller/helpers.rb +204 -0
- data/vendor/rails/actionpack/lib/action_controller/http_authentication.rb +126 -0
- data/vendor/rails/actionpack/lib/action_controller/integration.rb +581 -0
- data/vendor/rails/actionpack/lib/action_controller/layout.rb +326 -0
- data/vendor/rails/actionpack/lib/action_controller/mime_responds.rb +170 -0
- data/vendor/rails/actionpack/lib/action_controller/mime_type.rb +163 -0
- data/vendor/rails/actionpack/lib/action_controller/mime_types.rb +20 -0
- data/vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb +88 -0
- data/vendor/rails/actionpack/lib/action_controller/record_identifier.rb +91 -0
- data/vendor/rails/actionpack/lib/action_controller/request.rb +730 -0
- data/vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb +132 -0
- data/vendor/rails/actionpack/lib/action_controller/request_profiler.rb +138 -0
- data/vendor/rails/actionpack/lib/action_controller/rescue.rb +258 -0
- data/vendor/rails/actionpack/lib/action_controller/resources.rb +529 -0
- data/vendor/rails/actionpack/lib/action_controller/response.rb +76 -0
- data/vendor/rails/actionpack/lib/action_controller/routing.rb +1499 -0
- data/vendor/rails/actionpack/lib/action_controller/routing_optimisation.rb +119 -0
- data/vendor/rails/actionpack/lib/action_controller/session/active_record_store.rb +336 -0
- data/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb +164 -0
- data/vendor/rails/actionpack/lib/action_controller/session/drb_server.rb +32 -0
- data/vendor/rails/actionpack/lib/action_controller/session/drb_store.rb +35 -0
- data/vendor/rails/actionpack/lib/action_controller/session/mem_cache_store.rb +98 -0
- data/vendor/rails/actionpack/lib/action_controller/session_management.rb +151 -0
- data/vendor/rails/actionpack/lib/action_controller/status_codes.rb +88 -0
- data/vendor/rails/actionpack/lib/action_controller/streaming.rb +141 -0
- data/vendor/rails/actionpack/lib/action_controller/templates/rescues/_request_and_response.erb +24 -0
- data/vendor/rails/actionpack/lib/action_controller/templates/rescues/_trace.erb +26 -0
- data/vendor/rails/actionpack/lib/action_controller/templates/rescues/diagnostics.erb +11 -0
- data/vendor/rails/actionpack/lib/action_controller/templates/rescues/layout.erb +29 -0
- data/vendor/rails/actionpack/lib/action_controller/templates/rescues/missing_template.erb +2 -0
- data/vendor/rails/actionpack/lib/action_controller/templates/rescues/routing_error.erb +10 -0
- data/vendor/rails/actionpack/lib/action_controller/templates/rescues/template_error.erb +21 -0
- data/vendor/rails/actionpack/lib/action_controller/templates/rescues/unknown_action.erb +2 -0
- data/vendor/rails/actionpack/lib/action_controller/test_case.rb +53 -0
- data/vendor/rails/actionpack/lib/action_controller/test_process.rb +520 -0
- data/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +135 -0
- data/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/document.rb +68 -0
- data/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb +530 -0
- data/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/sanitizer.rb +173 -0
- data/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb +828 -0
- data/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +105 -0
- data/vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/version.rb +11 -0
- data/vendor/rails/actionpack/lib/action_controller/verification.rb +114 -0
- data/vendor/rails/actionpack/lib/action_pack.rb +24 -0
- data/vendor/rails/actionpack/lib/action_pack/version.rb +9 -0
- data/vendor/rails/actionpack/lib/action_view.rb +37 -0
- data/vendor/rails/actionpack/lib/action_view/base.rb +642 -0
- data/vendor/rails/actionpack/lib/action_view/compiled_templates.rb +69 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb +255 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb +548 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/atom_feed_helper.rb +111 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/benchmark_helper.rb +31 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/cache_helper.rb +39 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb +162 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb +689 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb +31 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb +689 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb +425 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb +432 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/javascript_helper.rb +217 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/javascripts/controls.js +963 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/javascripts/dragdrop.js +972 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/javascripts/effects.js +1120 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/javascripts/prototype.js +4225 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb +179 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +1268 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/record_identification_helper.rb +20 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/record_tag_helper.rb +59 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/sanitize_helper.rb +223 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/scriptaculous_helper.rb +199 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb +133 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/text_helper.rb +479 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb +524 -0
- data/vendor/rails/actionpack/lib/action_view/partials.rb +200 -0
- data/vendor/rails/actionpack/lib/action_view/template_error.rb +102 -0
- data/vendor/rails/actionpack/lib/action_view/template_handler.rb +17 -0
- data/vendor/rails/actionpack/lib/action_view/template_handlers/builder.rb +19 -0
- data/vendor/rails/actionpack/lib/action_view/template_handlers/erb.rb +21 -0
- data/vendor/rails/actionpack/lib/action_view/template_handlers/rjs.rb +14 -0
- data/vendor/rails/actionpack/lib/actionpack.rb +1 -0
- data/vendor/rails/actionpack/test/abstract_unit.rb +36 -0
- data/vendor/rails/actionpack/test/action_view_test.rb +44 -0
- data/vendor/rails/actionpack/test/active_record_unit.rb +108 -0
- data/vendor/rails/actionpack/test/activerecord/active_record_store_test.rb +142 -0
- data/vendor/rails/actionpack/test/activerecord/render_partial_with_record_identification_test.rb +74 -0
- data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +492 -0
- data/vendor/rails/actionpack/test/controller/addresses_render_test.rb +43 -0
- data/vendor/rails/actionpack/test/controller/assert_select_test.rb +682 -0
- data/vendor/rails/actionpack/test/controller/base_test.rb +134 -0
- data/vendor/rails/actionpack/test/controller/benchmark_test.rb +33 -0
- data/vendor/rails/actionpack/test/controller/caching_test.rb +349 -0
- data/vendor/rails/actionpack/test/controller/capture_test.rb +89 -0
- data/vendor/rails/actionpack/test/controller/cgi_test.rb +115 -0
- data/vendor/rails/actionpack/test/controller/components_test.rb +140 -0
- data/vendor/rails/actionpack/test/controller/content_type_test.rb +139 -0
- data/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
- data/vendor/rails/actionpack/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
- data/vendor/rails/actionpack/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
- data/vendor/rails/actionpack/test/controller/cookie_test.rb +135 -0
- data/vendor/rails/actionpack/test/controller/custom_handler_test.rb +41 -0
- data/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb +37 -0
- data/vendor/rails/actionpack/test/controller/dispatcher_test.rb +123 -0
- data/vendor/rails/actionpack/test/controller/fake_controllers.rb +16 -0
- data/vendor/rails/actionpack/test/controller/fake_models.rb +5 -0
- data/vendor/rails/actionpack/test/controller/filter_params_test.rb +43 -0
- data/vendor/rails/actionpack/test/controller/filters_test.rb +856 -0
- data/vendor/rails/actionpack/test/controller/flash_test.rb +146 -0
- data/vendor/rails/actionpack/test/controller/fragment_store_setting_test.rb +47 -0
- data/vendor/rails/actionpack/test/controller/helper_test.rb +206 -0
- data/vendor/rails/actionpack/test/controller/html-scanner/document_test.rb +124 -0
- data/vendor/rails/actionpack/test/controller/html-scanner/node_test.rb +69 -0
- data/vendor/rails/actionpack/test/controller/html-scanner/sanitizer_test.rb +250 -0
- data/vendor/rails/actionpack/test/controller/html-scanner/tag_node_test.rb +239 -0
- data/vendor/rails/actionpack/test/controller/html-scanner/text_node_test.rb +51 -0
- data/vendor/rails/actionpack/test/controller/html-scanner/tokenizer_test.rb +125 -0
- data/vendor/rails/actionpack/test/controller/http_authentication_test.rb +54 -0
- data/vendor/rails/actionpack/test/controller/integration_test.rb +255 -0
- data/vendor/rails/actionpack/test/controller/layout_test.rb +239 -0
- data/vendor/rails/actionpack/test/controller/mime_responds_test.rb +506 -0
- data/vendor/rails/actionpack/test/controller/mime_type_test.rb +55 -0
- data/vendor/rails/actionpack/test/controller/new_render_test.rb +832 -0
- data/vendor/rails/actionpack/test/controller/polymorphic_routes_test.rb +98 -0
- data/vendor/rails/actionpack/test/controller/record_identifier_test.rb +103 -0
- data/vendor/rails/actionpack/test/controller/redirect_test.rb +258 -0
- data/vendor/rails/actionpack/test/controller/render_test.rb +464 -0
- data/vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb +217 -0
- data/vendor/rails/actionpack/test/controller/request_test.rb +836 -0
- data/vendor/rails/actionpack/test/controller/rescue_test.rb +501 -0
- data/vendor/rails/actionpack/test/controller/resources_test.rb +787 -0
- data/vendor/rails/actionpack/test/controller/routing_test.rb +2203 -0
- data/vendor/rails/actionpack/test/controller/selector_test.rb +628 -0
- data/vendor/rails/actionpack/test/controller/send_file_test.rb +127 -0
- data/vendor/rails/actionpack/test/controller/session/cookie_store_test.rb +246 -0
- data/vendor/rails/actionpack/test/controller/session/mem_cache_store_test.rb +182 -0
- data/vendor/rails/actionpack/test/controller/session_fixation_test.rb +89 -0
- data/vendor/rails/actionpack/test/controller/session_management_test.rb +156 -0
- data/vendor/rails/actionpack/test/controller/test_test.rb +623 -0
- data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +246 -0
- data/vendor/rails/actionpack/test/controller/verification_test.rb +253 -0
- data/vendor/rails/actionpack/test/controller/view_paths_test.rb +137 -0
- data/vendor/rails/actionpack/test/controller/webservice_test.rb +184 -0
- data/vendor/rails/actionpack/test/fixtures/addresses/list.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/companies.yml +24 -0
- data/vendor/rails/actionpack/test/fixtures/company.rb +9 -0
- data/vendor/rails/actionpack/test/fixtures/content_type/render_default_content_types_for_respond_to.rhtml +1 -0
- data/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rhtml.rhtml +1 -0
- data/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rjs.rjs +1 -0
- data/vendor/rails/actionpack/test/fixtures/content_type/render_default_for_rxml.rxml +1 -0
- data/vendor/rails/actionpack/test/fixtures/db_definitions/sqlite.sql +43 -0
- data/vendor/rails/actionpack/test/fixtures/developer.rb +9 -0
- data/vendor/rails/actionpack/test/fixtures/developers.yml +21 -0
- data/vendor/rails/actionpack/test/fixtures/developers_projects.yml +13 -0
- data/vendor/rails/actionpack/test/fixtures/fun/games/hello_world.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/helpers/abc_helper.rb +5 -0
- data/vendor/rails/actionpack/test/fixtures/helpers/fun/games_helper.rb +3 -0
- data/vendor/rails/actionpack/test/fixtures/helpers/fun/pdf_helper.rb +3 -0
- data/vendor/rails/actionpack/test/fixtures/layout_tests/alt/hello.rhtml +1 -0
- data/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml +1 -0
- data/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/item.rhtml +1 -0
- data/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/layout_test.rhtml +1 -0
- data/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/multiple_extensions.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/layout_tests/layouts/third_party_template_library.mab +1 -0
- data/vendor/rails/actionpack/test/fixtures/layout_tests/views/hello.rhtml +1 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/builder.builder +3 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/standard.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/talk_from_action.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/layouts/yield.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/binary_file +0 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/bracketed_param +5 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/large_text_file +10 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/mixed_files +0 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/mona_lisa.jpg +0 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/single_parameter +5 -0
- data/vendor/rails/actionpack/test/fixtures/multipart/text_file +10 -0
- data/vendor/rails/actionpack/test/fixtures/override/test/hello_world.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/override2/layouts/test/sub.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/layouts/post.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/layouts/super_post.iphone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/post/index.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/post/index.iphone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/post_test/super_post/index.iphone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/project.rb +3 -0
- data/vendor/rails/actionpack/test/fixtures/projects.yml +7 -0
- data/vendor/rails/actionpack/test/fixtures/public/404.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/500.html +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/images/rails.png +0 -0
- data/vendor/rails/actionpack/test/fixtures/public/javascripts/application.js +0 -0
- data/vendor/rails/actionpack/test/fixtures/public/javascripts/bank.js +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/javascripts/robber.js +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/stylesheets/bank.css +1 -0
- data/vendor/rails/actionpack/test/fixtures/public/stylesheets/robber.css +1 -0
- data/vendor/rails/actionpack/test/fixtures/replies.yml +15 -0
- data/vendor/rails/actionpack/test/fixtures/reply.rb +6 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/all_types_with_layout.js.rjs +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/custom_constant_handling_without_block.mobile.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/iphone_with_html_response_type.iphone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/layouts/missing.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/layouts/standard.iphone.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.js.rjs +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults.xml.builder +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.js.rjs +1 -0
- data/vendor/rails/actionpack/test/fixtures/respond_to/using_defaults_with_type_list.xml.builder +1 -0
- data/vendor/rails/actionpack/test/fixtures/scope/test/modgreet.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_customer.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_customer_greeting.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_hash_greeting.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_hash_object.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/test/_hello.builder +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_layout_for_partial.html.erb +3 -0
- data/vendor/rails/actionpack/test/fixtures/test/_partial.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_partial.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_partial.js.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_partial_for_use_in_layout.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_partial_only.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/_person.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/test/action_talk_to_layout.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/test/block_content_for.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/test/calling_partial_with_layout.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/capturing.erb +4 -0
- data/vendor/rails/actionpack/test/fixtures/test/content_for.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/test/content_for_concatenated.erb +3 -0
- data/vendor/rails/actionpack/test/fixtures/test/content_for_with_parameter.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/test/delete_with_js.rjs +2 -0
- data/vendor/rails/actionpack/test/fixtures/test/dot.directory/render_file_with_ivar.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/enum_rjs_test.rjs +6 -0
- data/vendor/rails/actionpack/test/fixtures/test/erb_content_for.erb +2 -0
- data/vendor/rails/actionpack/test/fixtures/test/formatted_html_erb.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.builder +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/formatted_xml_erb.xml.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/greeting.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello.builder +4 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello_world.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello_world_container.builder +3 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello_world_from_rxml.builder +4 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello_world_with_layout_false.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello_xml_world.builder +11 -0
- data/vendor/rails/actionpack/test/fixtures/test/list.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/non_erb_block_content_for.builder +4 -0
- data/vendor/rails/actionpack/test/fixtures/test/potential_conflicts.erb +4 -0
- data/vendor/rails/actionpack/test/fixtures/test/render_file_with_ivar.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/render_file_with_locals.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/render_to_string_test.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/test/update_element_with_capture.erb +9 -0
- data/vendor/rails/actionpack/test/fixtures/test/using_layout_around_block.html.erb +1 -0
- data/vendor/rails/actionpack/test/fixtures/topic.rb +3 -0
- data/vendor/rails/actionpack/test/fixtures/topics.yml +22 -0
- data/vendor/rails/actionpack/test/template/active_record_helper_test.rb +251 -0
- data/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +438 -0
- data/vendor/rails/actionpack/test/template/atom_feed_helper_test.rb +101 -0
- data/vendor/rails/actionpack/test/template/benchmark_helper_test.rb +72 -0
- data/vendor/rails/actionpack/test/template/compiled_templates_test.rb +193 -0
- data/vendor/rails/actionpack/test/template/date_helper_test.rb +1438 -0
- data/vendor/rails/actionpack/test/template/erb_util_test.rb +56 -0
- data/vendor/rails/actionpack/test/template/form_helper_test.rb +792 -0
- data/vendor/rails/actionpack/test/template/form_options_helper_test.rb +1296 -0
- data/vendor/rails/actionpack/test/template/form_tag_helper_test.rb +238 -0
- data/vendor/rails/actionpack/test/template/javascript_helper_test.rb +115 -0
- data/vendor/rails/actionpack/test/template/number_helper_test.rb +93 -0
- data/vendor/rails/actionpack/test/template/prototype_helper_test.rb +627 -0
- data/vendor/rails/actionpack/test/template/sanitize_helper_test.rb +49 -0
- data/vendor/rails/actionpack/test/template/scriptaculous_helper_test.rb +96 -0
- data/vendor/rails/actionpack/test/template/tag_helper_test.rb +80 -0
- data/vendor/rails/actionpack/test/template/text_helper_test.rb +335 -0
- data/vendor/rails/actionpack/test/template/url_helper_test.rb +536 -0
- data/vendor/rails/actionpack/test/testing_sandbox.rb +11 -0
- data/vendor/rails/activerecord/CHANGELOG +5527 -0
- data/vendor/rails/activerecord/MIT-LICENSE +20 -0
- data/vendor/rails/activerecord/README +346 -0
- data/vendor/rails/activerecord/RUNNING_UNIT_TESTS +33 -0
- data/vendor/rails/activerecord/Rakefile +248 -0
- data/vendor/rails/activerecord/examples/associations.png +0 -0
- data/vendor/rails/activerecord/install.rb +30 -0
- data/vendor/rails/activerecord/lib/active_record.rb +76 -0
- data/vendor/rails/activerecord/lib/active_record/aggregations.rb +180 -0
- data/vendor/rails/activerecord/lib/active_record/associations.rb +1769 -0
- data/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +240 -0
- data/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb +160 -0
- data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb +56 -0
- data/vendor/rails/activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb +50 -0
- data/vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb +164 -0
- data/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +174 -0
- data/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +284 -0
- data/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb +96 -0
- data/vendor/rails/activerecord/lib/active_record/attribute_methods.rb +328 -0
- data/vendor/rails/activerecord/lib/active_record/base.rb +2471 -0
- data/vendor/rails/activerecord/lib/active_record/calculations.rb +267 -0
- data/vendor/rails/activerecord/lib/active_record/callbacks.rb +341 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +308 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +171 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb +87 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +69 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +472 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +306 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +172 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +496 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +847 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +34 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +391 -0
- data/vendor/rails/activerecord/lib/active_record/fixtures.rb +1034 -0
- data/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb +144 -0
- data/vendor/rails/activerecord/lib/active_record/locking/pessimistic.rb +77 -0
- data/vendor/rails/activerecord/lib/active_record/migration.rb +417 -0
- data/vendor/rails/activerecord/lib/active_record/observer.rb +181 -0
- data/vendor/rails/activerecord/lib/active_record/query_cache.rb +21 -0
- data/vendor/rails/activerecord/lib/active_record/reflection.rb +219 -0
- data/vendor/rails/activerecord/lib/active_record/schema.rb +58 -0
- data/vendor/rails/activerecord/lib/active_record/schema_dumper.rb +171 -0
- data/vendor/rails/activerecord/lib/active_record/serialization.rb +98 -0
- data/vendor/rails/activerecord/lib/active_record/serializers/json_serializer.rb +71 -0
- data/vendor/rails/activerecord/lib/active_record/serializers/xml_serializer.rb +315 -0
- data/vendor/rails/activerecord/lib/active_record/timestamp.rb +41 -0
- data/vendor/rails/activerecord/lib/active_record/transactions.rb +132 -0
- data/vendor/rails/activerecord/lib/active_record/validations.rb +1025 -0
- data/vendor/rails/activerecord/lib/active_record/vendor/db2.rb +362 -0
- data/vendor/rails/activerecord/lib/active_record/vendor/mysql.rb +1214 -0
- data/vendor/rails/activerecord/lib/active_record/version.rb +9 -0
- data/vendor/rails/activerecord/lib/activerecord.rb +1 -0
- data/vendor/rails/activerecord/test/aaa_create_tables_test.rb +72 -0
- data/vendor/rails/activerecord/test/abstract_unit.rb +84 -0
- data/vendor/rails/activerecord/test/active_schema_test_mysql.rb +43 -0
- data/vendor/rails/activerecord/test/adapter_test.rb +105 -0
- data/vendor/rails/activerecord/test/adapter_test_sqlserver.rb +95 -0
- data/vendor/rails/activerecord/test/aggregations_test.rb +128 -0
- data/vendor/rails/activerecord/test/all.sh +8 -0
- data/vendor/rails/activerecord/test/ar_schema_test.rb +33 -0
- data/vendor/rails/activerecord/test/association_inheritance_reload.rb +14 -0
- data/vendor/rails/activerecord/test/associations/callbacks_test.rb +147 -0
- data/vendor/rails/activerecord/test/associations/cascaded_eager_loading_test.rb +110 -0
- data/vendor/rails/activerecord/test/associations/eager_singularization_test.rb +145 -0
- data/vendor/rails/activerecord/test/associations/eager_test.rb +442 -0
- data/vendor/rails/activerecord/test/associations/extension_test.rb +47 -0
- data/vendor/rails/activerecord/test/associations/inner_join_association_test.rb +88 -0
- data/vendor/rails/activerecord/test/associations/join_model_test.rb +559 -0
- data/vendor/rails/activerecord/test/associations_test.rb +2147 -0
- data/vendor/rails/activerecord/test/attribute_methods_test.rb +146 -0
- data/vendor/rails/activerecord/test/base_test.rb +1745 -0
- data/vendor/rails/activerecord/test/binary_test.rb +32 -0
- data/vendor/rails/activerecord/test/calculations_test.rb +251 -0
- data/vendor/rails/activerecord/test/callbacks_test.rb +400 -0
- data/vendor/rails/activerecord/test/class_inheritable_attributes_test.rb +32 -0
- data/vendor/rails/activerecord/test/column_alias_test.rb +17 -0
- data/vendor/rails/activerecord/test/connection_test_firebird.rb +8 -0
- data/vendor/rails/activerecord/test/connection_test_mysql.rb +30 -0
- data/vendor/rails/activerecord/test/connections/native_db2/connection.rb +25 -0
- data/vendor/rails/activerecord/test/connections/native_firebird/connection.rb +26 -0
- data/vendor/rails/activerecord/test/connections/native_frontbase/connection.rb +27 -0
- data/vendor/rails/activerecord/test/connections/native_mysql/connection.rb +27 -0
- data/vendor/rails/activerecord/test/connections/native_openbase/connection.rb +21 -0
- data/vendor/rails/activerecord/test/connections/native_oracle/connection.rb +27 -0
- data/vendor/rails/activerecord/test/connections/native_postgresql/connection.rb +23 -0
- data/vendor/rails/activerecord/test/connections/native_sqlite/connection.rb +25 -0
- data/vendor/rails/activerecord/test/connections/native_sqlite3/connection.rb +25 -0
- data/vendor/rails/activerecord/test/connections/native_sqlite3/in_memory_connection.rb +18 -0
- data/vendor/rails/activerecord/test/connections/native_sybase/connection.rb +23 -0
- data/vendor/rails/activerecord/test/copy_table_test_sqlite.rb +69 -0
- data/vendor/rails/activerecord/test/datatype_test_postgresql.rb +203 -0
- data/vendor/rails/activerecord/test/date_time_test.rb +37 -0
- data/vendor/rails/activerecord/test/default_test_firebird.rb +16 -0
- data/vendor/rails/activerecord/test/defaults_test.rb +67 -0
- data/vendor/rails/activerecord/test/deprecated_finder_test.rb +30 -0
- data/vendor/rails/activerecord/test/finder_test.rb +650 -0
- data/vendor/rails/activerecord/test/fixtures/accounts.yml +28 -0
- data/vendor/rails/activerecord/test/fixtures/all/developers.yml +0 -0
- data/vendor/rails/activerecord/test/fixtures/all/people.csv +0 -0
- data/vendor/rails/activerecord/test/fixtures/all/tasks.yml +0 -0
- data/vendor/rails/activerecord/test/fixtures/author.rb +109 -0
- data/vendor/rails/activerecord/test/fixtures/author_favorites.yml +4 -0
- data/vendor/rails/activerecord/test/fixtures/authors.yml +7 -0
- data/vendor/rails/activerecord/test/fixtures/auto_id.rb +4 -0
- data/vendor/rails/activerecord/test/fixtures/bad_fixtures/attr_with_numeric_first_char +1 -0
- data/vendor/rails/activerecord/test/fixtures/bad_fixtures/attr_with_spaces +1 -0
- data/vendor/rails/activerecord/test/fixtures/bad_fixtures/blank_line +3 -0
- data/vendor/rails/activerecord/test/fixtures/bad_fixtures/duplicate_attributes +3 -0
- data/vendor/rails/activerecord/test/fixtures/bad_fixtures/missing_value +1 -0
- data/vendor/rails/activerecord/test/fixtures/binaries.yml +132 -0
- data/vendor/rails/activerecord/test/fixtures/binary.rb +2 -0
- data/vendor/rails/activerecord/test/fixtures/book.rb +4 -0
- data/vendor/rails/activerecord/test/fixtures/books.yml +7 -0
- data/vendor/rails/activerecord/test/fixtures/categories.yml +14 -0
- data/vendor/rails/activerecord/test/fixtures/categories/special_categories.yml +9 -0
- data/vendor/rails/activerecord/test/fixtures/categories/subsubdir/arbitrary_filename.yml +4 -0
- data/vendor/rails/activerecord/test/fixtures/categories_ordered.yml +7 -0
- data/vendor/rails/activerecord/test/fixtures/categories_posts.yml +23 -0
- data/vendor/rails/activerecord/test/fixtures/categorization.rb +5 -0
- data/vendor/rails/activerecord/test/fixtures/categorizations.yml +17 -0
- data/vendor/rails/activerecord/test/fixtures/category.rb +26 -0
- data/vendor/rails/activerecord/test/fixtures/citation.rb +6 -0
- data/vendor/rails/activerecord/test/fixtures/column_name.rb +3 -0
- data/vendor/rails/activerecord/test/fixtures/comment.rb +23 -0
- data/vendor/rails/activerecord/test/fixtures/comments.yml +59 -0
- data/vendor/rails/activerecord/test/fixtures/companies.yml +55 -0
- data/vendor/rails/activerecord/test/fixtures/company.rb +114 -0
- data/vendor/rails/activerecord/test/fixtures/company_in_module.rb +59 -0
- data/vendor/rails/activerecord/test/fixtures/computer.rb +4 -0
- data/vendor/rails/activerecord/test/fixtures/computers.yml +4 -0
- data/vendor/rails/activerecord/test/fixtures/contact.rb +16 -0
- data/vendor/rails/activerecord/test/fixtures/course.rb +3 -0
- data/vendor/rails/activerecord/test/fixtures/courses.yml +7 -0
- data/vendor/rails/activerecord/test/fixtures/customer.rb +55 -0
- data/vendor/rails/activerecord/test/fixtures/customers.yml +17 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/db2.drop.sql +33 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/db2.sql +235 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/db22.drop.sql +2 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/db22.sql +5 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/firebird.drop.sql +65 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/firebird.sql +310 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/firebird2.drop.sql +2 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/firebird2.sql +6 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/frontbase.drop.sql +33 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/frontbase.sql +273 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/frontbase2.drop.sql +1 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/frontbase2.sql +4 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/openbase.drop.sql +2 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/openbase.sql +318 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/openbase2.drop.sql +2 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/openbase2.sql +7 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/oracle.drop.sql +67 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/oracle.sql +330 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/oracle2.drop.sql +2 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/oracle2.sql +6 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/postgresql.drop.sql +44 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/postgresql.sql +292 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/postgresql2.drop.sql +2 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/postgresql2.sql +4 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/schema.rb +354 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/schema2.rb +11 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/sqlite.drop.sql +33 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/sqlite.sql +219 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/sqlite2.drop.sql +2 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/sqlite2.sql +5 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/sybase.drop.sql +35 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/sybase.sql +222 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/sybase2.drop.sql +4 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/sybase2.sql +5 -0
- data/vendor/rails/activerecord/test/fixtures/default.rb +2 -0
- data/vendor/rails/activerecord/test/fixtures/developer.rb +72 -0
- data/vendor/rails/activerecord/test/fixtures/developers.yml +21 -0
- data/vendor/rails/activerecord/test/fixtures/developers_projects.yml +17 -0
- data/vendor/rails/activerecord/test/fixtures/developers_projects/david_action_controller +3 -0
- data/vendor/rails/activerecord/test/fixtures/developers_projects/david_active_record +3 -0
- data/vendor/rails/activerecord/test/fixtures/developers_projects/jamis_active_record +2 -0
- data/vendor/rails/activerecord/test/fixtures/edge.rb +5 -0
- data/vendor/rails/activerecord/test/fixtures/edges.yml +6 -0
- data/vendor/rails/activerecord/test/fixtures/entrant.rb +3 -0
- data/vendor/rails/activerecord/test/fixtures/entrants.yml +14 -0
- data/vendor/rails/activerecord/test/fixtures/example.log +1 -0
- data/vendor/rails/activerecord/test/fixtures/fk_test_has_fk.yml +3 -0
- data/vendor/rails/activerecord/test/fixtures/fk_test_has_pk.yml +2 -0
- data/vendor/rails/activerecord/test/fixtures/flowers.jpg +0 -0
- data/vendor/rails/activerecord/test/fixtures/funny_jokes.yml +10 -0
- data/vendor/rails/activerecord/test/fixtures/item.rb +7 -0
- data/vendor/rails/activerecord/test/fixtures/items.yml +4 -0
- data/vendor/rails/activerecord/test/fixtures/joke.rb +3 -0
- data/vendor/rails/activerecord/test/fixtures/keyboard.rb +3 -0
- data/vendor/rails/activerecord/test/fixtures/legacy_thing.rb +3 -0
- data/vendor/rails/activerecord/test/fixtures/legacy_things.yml +3 -0
- data/vendor/rails/activerecord/test/fixtures/matey.rb +4 -0
- data/vendor/rails/activerecord/test/fixtures/mateys.yml +4 -0
- data/vendor/rails/activerecord/test/fixtures/migrations/1_people_have_last_names.rb +9 -0
- data/vendor/rails/activerecord/test/fixtures/migrations/2_we_need_reminders.rb +12 -0
- data/vendor/rails/activerecord/test/fixtures/migrations/3_innocent_jointable.rb +12 -0
- data/vendor/rails/activerecord/test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb +15 -0
- data/vendor/rails/activerecord/test/fixtures/migrations_with_duplicate/1_people_have_last_names.rb +9 -0
- data/vendor/rails/activerecord/test/fixtures/migrations_with_duplicate/2_we_need_reminders.rb +12 -0
- data/vendor/rails/activerecord/test/fixtures/migrations_with_duplicate/3_foo.rb +7 -0
- data/vendor/rails/activerecord/test/fixtures/migrations_with_duplicate/3_innocent_jointable.rb +12 -0
- data/vendor/rails/activerecord/test/fixtures/migrations_with_missing_versions/1000_people_have_middle_names.rb +9 -0
- data/vendor/rails/activerecord/test/fixtures/migrations_with_missing_versions/1_people_have_last_names.rb +9 -0
- data/vendor/rails/activerecord/test/fixtures/migrations_with_missing_versions/3_we_need_reminders.rb +12 -0
- data/vendor/rails/activerecord/test/fixtures/migrations_with_missing_versions/4_innocent_jointable.rb +12 -0
- data/vendor/rails/activerecord/test/fixtures/minimalistic.rb +2 -0
- data/vendor/rails/activerecord/test/fixtures/minimalistics.yml +2 -0
- data/vendor/rails/activerecord/test/fixtures/mixed_case_monkey.rb +3 -0
- data/vendor/rails/activerecord/test/fixtures/mixed_case_monkeys.yml +6 -0
- data/vendor/rails/activerecord/test/fixtures/mixins.yml +29 -0
- data/vendor/rails/activerecord/test/fixtures/movie.rb +5 -0
- data/vendor/rails/activerecord/test/fixtures/movies.yml +7 -0
- data/vendor/rails/activerecord/test/fixtures/naked/csv/accounts.csv +1 -0
- data/vendor/rails/activerecord/test/fixtures/naked/yml/accounts.yml +1 -0
- data/vendor/rails/activerecord/test/fixtures/naked/yml/companies.yml +1 -0
- data/vendor/rails/activerecord/test/fixtures/naked/yml/courses.yml +1 -0
- data/vendor/rails/activerecord/test/fixtures/order.rb +4 -0
- data/vendor/rails/activerecord/test/fixtures/parrot.rb +13 -0
- data/vendor/rails/activerecord/test/fixtures/parrots.yml +27 -0
- data/vendor/rails/activerecord/test/fixtures/parrots_pirates.yml +7 -0
- data/vendor/rails/activerecord/test/fixtures/people.yml +3 -0
- data/vendor/rails/activerecord/test/fixtures/person.rb +4 -0
- data/vendor/rails/activerecord/test/fixtures/pirate.rb +5 -0
- data/vendor/rails/activerecord/test/fixtures/pirates.yml +9 -0
- data/vendor/rails/activerecord/test/fixtures/post.rb +59 -0
- data/vendor/rails/activerecord/test/fixtures/posts.yml +48 -0
- data/vendor/rails/activerecord/test/fixtures/project.rb +28 -0
- data/vendor/rails/activerecord/test/fixtures/projects.yml +7 -0
- data/vendor/rails/activerecord/test/fixtures/reader.rb +4 -0
- data/vendor/rails/activerecord/test/fixtures/readers.yml +4 -0
- data/vendor/rails/activerecord/test/fixtures/reply.rb +37 -0
- data/vendor/rails/activerecord/test/fixtures/reserved_words/distinct.yml +5 -0
- data/vendor/rails/activerecord/test/fixtures/reserved_words/distincts_selects.yml +11 -0
- data/vendor/rails/activerecord/test/fixtures/reserved_words/group.yml +14 -0
- data/vendor/rails/activerecord/test/fixtures/reserved_words/select.yml +8 -0
- data/vendor/rails/activerecord/test/fixtures/reserved_words/values.yml +7 -0
- data/vendor/rails/activerecord/test/fixtures/ship.rb +3 -0
- data/vendor/rails/activerecord/test/fixtures/ships.yml +5 -0
- data/vendor/rails/activerecord/test/fixtures/subject.rb +4 -0
- data/vendor/rails/activerecord/test/fixtures/subscriber.rb +6 -0
- data/vendor/rails/activerecord/test/fixtures/subscribers/first +2 -0
- data/vendor/rails/activerecord/test/fixtures/subscribers/second +2 -0
- data/vendor/rails/activerecord/test/fixtures/tag.rb +7 -0
- data/vendor/rails/activerecord/test/fixtures/tagging.rb +10 -0
- data/vendor/rails/activerecord/test/fixtures/taggings.yml +25 -0
- data/vendor/rails/activerecord/test/fixtures/tags.yml +7 -0
- data/vendor/rails/activerecord/test/fixtures/task.rb +3 -0
- data/vendor/rails/activerecord/test/fixtures/tasks.yml +7 -0
- data/vendor/rails/activerecord/test/fixtures/topic.rb +37 -0
- data/vendor/rails/activerecord/test/fixtures/topics.yml +22 -0
- data/vendor/rails/activerecord/test/fixtures/treasure.rb +4 -0
- data/vendor/rails/activerecord/test/fixtures/treasures.yml +10 -0
- data/vendor/rails/activerecord/test/fixtures/vertex.rb +9 -0
- data/vendor/rails/activerecord/test/fixtures/vertices.yml +4 -0
- data/vendor/rails/activerecord/test/fixtures_test.rb +602 -0
- data/vendor/rails/activerecord/test/inheritance_test.rb +211 -0
- data/vendor/rails/activerecord/test/json_serialization_test.rb +180 -0
- data/vendor/rails/activerecord/test/lifecycle_test.rb +137 -0
- data/vendor/rails/activerecord/test/locking_test.rb +282 -0
- data/vendor/rails/activerecord/test/method_scoping_test.rb +416 -0
- data/vendor/rails/activerecord/test/migration_test.rb +933 -0
- data/vendor/rails/activerecord/test/migration_test_firebird.rb +124 -0
- data/vendor/rails/activerecord/test/mixin_test.rb +95 -0
- data/vendor/rails/activerecord/test/modules_test.rb +34 -0
- data/vendor/rails/activerecord/test/multiple_db_test.rb +60 -0
- data/vendor/rails/activerecord/test/pk_test.rb +101 -0
- data/vendor/rails/activerecord/test/query_cache_test.rb +104 -0
- data/vendor/rails/activerecord/test/readonly_test.rb +107 -0
- data/vendor/rails/activerecord/test/reflection_test.rb +175 -0
- data/vendor/rails/activerecord/test/reserved_word_test_mysql.rb +177 -0
- data/vendor/rails/activerecord/test/schema_authorization_test_postgresql.rb +75 -0
- data/vendor/rails/activerecord/test/schema_dumper_test.rb +131 -0
- data/vendor/rails/activerecord/test/schema_test_postgresql.rb +64 -0
- data/vendor/rails/activerecord/test/serialization_test.rb +47 -0
- data/vendor/rails/activerecord/test/synonym_test_oracle.rb +17 -0
- data/vendor/rails/activerecord/test/table_name_test_sqlserver.rb +23 -0
- data/vendor/rails/activerecord/test/threaded_connections_test.rb +48 -0
- data/vendor/rails/activerecord/test/transactions_test.rb +281 -0
- data/vendor/rails/activerecord/test/unconnected_test.rb +32 -0
- data/vendor/rails/activerecord/test/validations_test.rb +1395 -0
- data/vendor/rails/activerecord/test/xml_serialization_test.rb +202 -0
- data/vendor/rails/activeresource/CHANGELOG +223 -0
- data/vendor/rails/activeresource/MIT-LICENSE +20 -0
- data/vendor/rails/activeresource/README +165 -0
- data/vendor/rails/activeresource/Rakefile +134 -0
- data/vendor/rails/activeresource/lib/active_resource.rb +47 -0
- data/vendor/rails/activeresource/lib/active_resource/base.rb +872 -0
- data/vendor/rails/activeresource/lib/active_resource/connection.rb +172 -0
- data/vendor/rails/activeresource/lib/active_resource/custom_methods.rb +105 -0
- data/vendor/rails/activeresource/lib/active_resource/formats.rb +14 -0
- data/vendor/rails/activeresource/lib/active_resource/formats/json_format.rb +23 -0
- data/vendor/rails/activeresource/lib/active_resource/formats/xml_format.rb +34 -0
- data/vendor/rails/activeresource/lib/active_resource/http_mock.rb +147 -0
- data/vendor/rails/activeresource/lib/active_resource/validations.rb +288 -0
- data/vendor/rails/activeresource/lib/active_resource/version.rb +9 -0
- data/vendor/rails/activeresource/lib/activeresource.rb +1 -0
- data/vendor/rails/activeresource/test/abstract_unit.rb +10 -0
- data/vendor/rails/activeresource/test/authorization_test.rb +82 -0
- data/vendor/rails/activeresource/test/base/custom_methods_test.rb +96 -0
- data/vendor/rails/activeresource/test/base/equality_test.rb +43 -0
- data/vendor/rails/activeresource/test/base/load_test.rb +111 -0
- data/vendor/rails/activeresource/test/base_errors_test.rb +48 -0
- data/vendor/rails/activeresource/test/base_test.rb +454 -0
- data/vendor/rails/activeresource/test/connection_test.rb +170 -0
- data/vendor/rails/activeresource/test/fixtures/beast.rb +14 -0
- data/vendor/rails/activeresource/test/fixtures/person.rb +3 -0
- data/vendor/rails/activeresource/test/fixtures/street_address.rb +4 -0
- data/vendor/rails/activeresource/test/format_test.rb +42 -0
- data/vendor/rails/activeresource/test/setter_trap.rb +27 -0
- data/vendor/rails/activesupport/CHANGELOG +986 -0
- data/vendor/rails/activesupport/MIT-LICENSE +20 -0
- data/vendor/rails/activesupport/README +43 -0
- data/vendor/rails/activesupport/Rakefile +84 -0
- data/vendor/rails/activesupport/install.rb +30 -0
- data/vendor/rails/activesupport/lib/active_support.rb +49 -0
- data/vendor/rails/activesupport/lib/active_support/basic_object.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/buffered_logger.rb +107 -0
- data/vendor/rails/activesupport/lib/active_support/clean_logger.rb +127 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext.rb +4 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/array.rb +13 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/array/access.rb +28 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/array/conversions.rb +94 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/array/extract_options.rb +19 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/array/grouping.rb +68 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/array/random_access.rb +12 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal.rb +2 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb +6 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb +50 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/cgi.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +14 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/class.rb +4 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/class/attribute_accessors.rb +48 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/class/delegating_attributes.rb +40 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb +140 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/class/removal.rb +24 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/date.rb +10 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/date/behavior.rb +13 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/date/calculations.rb +188 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/date/conversions.rb +98 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/date_time.rb +10 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/date_time/calculations.rb +77 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/date_time/conversions.rb +74 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/duplicable.rb +37 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/enumerable.rb +63 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/exception.rb +33 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/file.rb +21 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/float.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/float/rounding.rb +24 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash.rb +13 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +242 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/diff.rb +19 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/except.rb +24 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +102 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/keys.rb +54 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/reverse_merge.rb +25 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/slice.rb +28 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/integer.rb +7 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/integer/even_odd.rb +24 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/integer/inflections.rb +21 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/kernel.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb +11 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/kernel/daemonizing.rb +15 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb +13 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb +51 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/kernel/requires.rb +24 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/load_error.rb +38 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/logger.rb +16 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module.rb +8 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/aliasing.rb +70 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb +31 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/attr_internal.rb +31 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/attribute_accessors.rb +48 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/delegation.rb +62 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/inclusion.rb +11 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb +35 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/loading.rb +13 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb +17 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/numeric.rb +7 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/numeric/bytes.rb +44 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb +91 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/object.rb +4 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/object/conversions.rb +14 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/object/extending.rb +58 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/object/instance_variables.rb +22 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb +59 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/pathname.rb +7 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/pathname/clean_within.rb +14 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/proc.rb +12 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/range.rb +11 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/range/blockless_step.rb +22 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/range/conversions.rb +23 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/range/include_range.rb +22 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/range/overlaps.rb +12 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/string.rb +23 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/access.rb +58 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb +28 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/inflections.rb +153 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/iterators.rb +17 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/starts_ends_with.rb +27 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/unicode.rb +42 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/string/xchar.rb +11 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/symbol.rb +14 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/test.rb +1 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/test/unit/assertions.rb +62 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/time.rb +19 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/time/behavior.rb +13 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb +224 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/time/conversions.rb +94 -0
- data/vendor/rails/activesupport/lib/active_support/dependencies.rb +540 -0
- data/vendor/rails/activesupport/lib/active_support/deprecation.rb +204 -0
- data/vendor/rails/activesupport/lib/active_support/duration.rb +96 -0
- data/vendor/rails/activesupport/lib/active_support/inflections.rb +53 -0
- data/vendor/rails/activesupport/lib/active_support/inflector.rb +282 -0
- data/vendor/rails/activesupport/lib/active_support/json.rb +31 -0
- data/vendor/rails/activesupport/lib/active_support/json/decoding.rb +60 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/date.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/date_time.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/enumerable.rb +12 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/false_class.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/hash.rb +50 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/nil_class.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/numeric.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/object.rb +6 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/regexp.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/string.rb +30 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/symbol.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/time.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoders/true_class.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/json/encoding.rb +38 -0
- data/vendor/rails/activesupport/lib/active_support/json/variable.rb +10 -0
- data/vendor/rails/activesupport/lib/active_support/multibyte.rb +9 -0
- data/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +141 -0
- data/vendor/rails/activesupport/lib/active_support/multibyte/generators/generate_tables.rb +149 -0
- data/vendor/rails/activesupport/lib/active_support/multibyte/handlers/passthru_handler.rb +9 -0
- data/vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler.rb +564 -0
- data/vendor/rails/activesupport/lib/active_support/multibyte/handlers/utf8_handler_proc.rb +43 -0
- data/vendor/rails/activesupport/lib/active_support/option_merger.rb +25 -0
- data/vendor/rails/activesupport/lib/active_support/ordered_options.rb +49 -0
- data/vendor/rails/activesupport/lib/active_support/test_case.rb +5 -0
- data/vendor/rails/activesupport/lib/active_support/testing.rb +1 -0
- data/vendor/rails/activesupport/lib/active_support/testing/default.rb +12 -0
- data/vendor/rails/activesupport/lib/active_support/values/time_zone.rb +181 -0
- data/vendor/rails/activesupport/lib/active_support/values/unicode_tables.dat +0 -0
- data/vendor/rails/activesupport/lib/active_support/vendor.rb +14 -0
- data/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/blankslate.rb +113 -0
- data/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder.rb +13 -0
- data/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/blankslate.rb +20 -0
- data/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb +250 -0
- data/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xchar.rb +115 -0
- data/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlbase.rb +139 -0
- data/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb +63 -0
- data/vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlmarkup.rb +328 -0
- data/vendor/rails/activesupport/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb +1021 -0
- data/vendor/rails/activesupport/lib/active_support/version.rb +9 -0
- data/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +38 -0
- data/vendor/rails/activesupport/lib/activesupport.rb +1 -0
- data/vendor/rails/activesupport/test/abstract_unit.rb +20 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/a/b.rb +2 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/a/c/d.rb +2 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/a/c/e/f.rb +2 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/application.rb +1 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/class_folder.rb +3 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/class_folder/class_folder_subclass.rb +3 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/class_folder/inline_class.rb +2 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/class_folder/nested_class.rb +7 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/conflict.rb +1 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/counting_loader.rb +5 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/cross_site_dependency.rb +2 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/e.rb +2 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/module_folder/inline_class.rb +2 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/module_folder/nested_class.rb +4 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/module_folder/nested_sibling.rb +2 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/module_with_custom_const_missing/a/b.rb +1 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/multiple_constant_file.rb +2 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/raises_name_error.rb +3 -0
- data/vendor/rails/activesupport/test/autoloading_fixtures/raises_no_method_error.rb +3 -0
- data/vendor/rails/activesupport/test/buffered_logger_test.rb +107 -0
- data/vendor/rails/activesupport/test/clean_logger_test.rb +57 -0
- data/vendor/rails/activesupport/test/core_ext/array_ext_test.rb +250 -0
- data/vendor/rails/activesupport/test/core_ext/blank_test.rb +19 -0
- data/vendor/rails/activesupport/test/core_ext/cgi_ext_test.rb +14 -0
- data/vendor/rails/activesupport/test/core_ext/class/attribute_accessor_test.rb +31 -0
- data/vendor/rails/activesupport/test/core_ext/class/class_inheritable_attributes_test.rb +224 -0
- data/vendor/rails/activesupport/test/core_ext/class/delegating_attributes_test.rb +105 -0
- data/vendor/rails/activesupport/test/core_ext/class_test.rb +46 -0
- data/vendor/rails/activesupport/test/core_ext/date_ext_test.rb +196 -0
- data/vendor/rails/activesupport/test/core_ext/date_time_ext_test.rb +230 -0
- data/vendor/rails/activesupport/test/core_ext/duplicable_test.rb +22 -0
- data/vendor/rails/activesupport/test/core_ext/duration_test.rb +21 -0
- data/vendor/rails/activesupport/test/core_ext/enumerable_test.rb +61 -0
- data/vendor/rails/activesupport/test/core_ext/exception_test.rb +64 -0
- data/vendor/rails/activesupport/test/core_ext/file_test.rb +29 -0
- data/vendor/rails/activesupport/test/core_ext/float_ext_test.rb +25 -0
- data/vendor/rails/activesupport/test/core_ext/hash_ext_test.rb +743 -0
- data/vendor/rails/activesupport/test/core_ext/integer_ext_test.rb +37 -0
- data/vendor/rails/activesupport/test/core_ext/kernel_test.rb +43 -0
- data/vendor/rails/activesupport/test/core_ext/load_error_tests.rb +16 -0
- data/vendor/rails/activesupport/test/core_ext/module/attr_accessor_with_default_test.rb +30 -0
- data/vendor/rails/activesupport/test/core_ext/module/attr_internal_test.rb +52 -0
- data/vendor/rails/activesupport/test/core_ext/module/attribute_accessor_test.rb +33 -0
- data/vendor/rails/activesupport/test/core_ext/module/attribute_aliasing_test.rb +58 -0
- data/vendor/rails/activesupport/test/core_ext/module_test.rb +293 -0
- data/vendor/rails/activesupport/test/core_ext/name_error_test.rb +24 -0
- data/vendor/rails/activesupport/test/core_ext/numeric_ext_test.rb +147 -0
- data/vendor/rails/activesupport/test/core_ext/object_and_class_ext_test.rb +242 -0
- data/vendor/rails/activesupport/test/core_ext/pathname_test.rb +9 -0
- data/vendor/rails/activesupport/test/core_ext/proc_test.rb +11 -0
- data/vendor/rails/activesupport/test/core_ext/range_ext_test.rb +63 -0
- data/vendor/rails/activesupport/test/core_ext/string_ext_test.rb +180 -0
- data/vendor/rails/activesupport/test/core_ext/symbol_test.rb +9 -0
- data/vendor/rails/activesupport/test/core_ext/time_ext_test.rb +420 -0
- data/vendor/rails/activesupport/test/dependencies/check_warnings.rb +2 -0
- data/vendor/rails/activesupport/test/dependencies/conflict.rb +1 -0
- data/vendor/rails/activesupport/test/dependencies/cross_site_depender.rb +3 -0
- data/vendor/rails/activesupport/test/dependencies/mutual_one.rb +4 -0
- data/vendor/rails/activesupport/test/dependencies/mutual_two.rb +4 -0
- data/vendor/rails/activesupport/test/dependencies/raises_exception.rb +3 -0
- data/vendor/rails/activesupport/test/dependencies/requires_nonexistent0.rb +1 -0
- data/vendor/rails/activesupport/test/dependencies/requires_nonexistent1.rb +1 -0
- data/vendor/rails/activesupport/test/dependencies/service_one.rb +5 -0
- data/vendor/rails/activesupport/test/dependencies/service_two.rb +2 -0
- data/vendor/rails/activesupport/test/dependencies_test.rb +751 -0
- data/vendor/rails/activesupport/test/deprecation_test.rb +151 -0
- data/vendor/rails/activesupport/test/inflector_test.rb +248 -0
- data/vendor/rails/activesupport/test/inflector_test_cases.rb +208 -0
- data/vendor/rails/activesupport/test/json/decoding_test.rb +41 -0
- data/vendor/rails/activesupport/test/json/encoding_test.rb +111 -0
- data/vendor/rails/activesupport/test/multibyte_chars_test.rb +173 -0
- data/vendor/rails/activesupport/test/multibyte_conformance.rb +141 -0
- data/vendor/rails/activesupport/test/multibyte_handler_test.rb +367 -0
- data/vendor/rails/activesupport/test/option_merger_test.rb +50 -0
- data/vendor/rails/activesupport/test/ordered_options_test.rb +84 -0
- data/vendor/rails/activesupport/test/test_test.rb +73 -0
- data/vendor/rails/activesupport/test/time_zone_test.rb +98 -0
- data/vendor/rails/activesupport/test/whiny_nil_test.rb +38 -0
- data/vendor/rails/railties/CHANGELOG +1899 -0
- data/vendor/rails/railties/MIT-LICENSE +20 -0
- data/vendor/rails/railties/README +203 -0
- data/vendor/rails/railties/Rakefile +358 -0
- data/vendor/rails/railties/bin/about +3 -0
- data/vendor/rails/railties/bin/console +3 -0
- data/vendor/rails/railties/bin/destroy +3 -0
- data/vendor/rails/railties/bin/generate +3 -0
- data/{starter-app/vendor/plugins/spree/script → vendor/rails/railties/bin}/performance/benchmarker +0 -0
- data/{starter-app/vendor/plugins/spree/script → vendor/rails/railties/bin}/performance/profiler +0 -0
- data/vendor/rails/railties/bin/performance/request +3 -0
- data/vendor/rails/railties/bin/plugin +3 -0
- data/{starter-app/vendor/plugins/spree/script → vendor/rails/railties/bin}/process/inspector +0 -0
- data/{starter-app/vendor/plugins/spree/script → vendor/rails/railties/bin}/process/reaper +0 -0
- data/{starter-app/vendor/plugins/spree/script → vendor/rails/railties/bin}/process/spawner +0 -0
- data/vendor/rails/railties/bin/rails +19 -0
- data/vendor/rails/railties/bin/runner +3 -0
- data/vendor/rails/railties/bin/server +3 -0
- data/vendor/rails/railties/builtin/rails_info/rails/info.rb +123 -0
- data/vendor/rails/railties/builtin/rails_info/rails/info_controller.rb +9 -0
- data/vendor/rails/railties/builtin/rails_info/rails/info_helper.rb +2 -0
- data/vendor/rails/railties/builtin/rails_info/rails_info_controller.rb +2 -0
- data/vendor/rails/railties/configs/apache.conf +40 -0
- data/vendor/rails/railties/configs/databases/frontbase.yml +28 -0
- data/vendor/rails/railties/configs/databases/mysql.yml +54 -0
- data/vendor/rails/railties/configs/databases/oracle.yml +39 -0
- data/vendor/rails/railties/configs/databases/postgresql.yml +48 -0
- data/vendor/rails/railties/configs/databases/sqlite2.yml +16 -0
- data/vendor/rails/railties/configs/databases/sqlite3.yml +19 -0
- data/vendor/rails/railties/configs/empty.log +0 -0
- data/vendor/rails/railties/configs/initializers/inflections.rb +10 -0
- data/vendor/rails/railties/configs/initializers/mime_types.rb +5 -0
- data/vendor/rails/railties/configs/lighttpd.conf +54 -0
- data/vendor/rails/railties/configs/routes.rb +35 -0
- data/vendor/rails/railties/dispatches/dispatch.fcgi +24 -0
- data/vendor/rails/railties/dispatches/dispatch.rb +10 -0
- data/vendor/rails/railties/dispatches/gateway.cgi +97 -0
- data/vendor/rails/railties/doc/README_FOR_APP +2 -0
- data/vendor/rails/railties/environments/boot.rb +109 -0
- data/vendor/rails/railties/environments/development.rb +18 -0
- data/vendor/rails/railties/environments/environment.rb +59 -0
- data/vendor/rails/railties/environments/production.rb +19 -0
- data/vendor/rails/railties/environments/test.rb +22 -0
- data/{starter-app/vendor/plugins/paginating_find/test_app/Rakefile → vendor/rails/railties/fresh_rakefile} +0 -0
- data/vendor/rails/railties/helpers/application.rb +10 -0
- data/{starter-app/app → vendor/rails/railties}/helpers/application_helper.rb +0 -0
- data/vendor/rails/railties/helpers/test_helper.rb +38 -0
- data/vendor/rails/railties/html/404.html +30 -0
- data/vendor/rails/railties/html/422.html +30 -0
- data/vendor/rails/railties/html/500.html +30 -0
- data/vendor/rails/railties/html/favicon.ico +0 -0
- data/vendor/rails/railties/html/images/rails.png +0 -0
- data/vendor/rails/railties/html/index.html +277 -0
- data/vendor/rails/railties/html/javascripts/application.js +2 -0
- data/vendor/rails/railties/html/javascripts/controls.js +963 -0
- data/vendor/rails/railties/html/javascripts/dragdrop.js +972 -0
- data/vendor/rails/railties/html/javascripts/effects.js +1120 -0
- data/vendor/rails/railties/html/javascripts/prototype.js +4225 -0
- data/vendor/rails/railties/html/robots.txt +5 -0
- data/vendor/rails/railties/lib/code_statistics.rb +107 -0
- data/vendor/rails/railties/lib/commands.rb +17 -0
- data/vendor/rails/railties/lib/commands/about.rb +2 -0
- data/vendor/rails/railties/lib/commands/console.rb +32 -0
- data/vendor/rails/railties/lib/commands/destroy.rb +6 -0
- data/vendor/rails/railties/lib/commands/generate.rb +6 -0
- data/vendor/rails/railties/lib/commands/ncgi/listener +86 -0
- data/vendor/rails/railties/lib/commands/ncgi/tracker +69 -0
- data/vendor/rails/railties/lib/commands/performance/benchmarker.rb +24 -0
- data/vendor/rails/railties/lib/commands/performance/profiler.rb +50 -0
- data/vendor/rails/railties/lib/commands/performance/request.rb +6 -0
- data/vendor/rails/railties/lib/commands/plugin.rb +923 -0
- data/vendor/rails/railties/lib/commands/process/inspector.rb +68 -0
- data/vendor/rails/railties/lib/commands/process/reaper.rb +149 -0
- data/vendor/rails/railties/lib/commands/process/spawner.rb +219 -0
- data/vendor/rails/railties/lib/commands/process/spinner.rb +57 -0
- data/vendor/rails/railties/lib/commands/runner.rb +48 -0
- data/vendor/rails/railties/lib/commands/server.rb +39 -0
- data/vendor/rails/railties/lib/commands/servers/base.rb +31 -0
- data/vendor/rails/railties/lib/commands/servers/lighttpd.rb +94 -0
- data/vendor/rails/railties/lib/commands/servers/mongrel.rb +69 -0
- data/vendor/rails/railties/lib/commands/servers/webrick.rb +66 -0
- data/vendor/rails/railties/lib/commands/update.rb +4 -0
- data/vendor/rails/railties/lib/console_app.rb +30 -0
- data/vendor/rails/railties/lib/console_sandbox.rb +6 -0
- data/vendor/rails/railties/lib/console_with_helpers.rb +26 -0
- data/vendor/rails/railties/lib/dispatcher.rb +24 -0
- data/vendor/rails/railties/lib/fcgi_handler.rb +223 -0
- data/vendor/rails/railties/lib/initializer.rb +682 -0
- data/vendor/rails/railties/lib/rails/plugin.rb +84 -0
- data/vendor/rails/railties/lib/rails/plugin/loader.rb +150 -0
- data/vendor/rails/railties/lib/rails/plugin/locator.rb +78 -0
- data/vendor/rails/railties/lib/rails/version.rb +9 -0
- data/vendor/rails/railties/lib/rails_generator.rb +43 -0
- data/vendor/rails/railties/lib/rails_generator/base.rb +263 -0
- data/vendor/rails/railties/lib/rails_generator/commands.rb +591 -0
- data/vendor/rails/railties/lib/rails_generator/generated_attribute.rb +42 -0
- data/vendor/rails/railties/lib/rails_generator/generators/applications/app/USAGE +9 -0
- data/vendor/rails/railties/lib/rails_generator/generators/applications/app/app_generator.rb +179 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/controller/USAGE +29 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/controller/controller_generator.rb +37 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/controller.rb +10 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/functional_test.rb +8 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/helper.rb +2 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/controller/templates/view.html.erb +2 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/USAGE +8 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/integration_test_generator.rb +16 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/integration_test/templates/integration_test.rb +10 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/mailer/USAGE +16 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/mailer/mailer_generator.rb +34 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.erb +3 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/fixture.rhtml +0 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/mailer.rb +13 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/unit_test.rb +21 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.erb +3 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/mailer/templates/view.rhtml +0 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/migration/USAGE +29 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/migration/migration_generator.rb +20 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/migration/templates/migration.rb +11 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/model/USAGE +27 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/model/model_generator.rb +45 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/fixtures.yml +19 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/migration.rb +16 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/model.rb +2 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/model/templates/unit_test.rb +8 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/observer/USAGE +13 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/observer/observer_generator.rb +16 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/observer.rb +2 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/observer/templates/unit_test.rb +8 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/USAGE +25 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/plugin_generator.rb +39 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/MIT-LICENSE +20 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/README +13 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/Rakefile +22 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/USAGE +8 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/generator.rb +8 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/init.rb +1 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/install.rb +1 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/plugin.rb +1 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/tasks.rake +4 -0
- data/{starter-app/vendor/plugins/spree → vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates}/uninstall.rb +0 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/plugin/templates/unit_test.rb +8 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/resource/USAGE +23 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/resource/resource_generator.rb +74 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/controller.rb +2 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/functional_test.rb +8 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/resource/templates/helper.rb +2 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/USAGE +25 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +92 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/controller.rb +85 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +45 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/helper.rb +2 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +17 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/style.css +74 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +19 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +24 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +18 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +10 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/USAGE +10 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/session_migration_generator.rb +18 -0
- data/vendor/rails/railties/lib/rails_generator/generators/components/session_migration/templates/migration.rb +16 -0
- data/vendor/rails/railties/lib/rails_generator/lookup.rb +244 -0
- data/vendor/rails/railties/lib/rails_generator/manifest.rb +53 -0
- data/vendor/rails/railties/lib/rails_generator/options.rb +143 -0
- data/vendor/rails/railties/lib/rails_generator/scripts.rb +86 -0
- data/vendor/rails/railties/lib/rails_generator/scripts/destroy.rb +30 -0
- data/vendor/rails/railties/lib/rails_generator/scripts/generate.rb +7 -0
- data/vendor/rails/railties/lib/rails_generator/scripts/update.rb +12 -0
- data/vendor/rails/railties/lib/rails_generator/secret_key_generator.rb +160 -0
- data/vendor/rails/railties/lib/rails_generator/simple_logger.rb +46 -0
- data/vendor/rails/railties/lib/rails_generator/spec.rb +44 -0
- data/vendor/rails/railties/lib/railties_path.rb +1 -0
- data/vendor/rails/railties/lib/ruby_version_check.rb +17 -0
- data/vendor/rails/railties/lib/rubyprof_ext.rb +35 -0
- data/vendor/rails/railties/lib/source_annotation_extractor.rb +62 -0
- data/vendor/rails/railties/lib/tasks/annotations.rake +23 -0
- data/vendor/rails/railties/lib/tasks/databases.rake +363 -0
- data/vendor/rails/railties/lib/tasks/documentation.rake +80 -0
- data/vendor/rails/railties/lib/tasks/framework.rake +118 -0
- data/vendor/rails/railties/lib/tasks/log.rake +9 -0
- data/vendor/rails/railties/lib/tasks/misc.rake +10 -0
- data/vendor/rails/railties/lib/tasks/rails.rb +8 -0
- data/vendor/rails/railties/lib/tasks/routes.rake +17 -0
- data/vendor/rails/railties/lib/tasks/statistics.rake +18 -0
- data/vendor/rails/railties/lib/tasks/testing.rake +118 -0
- data/vendor/rails/railties/lib/tasks/tmp.rake +37 -0
- data/vendor/rails/railties/lib/test_help.rb +20 -0
- data/vendor/rails/railties/lib/webrick_server.rb +165 -0
- data/vendor/rails/railties/test/abstract_unit.rb +24 -0
- data/vendor/rails/railties/test/boot_test.rb +179 -0
- data/vendor/rails/railties/test/console_app_test.rb +29 -0
- data/vendor/rails/railties/test/fcgi_dispatcher_test.rb +265 -0
- data/vendor/rails/railties/test/fixtures/environment_with_constant.rb +1 -0
- data/vendor/rails/railties/test/fixtures/lib/generators/missing_class/missing_class_generator.rb +0 -0
- data/vendor/rails/railties/test/fixtures/lib/generators/working/working_generator.rb +2 -0
- data/vendor/rails/railties/test/fixtures/plugins/default/plugin_with_no_lib_dir/init.rb +0 -0
- data/vendor/rails/railties/test/fixtures/plugins/default/stubby/init.rb +7 -0
- data/vendor/rails/railties/test/fixtures/plugins/default/stubby/lib/stubby_mixin.rb +2 -0
- data/vendor/rails/railties/test/generators/generator_test_helper.rb +195 -0
- data/vendor/rails/railties/test/generators/rails_model_generator_test.rb +109 -0
- data/vendor/rails/railties/test/generators/rails_resource_generator_test.rb +106 -0
- data/vendor/rails/railties/test/generators/rails_scaffold_generator_test.rb +185 -0
- data/vendor/rails/railties/test/initializer_test.rb +218 -0
- data/vendor/rails/railties/test/mocks/routes.rb +6 -0
- data/vendor/rails/railties/test/plugin_loader_test.rb +140 -0
- data/vendor/rails/railties/test/plugin_locator_test.rb +69 -0
- data/vendor/rails/railties/test/plugin_test.rb +141 -0
- data/vendor/rails/railties/test/plugin_test_helper.rb +29 -0
- data/vendor/rails/railties/test/rails_generator_test.rb +137 -0
- data/vendor/rails/railties/test/rails_info_controller_test.rb +48 -0
- data/vendor/rails/railties/test/rails_info_test.rb +105 -0
- data/vendor/rails/railties/test/secret_key_generation_test.rb +35 -0
- metadata +2304 -693
- data/History.txt +0 -40
- data/License.txt +0 -26
- data/Manifest.txt +0 -671
- data/config/hoe.rb +0 -80
- data/config/requirements.rb +0 -15
- data/lib/spree/version.rb +0 -9
- data/script/txt2html +0 -74
- data/setup.rb +0 -1585
- data/starter-app/README +0 -182
- data/starter-app/app/controllers/application.rb +0 -14
- data/starter-app/app/models/tag.rb +0 -37
- data/starter-app/app/models/tagging.rb +0 -16
- data/starter-app/app/views/layouts/application.rhtml +0 -48
- data/starter-app/config/boot.rb +0 -45
- data/starter-app/config/environment.rb +0 -140
- data/starter-app/config/environments/development.rb +0 -21
- data/starter-app/config/routes.rb +0 -28
- data/starter-app/db/migrate/003_create_tags_and_taggings.rb +0 -28
- data/starter-app/db/migrate/004_spree_to_version_21.rb +0 -9
- data/starter-app/db/sample/credit_cards.yml +0 -12
- data/starter-app/db/sample/images.yml +0 -252
- data/starter-app/db/sample/line_items.yml +0 -25
- data/starter-app/db/sample/orders.yml +0 -15
- data/starter-app/db/sample/skus.yml +0 -28
- data/starter-app/db/sample/taggings.yml +0 -16
- data/starter-app/db/sample/tags.yml +0 -6
- data/starter-app/db/sample/variants.yml +0 -47
- data/starter-app/doc/README_FOR_APP +0 -2
- data/starter-app/lib/tagging_extensions.rb +0 -104
- data/starter-app/public/index.html +0 -277
- data/starter-app/public/stylesheets/cart/_controller.css +0 -4
- data/starter-app/script/destroy +0 -3
- data/starter-app/script/generate +0 -3
- data/starter-app/spec/models/product_spec.rb +0 -29
- data/starter-app/test/fixtures/users.yml +0 -7
- data/starter-app/test/test_helper.rb +0 -28
- data/starter-app/test/unit/user_test.rb +0 -8
- data/starter-app/vendor/plugins/engines/CHANGELOG +0 -258
- data/starter-app/vendor/plugins/engines/MIT-LICENSE +0 -21
- data/starter-app/vendor/plugins/engines/README +0 -63
- data/starter-app/vendor/plugins/engines/Rakefile +0 -32
- data/starter-app/vendor/plugins/engines/about.yml +0 -7
- data/starter-app/vendor/plugins/engines/boot.rb +0 -18
- data/starter-app/vendor/plugins/engines/generators/plugin_migration/USAGE +0 -45
- data/starter-app/vendor/plugins/engines/generators/plugin_migration/plugin_migration_generator.rb +0 -79
- data/starter-app/vendor/plugins/engines/generators/plugin_migration/templates/plugin_migration.erb +0 -13
- data/starter-app/vendor/plugins/engines/init.rb +0 -2
- data/starter-app/vendor/plugins/engines/lib/engines.rb +0 -169
- data/starter-app/vendor/plugins/engines/lib/engines/assets.rb +0 -38
- data/starter-app/vendor/plugins/engines/lib/engines/plugin.rb +0 -125
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/list.rb +0 -30
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/loader.rb +0 -18
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/locator.rb +0 -11
- data/starter-app/vendor/plugins/engines/lib/engines/plugin/migrator.rb +0 -60
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/action_mailer.rb +0 -85
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/active_record.rb +0 -24
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/asset_helpers.rb +0 -119
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/dependencies.rb +0 -145
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/migrations.rb +0 -161
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/rails.rb +0 -11
- data/starter-app/vendor/plugins/engines/lib/engines/rails_extensions/routing.rb +0 -84
- data/starter-app/vendor/plugins/engines/lib/engines/testing.rb +0 -87
- data/starter-app/vendor/plugins/engines/tasks/engines.rake +0 -176
- data/starter-app/vendor/plugins/paginating_find/test_app/db/schema.rb +0 -16
- data/starter-app/vendor/plugins/spree/.rakeTasks +0 -7
- data/starter-app/vendor/plugins/spree/CHANGELOG +0 -1
- data/starter-app/vendor/plugins/spree/README +0 -1
- data/starter-app/vendor/plugins/spree/Rakefile +0 -10
- data/starter-app/vendor/plugins/spree/VERSION +0 -1
- data/starter-app/vendor/plugins/spree/app/controllers/admin/orders_controller.rb +0 -247
- data/starter-app/vendor/plugins/spree/app/controllers/admin/products_controller.rb +0 -207
- data/starter-app/vendor/plugins/spree/app/controllers/cart_controller.rb +0 -39
- data/starter-app/vendor/plugins/spree/app/controllers/checkout_controller.rb +0 -184
- data/starter-app/vendor/plugins/spree/app/controllers/spree/base_controller.rb +0 -47
- data/starter-app/vendor/plugins/spree/app/helpers/checkout_helper.rb +0 -17
- data/starter-app/vendor/plugins/spree/app/helpers/spree/base_helper.rb +0 -101
- data/starter-app/vendor/plugins/spree/app/models/cart_item.rb +0 -26
- data/starter-app/vendor/plugins/spree/app/models/image.rb +0 -12
- data/starter-app/vendor/plugins/spree/app/models/order.rb +0 -87
- data/starter-app/vendor/plugins/spree/app/models/product.rb +0 -58
- data/starter-app/vendor/plugins/spree/app/models/sku.rb +0 -7
- data/starter-app/vendor/plugins/spree/app/models/variant.rb +0 -5
- data/starter-app/vendor/plugins/spree/app/views/admin/products/_form.rhtml +0 -65
- data/starter-app/vendor/plugins/spree/app/views/admin/products/_option_types.rhtml +0 -42
- data/starter-app/vendor/plugins/spree/app/views/admin/products/_variants.rhtml +0 -43
- data/starter-app/vendor/plugins/spree/app/views/admin/products/index.rhtml +0 -65
- data/starter-app/vendor/plugins/spree/app/views/cart/index.rhtml +0 -49
- data/starter-app/vendor/plugins/spree/app/views/layouts/admin.rhtml +0 -69
- data/starter-app/vendor/plugins/spree/app/views/layouts/products.rhtml +0 -20
- data/starter-app/vendor/plugins/spree/app/views/order_mailer/cancel.rhtml +0 -15
- data/starter-app/vendor/plugins/spree/app/views/order_mailer/confirm.rhtml +0 -18
- data/starter-app/vendor/plugins/spree/app/views/store/list.rhtml +0 -15
- data/starter-app/vendor/plugins/spree/app/views/store/show.rhtml +0 -70
- data/starter-app/vendor/plugins/spree/assets/.htaccess +0 -40
- data/starter-app/vendor/plugins/spree/assets/stylesheets/spree-admin.css +0 -348
- data/starter-app/vendor/plugins/spree/db/migrate/008_create_orders.rb +0 -24
- data/starter-app/vendor/plugins/spree/db/migrate/009_create_products.rb +0 -20
- data/starter-app/vendor/plugins/spree/db/migrate/011_create_variants.rb +0 -11
- data/starter-app/vendor/plugins/spree/db/migrate/013_create_skus.rb +0 -13
- data/starter-app/vendor/plugins/spree/db/migrate/019_create_images.rb +0 -19
- data/starter-app/vendor/plugins/spree/init.rb +0 -11
- data/starter-app/vendor/plugins/spree/install.rb +0 -3
- data/starter-app/vendor/plugins/spree/lib/constants/enumerable_constants.rb +0 -207
- data/starter-app/vendor/plugins/spree/lib/tasks/spree_bootstrap.rake +0 -24
- data/starter-app/vendor/plugins/spree/lib/tax/sales_tax.rb +0 -26
- data/starter-app/vendor/plugins/spree/routes.rb +0 -3
- data/starter-app/vendor/plugins/spree/script/about +0 -3
- data/starter-app/vendor/plugins/spree/script/breakpointer +0 -3
- data/starter-app/vendor/plugins/spree/script/console +0 -3
- data/starter-app/vendor/plugins/spree/script/destroy +0 -3
- data/starter-app/vendor/plugins/spree/script/generate +0 -3
- data/starter-app/vendor/plugins/spree/script/plugin +0 -3
- data/starter-app/vendor/plugins/spree/script/runner +0 -3
- data/starter-app/vendor/plugins/spree/script/server +0 -3
- data/starter-app/vendor/plugins/spree/test/fixtures/addresses.yml +0 -29
- data/starter-app/vendor/plugins/spree/test/fixtures/categories.yml +0 -40
- data/starter-app/vendor/plugins/spree/test/fixtures/line_items.yml +0 -32
- data/starter-app/vendor/plugins/spree/test/fixtures/orders.yml +0 -17
- data/starter-app/vendor/plugins/spree/test/fixtures/products.yml +0 -63
- data/starter-app/vendor/plugins/spree/test/fixtures/products_tags.yml +0 -10
- data/starter-app/vendor/plugins/spree/test/fixtures/roles.yml +0 -6
- data/starter-app/vendor/plugins/spree/test/fixtures/roles_users.yml +0 -3
- data/starter-app/vendor/plugins/spree/test/fixtures/skus.yml +0 -5
- data/starter-app/vendor/plugins/spree/test/fixtures/tags.yml +0 -7
- data/starter-app/vendor/plugins/spree/test/fixtures/tax_treatments.yml +0 -7
- data/starter-app/vendor/plugins/spree/test/fixtures/txns.yml +0 -13
- data/starter-app/vendor/plugins/spree/test/fixtures/users.yml +0 -40
- data/starter-app/vendor/plugins/spree/test/fixtures/variations.yml +0 -16
- data/starter-app/vendor/plugins/spree/test/functional/account_controller_test.rb +0 -129
- data/starter-app/vendor/plugins/spree/test/functional/admin/base_controller_test.rb +0 -18
- data/starter-app/vendor/plugins/spree/test/functional/admin/option_groups_controller_test.rb +0 -18
- data/starter-app/vendor/plugins/spree/test/functional/admin/option_values_controller_test.rb +0 -18
- data/starter-app/vendor/plugins/spree/test/functional/admin/orders_controller_test.rb +0 -18
- data/starter-app/vendor/plugins/spree/test/functional/admin/overview_controller_test.rb +0 -18
- data/starter-app/vendor/plugins/spree/test/functional/admin/products_controller_test.rb +0 -125
- data/starter-app/vendor/plugins/spree/test/functional/admin/users_controller_test.rb +0 -58
- data/starter-app/vendor/plugins/spree/test/functional/application_controller_test.rb +0 -30
- data/starter-app/vendor/plugins/spree/test/functional/cart_controller_test.rb +0 -76
- data/starter-app/vendor/plugins/spree/test/functional/checkout_controller_test.rb +0 -20
- data/starter-app/vendor/plugins/spree/test/integration/authentication_test.rb +0 -53
- data/starter-app/vendor/plugins/spree/test/integration/product_admin_test.rb +0 -135
- data/starter-app/vendor/plugins/spree/test/integration/user_stories_test.rb +0 -59
- data/starter-app/vendor/plugins/spree/test/test_helper.rb +0 -45
- data/starter-app/vendor/plugins/spree/test/unit/address_test.rb +0 -10
- data/starter-app/vendor/plugins/spree/test/unit/category_test.rb +0 -52
- data/starter-app/vendor/plugins/spree/test/unit/option_group_test.rb +0 -12
- data/starter-app/vendor/plugins/spree/test/unit/order_test.rb +0 -49
- data/starter-app/vendor/plugins/spree/test/unit/product_test.rb +0 -74
- data/starter-app/vendor/plugins/spree/test/unit/role_test.rb +0 -10
- data/starter-app/vendor/plugins/spree/test/unit/sales_tax_test.rb +0 -46
- data/starter-app/vendor/plugins/spree/test/unit/sku_test.rb +0 -10
- data/starter-app/vendor/plugins/spree/test/unit/tag_test.rb +0 -9
- data/starter-app/vendor/plugins/spree/test/unit/tax_treatment_test.rb +0 -10
- data/starter-app/vendor/plugins/spree/test/unit/txn_test.rb +0 -10
- data/tasks/deployment.rake +0 -34
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/test/test_helper.rb +0 -2
- data/test/test_railscart.rb +0 -11
@@ -0,0 +1,96 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module Associations
|
3
|
+
class HasOneAssociation < BelongsToAssociation #:nodoc:
|
4
|
+
def initialize(owner, reflection)
|
5
|
+
super
|
6
|
+
construct_sql
|
7
|
+
end
|
8
|
+
|
9
|
+
def create(attrs = {}, replace_existing = true)
|
10
|
+
new_record(replace_existing) { |klass| klass.create(attrs) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def create!(attrs = {}, replace_existing = true)
|
14
|
+
new_record(replace_existing) { |klass| klass.create!(attrs) }
|
15
|
+
end
|
16
|
+
|
17
|
+
def build(attrs = {}, replace_existing = true)
|
18
|
+
new_record(replace_existing) { |klass| klass.new(attrs) }
|
19
|
+
end
|
20
|
+
|
21
|
+
def replace(obj, dont_save = false)
|
22
|
+
load_target
|
23
|
+
|
24
|
+
unless @target.nil?
|
25
|
+
if dependent? && !dont_save && @target != obj
|
26
|
+
@target.destroy unless @target.new_record?
|
27
|
+
@owner.clear_association_cache
|
28
|
+
else
|
29
|
+
@target[@reflection.primary_key_name] = nil
|
30
|
+
@target.save unless @owner.new_record? || @target.new_record?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if obj.nil?
|
35
|
+
@target = nil
|
36
|
+
else
|
37
|
+
raise_on_type_mismatch(obj)
|
38
|
+
set_belongs_to_association_for(obj)
|
39
|
+
@target = (AssociationProxy === obj ? obj.target : obj)
|
40
|
+
end
|
41
|
+
|
42
|
+
@loaded = true
|
43
|
+
|
44
|
+
unless @owner.new_record? or obj.nil? or dont_save
|
45
|
+
return (obj.save ? self : false)
|
46
|
+
else
|
47
|
+
return (obj.nil? ? nil : self)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def find_target
|
53
|
+
@reflection.klass.find(:first,
|
54
|
+
:conditions => @finder_sql,
|
55
|
+
:order => @reflection.options[:order],
|
56
|
+
:include => @reflection.options[:include]
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
def construct_sql
|
61
|
+
case
|
62
|
+
when @reflection.options[:as]
|
63
|
+
@finder_sql =
|
64
|
+
"#{@reflection.klass.table_name}.#{@reflection.options[:as]}_id = #{@owner.quoted_id} AND " +
|
65
|
+
"#{@reflection.klass.table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}"
|
66
|
+
else
|
67
|
+
@finder_sql = "#{@reflection.table_name}.#{@reflection.primary_key_name} = #{@owner.quoted_id}"
|
68
|
+
end
|
69
|
+
@finder_sql << " AND (#{conditions})" if conditions
|
70
|
+
end
|
71
|
+
|
72
|
+
def construct_scope
|
73
|
+
create_scoping = {}
|
74
|
+
set_belongs_to_association_for(create_scoping)
|
75
|
+
{ :create => create_scoping }
|
76
|
+
end
|
77
|
+
|
78
|
+
def new_record(replace_existing)
|
79
|
+
# Make sure we load the target first, if we plan on replacing the existing
|
80
|
+
# instance. Otherwise, if the target has not previously been loaded
|
81
|
+
# elsewhere, the instance we create will get orphaned.
|
82
|
+
load_target if replace_existing
|
83
|
+
record = @reflection.klass.send(:with_scope, :create => construct_scope[:create]) { yield @reflection.klass }
|
84
|
+
|
85
|
+
if replace_existing
|
86
|
+
replace(record, true)
|
87
|
+
else
|
88
|
+
record[@reflection.primary_key_name] = @owner.id unless @owner.new_record?
|
89
|
+
self.target = record
|
90
|
+
end
|
91
|
+
|
92
|
+
record
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,328 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
module AttributeMethods #:nodoc:
|
3
|
+
DEFAULT_SUFFIXES = %w(= ? _before_type_cast)
|
4
|
+
ATTRIBUTE_TYPES_CACHED_BY_DEFAULT = [:datetime, :timestamp, :time, :date]
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.extend ClassMethods
|
8
|
+
base.attribute_method_suffix *DEFAULT_SUFFIXES
|
9
|
+
base.cattr_accessor :attribute_types_cached_by_default, :instance_writer => false
|
10
|
+
base.attribute_types_cached_by_default = ATTRIBUTE_TYPES_CACHED_BY_DEFAULT
|
11
|
+
end
|
12
|
+
|
13
|
+
# Declare and check for suffixed attribute methods.
|
14
|
+
module ClassMethods
|
15
|
+
# Declare a method available for all attributes with the given suffix.
|
16
|
+
# Uses method_missing and respond_to? to rewrite the method
|
17
|
+
# #{attr}#{suffix}(*args, &block)
|
18
|
+
# to
|
19
|
+
# attribute#{suffix}(#{attr}, *args, &block)
|
20
|
+
#
|
21
|
+
# An attribute#{suffix} instance method must exist and accept at least
|
22
|
+
# the attr argument.
|
23
|
+
#
|
24
|
+
# For example:
|
25
|
+
# class Person < ActiveRecord::Base
|
26
|
+
# attribute_method_suffix '_changed?'
|
27
|
+
#
|
28
|
+
# private
|
29
|
+
# def attribute_changed?(attr)
|
30
|
+
# ...
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# person = Person.find(1)
|
35
|
+
# person.name_changed? # => false
|
36
|
+
# person.name = 'Hubert'
|
37
|
+
# person.name_changed? # => true
|
38
|
+
def attribute_method_suffix(*suffixes)
|
39
|
+
attribute_method_suffixes.concat suffixes
|
40
|
+
rebuild_attribute_method_regexp
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns MatchData if method_name is an attribute method.
|
44
|
+
def match_attribute_method?(method_name)
|
45
|
+
rebuild_attribute_method_regexp unless defined?(@@attribute_method_regexp) && @@attribute_method_regexp
|
46
|
+
@@attribute_method_regexp.match(method_name)
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
# Contains the names of the generated attribute methods.
|
51
|
+
def generated_methods #:nodoc:
|
52
|
+
@generated_methods ||= Set.new
|
53
|
+
end
|
54
|
+
|
55
|
+
def generated_methods?
|
56
|
+
!generated_methods.empty?
|
57
|
+
end
|
58
|
+
|
59
|
+
# generates all the attribute related methods for columns in the database
|
60
|
+
# accessors, mutators and query methods
|
61
|
+
def define_attribute_methods
|
62
|
+
return if generated_methods?
|
63
|
+
columns_hash.each do |name, column|
|
64
|
+
unless instance_method_already_implemented?(name)
|
65
|
+
if self.serialized_attributes[name]
|
66
|
+
define_read_method_for_serialized_attribute(name)
|
67
|
+
else
|
68
|
+
define_read_method(name.to_sym, name, column)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
unless instance_method_already_implemented?("#{name}=")
|
73
|
+
define_write_method(name.to_sym)
|
74
|
+
end
|
75
|
+
|
76
|
+
unless instance_method_already_implemented?("#{name}?")
|
77
|
+
define_question_method(name)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Check to see if the method is defined in the model or any of its subclasses that also derive from ActiveRecord.
|
83
|
+
# Raise DangerousAttributeError if the method is defined by ActiveRecord though.
|
84
|
+
def instance_method_already_implemented?(method_name)
|
85
|
+
return true if method_name =~ /^id(=$|\?$|$)/
|
86
|
+
@_defined_class_methods ||= Set.new(ancestors.first(ancestors.index(ActiveRecord::Base)).collect! { |m| m.public_instance_methods(false) | m.private_instance_methods(false) | m.protected_instance_methods(false) }.flatten)
|
87
|
+
@@_defined_activerecord_methods ||= Set.new(ActiveRecord::Base.public_instance_methods(false) | ActiveRecord::Base.private_instance_methods(false) | ActiveRecord::Base.protected_instance_methods(false))
|
88
|
+
raise DangerousAttributeError, "#{method_name} is defined by ActiveRecord" if @@_defined_activerecord_methods.include?(method_name)
|
89
|
+
@_defined_class_methods.include?(method_name)
|
90
|
+
end
|
91
|
+
|
92
|
+
alias :define_read_methods :define_attribute_methods
|
93
|
+
|
94
|
+
# +cache_attributes+ allows you to declare which converted attribute values should
|
95
|
+
# be cached. Usually caching only pays off for attributes with expensive conversion
|
96
|
+
# methods, like date columns (e.g. created_at, updated_at).
|
97
|
+
def cache_attributes(*attribute_names)
|
98
|
+
attribute_names.each {|attr| cached_attributes << attr.to_s}
|
99
|
+
end
|
100
|
+
|
101
|
+
# returns the attributes where
|
102
|
+
def cached_attributes
|
103
|
+
@cached_attributes ||=
|
104
|
+
columns.select{|c| attribute_types_cached_by_default.include?(c.type)}.map(&:name).to_set
|
105
|
+
end
|
106
|
+
|
107
|
+
def cache_attribute?(attr_name)
|
108
|
+
cached_attributes.include?(attr_name)
|
109
|
+
end
|
110
|
+
|
111
|
+
private
|
112
|
+
# Suffixes a, ?, c become regexp /(a|\?|c)$/
|
113
|
+
def rebuild_attribute_method_regexp
|
114
|
+
suffixes = attribute_method_suffixes.map { |s| Regexp.escape(s) }
|
115
|
+
@@attribute_method_regexp = /(#{suffixes.join('|')})$/.freeze
|
116
|
+
end
|
117
|
+
|
118
|
+
# Default to =, ?, _before_type_cast
|
119
|
+
def attribute_method_suffixes
|
120
|
+
@@attribute_method_suffixes ||= []
|
121
|
+
end
|
122
|
+
|
123
|
+
# Define an attribute reader method. Cope with nil column.
|
124
|
+
def define_read_method(symbol, attr_name, column)
|
125
|
+
cast_code = column.type_cast_code('v') if column
|
126
|
+
access_code = cast_code ? "(v=@attributes['#{attr_name}']) && #{cast_code}" : "@attributes['#{attr_name}']"
|
127
|
+
|
128
|
+
unless attr_name.to_s == self.primary_key.to_s
|
129
|
+
access_code = access_code.insert(0, "missing_attribute('#{attr_name}', caller) unless @attributes.has_key?('#{attr_name}'); ")
|
130
|
+
end
|
131
|
+
|
132
|
+
if cache_attribute?(attr_name)
|
133
|
+
access_code = "@attributes_cache['#{attr_name}'] ||= (#{access_code})"
|
134
|
+
end
|
135
|
+
evaluate_attribute_method attr_name, "def #{symbol}; #{access_code}; end"
|
136
|
+
end
|
137
|
+
|
138
|
+
# Define read method for serialized attribute.
|
139
|
+
def define_read_method_for_serialized_attribute(attr_name)
|
140
|
+
evaluate_attribute_method attr_name, "def #{attr_name}; unserialize_attribute('#{attr_name}'); end"
|
141
|
+
end
|
142
|
+
|
143
|
+
# Define an attribute ? method.
|
144
|
+
def define_question_method(attr_name)
|
145
|
+
evaluate_attribute_method attr_name, "def #{attr_name}?; query_attribute('#{attr_name}'); end", "#{attr_name}?"
|
146
|
+
end
|
147
|
+
|
148
|
+
def define_write_method(attr_name)
|
149
|
+
evaluate_attribute_method attr_name, "def #{attr_name}=(new_value);write_attribute('#{attr_name}', new_value);end", "#{attr_name}="
|
150
|
+
end
|
151
|
+
|
152
|
+
# Evaluate the definition for an attribute related method
|
153
|
+
def evaluate_attribute_method(attr_name, method_definition, method_name=attr_name)
|
154
|
+
|
155
|
+
unless method_name.to_s == primary_key.to_s
|
156
|
+
generated_methods << method_name
|
157
|
+
end
|
158
|
+
|
159
|
+
begin
|
160
|
+
class_eval(method_definition, __FILE__, __LINE__)
|
161
|
+
rescue SyntaxError => err
|
162
|
+
generated_methods.delete(attr_name)
|
163
|
+
if logger
|
164
|
+
logger.warn "Exception occurred during reader method compilation."
|
165
|
+
logger.warn "Maybe #{attr_name} is not a valid Ruby identifier?"
|
166
|
+
logger.warn "#{err.message}"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end # ClassMethods
|
171
|
+
|
172
|
+
|
173
|
+
# Allows access to the object attributes, which are held in the @attributes hash, as though they
|
174
|
+
# were first-class methods. So a Person class with a name attribute can use Person#name and
|
175
|
+
# Person#name= and never directly use the attributes hash -- except for multiple assigns with
|
176
|
+
# ActiveRecord#attributes=. A Milestone class can also ask Milestone#completed? to test that
|
177
|
+
# the completed attribute is not nil or 0.
|
178
|
+
#
|
179
|
+
# It's also possible to instantiate related objects, so a Client class belonging to the clients
|
180
|
+
# table with a master_id foreign key can instantiate master through Client#master.
|
181
|
+
def method_missing(method_id, *args, &block)
|
182
|
+
method_name = method_id.to_s
|
183
|
+
|
184
|
+
# If we haven't generated any methods yet, generate them, then
|
185
|
+
# see if we've created the method we're looking for.
|
186
|
+
if !self.class.generated_methods?
|
187
|
+
self.class.define_attribute_methods
|
188
|
+
if self.class.generated_methods.include?(method_name)
|
189
|
+
return self.send(method_id, *args, &block)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
if self.class.primary_key.to_s == method_name
|
194
|
+
id
|
195
|
+
elsif md = self.class.match_attribute_method?(method_name)
|
196
|
+
attribute_name, method_type = md.pre_match, md.to_s
|
197
|
+
if @attributes.include?(attribute_name)
|
198
|
+
__send__("attribute#{method_type}", attribute_name, *args, &block)
|
199
|
+
else
|
200
|
+
super
|
201
|
+
end
|
202
|
+
elsif @attributes.include?(method_name)
|
203
|
+
read_attribute(method_name)
|
204
|
+
else
|
205
|
+
super
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
|
210
|
+
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
|
211
|
+
def read_attribute(attr_name)
|
212
|
+
attr_name = attr_name.to_s
|
213
|
+
if !(value = @attributes[attr_name]).nil?
|
214
|
+
if column = column_for_attribute(attr_name)
|
215
|
+
if unserializable_attribute?(attr_name, column)
|
216
|
+
unserialize_attribute(attr_name)
|
217
|
+
else
|
218
|
+
column.type_cast(value)
|
219
|
+
end
|
220
|
+
else
|
221
|
+
value
|
222
|
+
end
|
223
|
+
else
|
224
|
+
nil
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def read_attribute_before_type_cast(attr_name)
|
229
|
+
@attributes[attr_name]
|
230
|
+
end
|
231
|
+
|
232
|
+
# Returns true if the attribute is of a text column and marked for serialization.
|
233
|
+
def unserializable_attribute?(attr_name, column)
|
234
|
+
column.text? && self.class.serialized_attributes[attr_name]
|
235
|
+
end
|
236
|
+
|
237
|
+
# Returns the unserialized object of the attribute.
|
238
|
+
def unserialize_attribute(attr_name)
|
239
|
+
unserialized_object = object_from_yaml(@attributes[attr_name])
|
240
|
+
|
241
|
+
if unserialized_object.is_a?(self.class.serialized_attributes[attr_name]) || unserialized_object.nil?
|
242
|
+
@attributes.frozen? ? unserialized_object : @attributes[attr_name] = unserialized_object
|
243
|
+
else
|
244
|
+
raise SerializationTypeMismatch,
|
245
|
+
"#{attr_name} was supposed to be a #{self.class.serialized_attributes[attr_name]}, but was a #{unserialized_object.class.to_s}"
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
|
250
|
+
# Updates the attribute identified by <tt>attr_name</tt> with the specified +value+. Empty strings for fixnum and float
|
251
|
+
# columns are turned into nil.
|
252
|
+
def write_attribute(attr_name, value)
|
253
|
+
attr_name = attr_name.to_s
|
254
|
+
@attributes_cache.delete(attr_name)
|
255
|
+
if (column = column_for_attribute(attr_name)) && column.number?
|
256
|
+
@attributes[attr_name] = convert_number_column_value(value)
|
257
|
+
else
|
258
|
+
@attributes[attr_name] = value
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
|
263
|
+
def query_attribute(attr_name)
|
264
|
+
unless value = read_attribute(attr_name)
|
265
|
+
false
|
266
|
+
else
|
267
|
+
column = self.class.columns_hash[attr_name]
|
268
|
+
if column.nil?
|
269
|
+
if Numeric === value || value !~ /[^0-9]/
|
270
|
+
!value.to_i.zero?
|
271
|
+
else
|
272
|
+
!value.blank?
|
273
|
+
end
|
274
|
+
elsif column.number?
|
275
|
+
!value.zero?
|
276
|
+
else
|
277
|
+
!value.blank?
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
282
|
+
# A Person object with a name attribute can ask person.respond_to?("name"), person.respond_to?("name="), and
|
283
|
+
# person.respond_to?("name?") which will all return true.
|
284
|
+
alias :respond_to_without_attributes? :respond_to?
|
285
|
+
def respond_to?(method, include_priv = false)
|
286
|
+
method_name = method.to_s
|
287
|
+
if super
|
288
|
+
return true
|
289
|
+
elsif !self.class.generated_methods?
|
290
|
+
self.class.define_attribute_methods
|
291
|
+
if self.class.generated_methods.include?(method_name)
|
292
|
+
return true
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
if @attributes.nil?
|
297
|
+
return super
|
298
|
+
elsif @attributes.include?(method_name)
|
299
|
+
return true
|
300
|
+
elsif md = self.class.match_attribute_method?(method_name)
|
301
|
+
return true if @attributes.include?(md.pre_match)
|
302
|
+
end
|
303
|
+
super
|
304
|
+
end
|
305
|
+
|
306
|
+
|
307
|
+
private
|
308
|
+
|
309
|
+
def missing_attribute(attr_name, stack)
|
310
|
+
raise ActiveRecord::MissingAttributeError, "missing attribute: #{attr_name}", stack
|
311
|
+
end
|
312
|
+
|
313
|
+
# Handle *? for method_missing.
|
314
|
+
def attribute?(attribute_name)
|
315
|
+
query_attribute(attribute_name)
|
316
|
+
end
|
317
|
+
|
318
|
+
# Handle *= for method_missing.
|
319
|
+
def attribute=(attribute_name, value)
|
320
|
+
write_attribute(attribute_name, value)
|
321
|
+
end
|
322
|
+
|
323
|
+
# Handle *_before_type_cast for method_missing.
|
324
|
+
def attribute_before_type_cast(attribute_name)
|
325
|
+
read_attribute_before_type_cast(attribute_name)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
@@ -0,0 +1,2471 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'yaml'
|
3
|
+
require 'set'
|
4
|
+
|
5
|
+
module ActiveRecord #:nodoc:
|
6
|
+
# Generic ActiveRecord exception class.
|
7
|
+
class ActiveRecordError < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
# Raised when the single-table inheritance mechanism failes to locate the subclass
|
11
|
+
# (for example due to improper usage of column that +inheritance_column+ points to).
|
12
|
+
class SubclassNotFound < ActiveRecordError #:nodoc:
|
13
|
+
end
|
14
|
+
|
15
|
+
# Raised when object assigned to association is of incorrect type.
|
16
|
+
#
|
17
|
+
# Example:
|
18
|
+
#
|
19
|
+
# class Ticket < ActiveRecord::Base
|
20
|
+
# has_many :patches
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# class Patch < ActiveRecord::Base
|
24
|
+
# belongs_to :ticket
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# and somewhere in the code:
|
28
|
+
#
|
29
|
+
# @ticket.patches << Comment.new(:content => "Please attach tests to your patch.")
|
30
|
+
# @ticket.save
|
31
|
+
class AssociationTypeMismatch < ActiveRecordError
|
32
|
+
end
|
33
|
+
|
34
|
+
# Raised when unserialized object's type mismatches one specified for serializable field.
|
35
|
+
class SerializationTypeMismatch < ActiveRecordError
|
36
|
+
end
|
37
|
+
|
38
|
+
# Raised when adapter not specified on connection (or configuration file config/database.yml misses adapter field).
|
39
|
+
class AdapterNotSpecified < ActiveRecordError
|
40
|
+
end
|
41
|
+
|
42
|
+
# Raised when ActiveRecord cannot find database adapter specified in config/database.yml or programmatically.
|
43
|
+
class AdapterNotFound < ActiveRecordError
|
44
|
+
end
|
45
|
+
|
46
|
+
# Raised when connection to the database could not been established (for example when connection= is given a nil object).
|
47
|
+
class ConnectionNotEstablished < ActiveRecordError
|
48
|
+
end
|
49
|
+
|
50
|
+
# Raised when ActiveRecord cannot find record by given id or set of ids.
|
51
|
+
class RecordNotFound < ActiveRecordError
|
52
|
+
end
|
53
|
+
|
54
|
+
# Raised by ActiveRecord::Base.save! and ActiveRecord::Base.create! methods when record cannot be
|
55
|
+
# saved because record is invalid.
|
56
|
+
class RecordNotSaved < ActiveRecordError
|
57
|
+
end
|
58
|
+
|
59
|
+
# 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).
|
60
|
+
class StatementInvalid < ActiveRecordError
|
61
|
+
end
|
62
|
+
|
63
|
+
# Raised when number of bind variables in statement given to :condition key (for example, when using +find+ method)
|
64
|
+
# does not match number of expected variables.
|
65
|
+
#
|
66
|
+
# Example:
|
67
|
+
#
|
68
|
+
# Location.find :all, :conditions => ["lat = ? AND lng = ?", 53.7362]
|
69
|
+
#
|
70
|
+
# in example above two placeholders are given but only one variable to fill them.
|
71
|
+
class PreparedStatementInvalid < ActiveRecordError
|
72
|
+
end
|
73
|
+
|
74
|
+
# Raised on attempt to save stale record. Record is stale when it's being saved in another query after
|
75
|
+
# instantiation, for example, when two users edit the same wiki page and one starts editing and saves
|
76
|
+
# the page before the other.
|
77
|
+
#
|
78
|
+
# Read more about optimistic locking in +ActiveRecord::Locking+ module RDoc.
|
79
|
+
class StaleObjectError < ActiveRecordError
|
80
|
+
end
|
81
|
+
|
82
|
+
# Raised when association is being configured improperly or
|
83
|
+
# user tries to use offset and limit together with has_many or has_and_belongs_to_many associations.
|
84
|
+
class ConfigurationError < ActiveRecordError
|
85
|
+
end
|
86
|
+
|
87
|
+
# Raised on attempt to update record that is instantiated as read only.
|
88
|
+
class ReadOnlyRecord < ActiveRecordError
|
89
|
+
end
|
90
|
+
|
91
|
+
# Used by ActiveRecord transaction mechanism to distinguish rollback from other exceptional situations.
|
92
|
+
# You can use it to roll your transaction back explicitly in the block passed to +transaction+ method.
|
93
|
+
class Rollback < ActiveRecordError
|
94
|
+
end
|
95
|
+
|
96
|
+
# Raised when attribute has a name reserved by ActiveRecord (when attribute has name of one of ActiveRecord instance methods).
|
97
|
+
class DangerousAttributeError < ActiveRecordError
|
98
|
+
end
|
99
|
+
|
100
|
+
# Raised when you've tried to access a column which wasn't
|
101
|
+
# loaded by your finder. Typically this is because :select
|
102
|
+
# has been specified
|
103
|
+
class MissingAttributeError < NoMethodError
|
104
|
+
end
|
105
|
+
|
106
|
+
class AttributeAssignmentError < ActiveRecordError #:nodoc:
|
107
|
+
attr_reader :exception, :attribute
|
108
|
+
def initialize(message, exception, attribute)
|
109
|
+
@exception = exception
|
110
|
+
@attribute = attribute
|
111
|
+
@message = message
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class MultiparameterAssignmentErrors < ActiveRecordError #:nodoc:
|
116
|
+
attr_reader :errors
|
117
|
+
def initialize(errors)
|
118
|
+
@errors = errors
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Active Record objects don't specify their attributes directly, but rather infer them from the table definition with
|
123
|
+
# which they're linked. Adding, removing, and changing attributes and their type is done directly in the database. Any change
|
124
|
+
# is instantly reflected in the Active Record objects. The mapping that binds a given Active Record class to a certain
|
125
|
+
# database table will happen automatically in most common cases, but can be overwritten for the uncommon ones.
|
126
|
+
#
|
127
|
+
# See the mapping rules in table_name and the full example in link:files/README.html for more insight.
|
128
|
+
#
|
129
|
+
# == Creation
|
130
|
+
#
|
131
|
+
# Active Records accept constructor parameters either in a hash or as a block. The hash method is especially useful when
|
132
|
+
# you're receiving the data from somewhere else, like an HTTP request. It works like this:
|
133
|
+
#
|
134
|
+
# user = User.new(:name => "David", :occupation => "Code Artist")
|
135
|
+
# user.name # => "David"
|
136
|
+
#
|
137
|
+
# You can also use block initialization:
|
138
|
+
#
|
139
|
+
# user = User.new do |u|
|
140
|
+
# u.name = "David"
|
141
|
+
# u.occupation = "Code Artist"
|
142
|
+
# end
|
143
|
+
#
|
144
|
+
# And of course you can just create a bare object and specify the attributes after the fact:
|
145
|
+
#
|
146
|
+
# user = User.new
|
147
|
+
# user.name = "David"
|
148
|
+
# user.occupation = "Code Artist"
|
149
|
+
#
|
150
|
+
# == Conditions
|
151
|
+
#
|
152
|
+
# Conditions can either be specified as a string, array, or hash representing the WHERE-part of an SQL statement.
|
153
|
+
# The array form is to be used when the condition input is tainted and requires sanitization. The string form can
|
154
|
+
# be used for statements that don't involve tainted data. The hash form works much like the array form, except
|
155
|
+
# only equality and range is possible. Examples:
|
156
|
+
#
|
157
|
+
# class User < ActiveRecord::Base
|
158
|
+
# def self.authenticate_unsafely(user_name, password)
|
159
|
+
# find(:first, :conditions => "user_name = '#{user_name}' AND password = '#{password}'")
|
160
|
+
# end
|
161
|
+
#
|
162
|
+
# def self.authenticate_safely(user_name, password)
|
163
|
+
# find(:first, :conditions => [ "user_name = ? AND password = ?", user_name, password ])
|
164
|
+
# end
|
165
|
+
#
|
166
|
+
# def self.authenticate_safely_simply(user_name, password)
|
167
|
+
# find(:first, :conditions => { :user_name => user_name, :password => password })
|
168
|
+
# end
|
169
|
+
# end
|
170
|
+
#
|
171
|
+
# The <tt>authenticate_unsafely</tt> method inserts the parameters directly into the query and is thus susceptible to SQL-injection
|
172
|
+
# attacks if the <tt>user_name</tt> and +password+ parameters come directly from an HTTP request. The <tt>authenticate_safely</tt> and
|
173
|
+
# <tt>authenticate_safely_simply</tt> both will sanitize the <tt>user_name</tt> and +password+ before inserting them in the query,
|
174
|
+
# which will ensure that an attacker can't escape the query and fake the login (or worse).
|
175
|
+
#
|
176
|
+
# When using multiple parameters in the conditions, it can easily become hard to read exactly what the fourth or fifth
|
177
|
+
# question mark is supposed to represent. In those cases, you can resort to named bind variables instead. That's done by replacing
|
178
|
+
# the question marks with symbols and supplying a hash with values for the matching symbol keys:
|
179
|
+
#
|
180
|
+
# Company.find(:first, :conditions => [
|
181
|
+
# "id = :id AND name = :name AND division = :division AND created_at > :accounting_date",
|
182
|
+
# { :id => 3, :name => "37signals", :division => "First", :accounting_date => '2005-01-01' }
|
183
|
+
# ])
|
184
|
+
#
|
185
|
+
# Similarly, a simple hash without a statement will generate conditions based on equality with the SQL AND
|
186
|
+
# operator. For instance:
|
187
|
+
#
|
188
|
+
# Student.find(:all, :conditions => { :first_name => "Harvey", :status => 1 })
|
189
|
+
# Student.find(:all, :conditions => params[:student])
|
190
|
+
#
|
191
|
+
# A range may be used in the hash to use the SQL BETWEEN operator:
|
192
|
+
#
|
193
|
+
# Student.find(:all, :conditions => { :grade => 9..12 })
|
194
|
+
#
|
195
|
+
# == Overwriting default accessors
|
196
|
+
#
|
197
|
+
# All column values are automatically available through basic accessors on the Active Record object, but sometimes you
|
198
|
+
# want to specialize this behavior. This can be done by overwriting the default accessors (using the same
|
199
|
+
# name as the attribute) and calling read_attribute(attr_name) and write_attribute(attr_name, value) to actually change things.
|
200
|
+
# Example:
|
201
|
+
#
|
202
|
+
# class Song < ActiveRecord::Base
|
203
|
+
# # Uses an integer of seconds to hold the length of the song
|
204
|
+
#
|
205
|
+
# def length=(minutes)
|
206
|
+
# write_attribute(:length, minutes * 60)
|
207
|
+
# end
|
208
|
+
#
|
209
|
+
# def length
|
210
|
+
# read_attribute(:length) / 60
|
211
|
+
# end
|
212
|
+
# end
|
213
|
+
#
|
214
|
+
# You can alternatively use self[:attribute]=(value) and self[:attribute] instead of write_attribute(:attribute, value) and
|
215
|
+
# read_attribute(:attribute) as a shorter form.
|
216
|
+
#
|
217
|
+
# == Attribute query methods
|
218
|
+
#
|
219
|
+
# In addition to the basic accessors, query methods are also automatically available on the Active Record object.
|
220
|
+
# Query methods allow you to test whether an attribute value is present.
|
221
|
+
#
|
222
|
+
# For example, an Active Record User with the <tt>name</tt> attribute has a <tt>name?</tt> method that you can call
|
223
|
+
# to determine whether the user has a name:
|
224
|
+
#
|
225
|
+
# user = User.new(:name => "David")
|
226
|
+
# user.name? # => true
|
227
|
+
#
|
228
|
+
# anonymous = User.new(:name => "")
|
229
|
+
# anonymous.name? # => false
|
230
|
+
#
|
231
|
+
# == Accessing attributes before they have been typecasted
|
232
|
+
#
|
233
|
+
# Sometimes you want to be able to read the raw attribute data without having the column-determined typecast run its course first.
|
234
|
+
# That can be done by using the <attribute>_before_type_cast accessors that all attributes have. For example, if your Account model
|
235
|
+
# has a balance attribute, you can call account.balance_before_type_cast or account.id_before_type_cast.
|
236
|
+
#
|
237
|
+
# This is especially useful in validation situations where the user might supply a string for an integer field and you want to display
|
238
|
+
# the original string back in an error message. Accessing the attribute normally would typecast the string to 0, which isn't what you
|
239
|
+
# want.
|
240
|
+
#
|
241
|
+
# == Dynamic attribute-based finders
|
242
|
+
#
|
243
|
+
# Dynamic attribute-based finders are a cleaner way of getting (and/or creating) objects by simple queries without turning to SQL. They work by
|
244
|
+
# appending the name of an attribute to <tt>find_by_</tt> or <tt>find_all_by_</tt>, so you get finders like Person.find_by_user_name,
|
245
|
+
# Person.find_all_by_last_name, Payment.find_by_transaction_id. So instead of writing
|
246
|
+
# <tt>Person.find(:first, :conditions => ["user_name = ?", user_name])</tt>, you just do <tt>Person.find_by_user_name(user_name)</tt>.
|
247
|
+
# And instead of writing <tt>Person.find(:all, :conditions => ["last_name = ?", last_name])</tt>, you just do <tt>Person.find_all_by_last_name(last_name)</tt>.
|
248
|
+
#
|
249
|
+
# It's also possible to use multiple attributes in the same find by separating them with "_and_", so you get finders like
|
250
|
+
# <tt>Person.find_by_user_name_and_password</tt> or even <tt>Payment.find_by_purchaser_and_state_and_country</tt>. So instead of writing
|
251
|
+
# <tt>Person.find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])</tt>, you just do
|
252
|
+
# <tt>Person.find_by_user_name_and_password(user_name, password)</tt>.
|
253
|
+
#
|
254
|
+
# It's even possible to use all the additional parameters to find. For example, the full interface for Payment.find_all_by_amount
|
255
|
+
# is actually Payment.find_all_by_amount(amount, options). And the full interface to Person.find_by_user_name is
|
256
|
+
# actually Person.find_by_user_name(user_name, options). So you could call <tt>Payment.find_all_by_amount(50, :order => "created_on")</tt>.
|
257
|
+
#
|
258
|
+
# The same dynamic finder style can be used to create the object if it doesn't already exist. This dynamic finder is called with
|
259
|
+
# <tt>find_or_create_by_</tt> and will return the object if it already exists and otherwise creates it, then returns it. Example:
|
260
|
+
#
|
261
|
+
# # No 'Summer' tag exists
|
262
|
+
# Tag.find_or_create_by_name("Summer") # equal to Tag.create(:name => "Summer")
|
263
|
+
#
|
264
|
+
# # Now the 'Summer' tag does exist
|
265
|
+
# Tag.find_or_create_by_name("Summer") # equal to Tag.find_by_name("Summer")
|
266
|
+
#
|
267
|
+
# Use the <tt>find_or_initialize_by_</tt> finder if you want to return a new record without saving it first. Example:
|
268
|
+
#
|
269
|
+
# # No 'Winter' tag exists
|
270
|
+
# winter = Tag.find_or_initialize_by_name("Winter")
|
271
|
+
# winter.new_record? # true
|
272
|
+
#
|
273
|
+
# To find by a subset of the attributes to be used for instantiating a new object, pass a hash instead of
|
274
|
+
# a list of parameters. For example:
|
275
|
+
#
|
276
|
+
# Tag.find_or_create_by_name(:name => "rails", :creator => current_user)
|
277
|
+
#
|
278
|
+
# That will either find an existing tag named "rails", or create a new one while setting the user that created it.
|
279
|
+
#
|
280
|
+
# == Saving arrays, hashes, and other non-mappable objects in text columns
|
281
|
+
#
|
282
|
+
# 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+.
|
283
|
+
# This makes it possible to store arrays, hashes, and other non-mappable objects without doing any additional work. Example:
|
284
|
+
#
|
285
|
+
# class User < ActiveRecord::Base
|
286
|
+
# serialize :preferences
|
287
|
+
# end
|
288
|
+
#
|
289
|
+
# user = User.create(:preferences => { "background" => "black", "display" => large })
|
290
|
+
# User.find(user.id).preferences # => { "background" => "black", "display" => large }
|
291
|
+
#
|
292
|
+
# You can also specify a class option as the second parameter that'll raise an exception if a serialized object is retrieved as a
|
293
|
+
# descendent of a class not in the hierarchy. Example:
|
294
|
+
#
|
295
|
+
# class User < ActiveRecord::Base
|
296
|
+
# serialize :preferences, Hash
|
297
|
+
# end
|
298
|
+
#
|
299
|
+
# user = User.create(:preferences => %w( one two three ))
|
300
|
+
# User.find(user.id).preferences # raises SerializationTypeMismatch
|
301
|
+
#
|
302
|
+
# == Single table inheritance
|
303
|
+
#
|
304
|
+
# Active Record allows inheritance by storing the name of the class in a column that by default is named "type" (can be changed
|
305
|
+
# by overwriting <tt>Base.inheritance_column</tt>). This means that an inheritance looking like this:
|
306
|
+
#
|
307
|
+
# class Company < ActiveRecord::Base; end
|
308
|
+
# class Firm < Company; end
|
309
|
+
# class Client < Company; end
|
310
|
+
# class PriorityClient < Client; end
|
311
|
+
#
|
312
|
+
# When you do Firm.create(:name => "37signals"), this record will be saved in the companies table with type = "Firm". You can then
|
313
|
+
# fetch this row again using Company.find(:first, "name = '37signals'") and it will return a Firm object.
|
314
|
+
#
|
315
|
+
# 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
|
316
|
+
# like normal subclasses with no special magic for differentiating between them or reloading the right type with find.
|
317
|
+
#
|
318
|
+
# Note, all the attributes for all the cases are kept in the same table. Read more:
|
319
|
+
# http://www.martinfowler.com/eaaCatalog/singleTableInheritance.html
|
320
|
+
#
|
321
|
+
# == Connection to multiple databases in different models
|
322
|
+
#
|
323
|
+
# Connections are usually created through ActiveRecord::Base.establish_connection and retrieved by ActiveRecord::Base.connection.
|
324
|
+
# All classes inheriting from ActiveRecord::Base will use this connection. But you can also set a class-specific connection.
|
325
|
+
# For example, if Course is an ActiveRecord::Base, but resides in a different database, you can just say Course.establish_connection
|
326
|
+
# and Course *and all its subclasses* will use this connection instead.
|
327
|
+
#
|
328
|
+
# This feature is implemented by keeping a connection pool in ActiveRecord::Base that is a Hash indexed by the class. If a connection is
|
329
|
+
# requested, the retrieve_connection method will go up the class-hierarchy until a connection is found in the connection pool.
|
330
|
+
#
|
331
|
+
# == Exceptions
|
332
|
+
#
|
333
|
+
# * +ActiveRecordError+ -- generic error class and superclass of all other errors raised by Active Record
|
334
|
+
# * +AdapterNotSpecified+ -- the configuration hash used in <tt>establish_connection</tt> didn't include an
|
335
|
+
# <tt>:adapter</tt> key.
|
336
|
+
# * +AdapterNotFound+ -- the <tt>:adapter</tt> key used in <tt>establish_connection</tt> specified a non-existent adapter
|
337
|
+
# (or a bad spelling of an existing one).
|
338
|
+
# * +AssociationTypeMismatch+ -- the object assigned to the association wasn't of the type specified in the association definition.
|
339
|
+
# * +SerializationTypeMismatch+ -- the serialized object wasn't of the class specified as the second parameter.
|
340
|
+
# * +ConnectionNotEstablished+ -- no connection has been established. Use <tt>establish_connection</tt> before querying.
|
341
|
+
# * +RecordNotFound+ -- no record responded to the find* method.
|
342
|
+
# Either the row with the given ID doesn't exist or the row didn't meet the additional restrictions.
|
343
|
+
# * +StatementInvalid+ -- the database server rejected the SQL statement. The precise error is added in the message.
|
344
|
+
# Either the record with the given ID doesn't exist or the record didn't meet the additional restrictions.
|
345
|
+
# * +MultiparameterAssignmentErrors+ -- collection of errors that occurred during a mass assignment using the
|
346
|
+
# +attributes=+ method. The +errors+ property of this exception contains an array of +AttributeAssignmentError+
|
347
|
+
# objects that should be inspected to determine which attributes triggered the errors.
|
348
|
+
# * +AttributeAssignmentError+ -- an error occurred while doing a mass assignment through the +attributes=+ method.
|
349
|
+
# You can inspect the +attribute+ property of the exception object to determine which attribute triggered the error.
|
350
|
+
#
|
351
|
+
# *Note*: The attributes listed are class-level attributes (accessible from both the class and instance level).
|
352
|
+
# So it's possible to assign a logger to the class through Base.logger= which will then be used by all
|
353
|
+
# instances in the current object space.
|
354
|
+
class Base
|
355
|
+
# Accepts a logger conforming to the interface of Log4r or the default Ruby 1.8+ Logger class, which is then passed
|
356
|
+
# on to any new database connections made and which can be retrieved on both a class and instance level by calling +logger+.
|
357
|
+
cattr_accessor :logger, :instance_writer => false
|
358
|
+
|
359
|
+
def self.inherited(child) #:nodoc:
|
360
|
+
@@subclasses[self] ||= []
|
361
|
+
@@subclasses[self] << child
|
362
|
+
super
|
363
|
+
end
|
364
|
+
|
365
|
+
def self.reset_subclasses #:nodoc:
|
366
|
+
nonreloadables = []
|
367
|
+
subclasses.each do |klass|
|
368
|
+
unless Dependencies.autoloaded? klass
|
369
|
+
nonreloadables << klass
|
370
|
+
next
|
371
|
+
end
|
372
|
+
klass.instance_variables.each { |var| klass.send(:remove_instance_variable, var) }
|
373
|
+
klass.instance_methods(false).each { |m| klass.send :undef_method, m }
|
374
|
+
end
|
375
|
+
@@subclasses = {}
|
376
|
+
nonreloadables.each { |klass| (@@subclasses[klass.superclass] ||= []) << klass }
|
377
|
+
end
|
378
|
+
|
379
|
+
@@subclasses = {}
|
380
|
+
|
381
|
+
cattr_accessor :configurations, :instance_writer => false
|
382
|
+
@@configurations = {}
|
383
|
+
|
384
|
+
# Accessor for the prefix type that will be prepended to every primary key column name. The options are :table_name and
|
385
|
+
# :table_name_with_underscore. If the first is specified, the Product class will look for "productid" instead of "id" as
|
386
|
+
# the primary column. If the latter is specified, the Product class will look for "product_id" instead of "id". Remember
|
387
|
+
# that this is a global setting for all Active Records.
|
388
|
+
cattr_accessor :primary_key_prefix_type, :instance_writer => false
|
389
|
+
@@primary_key_prefix_type = nil
|
390
|
+
|
391
|
+
# Accessor for the name of the prefix string to prepend to every table name. So if set to "basecamp_", all
|
392
|
+
# table names will be named like "basecamp_projects", "basecamp_people", etc. This is a convenient way of creating a namespace
|
393
|
+
# for tables in a shared database. By default, the prefix is the empty string.
|
394
|
+
cattr_accessor :table_name_prefix, :instance_writer => false
|
395
|
+
@@table_name_prefix = ""
|
396
|
+
|
397
|
+
# Works like +table_name_prefix+, but appends instead of prepends (set to "_basecamp" gives "projects_basecamp",
|
398
|
+
# "people_basecamp"). By default, the suffix is the empty string.
|
399
|
+
cattr_accessor :table_name_suffix, :instance_writer => false
|
400
|
+
@@table_name_suffix = ""
|
401
|
+
|
402
|
+
# Indicates whether table names should be the pluralized versions of the corresponding class names.
|
403
|
+
# If true, the default table name for a +Product+ class will be +products+. If false, it would just be +product+.
|
404
|
+
# See table_name for the full rules on table/class naming. This is true, by default.
|
405
|
+
cattr_accessor :pluralize_table_names, :instance_writer => false
|
406
|
+
@@pluralize_table_names = true
|
407
|
+
|
408
|
+
# Determines whether to use ANSI codes to colorize the logging statements committed by the connection adapter. These colors
|
409
|
+
# make it much easier to overview things during debugging (when used through a reader like +tail+ and on a black background), but
|
410
|
+
# may complicate matters if you use software like syslog. This is true, by default.
|
411
|
+
cattr_accessor :colorize_logging, :instance_writer => false
|
412
|
+
@@colorize_logging = true
|
413
|
+
|
414
|
+
# Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates and times from the database.
|
415
|
+
# This is set to :local by default.
|
416
|
+
cattr_accessor :default_timezone, :instance_writer => false
|
417
|
+
@@default_timezone = :local
|
418
|
+
|
419
|
+
# Determines whether to use a connection for each thread, or a single shared connection for all threads.
|
420
|
+
# Defaults to false. Set to true if you're writing a threaded application.
|
421
|
+
cattr_accessor :allow_concurrency, :instance_writer => false
|
422
|
+
@@allow_concurrency = false
|
423
|
+
|
424
|
+
# Specifies the format to use when dumping the database schema with Rails'
|
425
|
+
# Rakefile. If :sql, the schema is dumped as (potentially database-
|
426
|
+
# specific) SQL statements. If :ruby, the schema is dumped as an
|
427
|
+
# ActiveRecord::Schema file which can be loaded into any database that
|
428
|
+
# supports migrations. Use :ruby if you want to have different database
|
429
|
+
# adapters for, e.g., your development and test environments.
|
430
|
+
cattr_accessor :schema_format , :instance_writer => false
|
431
|
+
@@schema_format = :ruby
|
432
|
+
|
433
|
+
class << self # Class methods
|
434
|
+
# Find operates with three different retrieval approaches:
|
435
|
+
#
|
436
|
+
# * Find by id: This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]).
|
437
|
+
# If no record can be found for all of the listed ids, then RecordNotFound will be raised.
|
438
|
+
# * Find first: This will return the first record matched by the options used. These options can either be specific
|
439
|
+
# conditions or merely an order. If no record can be matched, nil is returned.
|
440
|
+
# * Find all: This will return all the records matched by the options used. If no records are found, an empty array is returned.
|
441
|
+
#
|
442
|
+
# All approaches accept an options hash as their last parameter. The options are:
|
443
|
+
#
|
444
|
+
# * <tt>:conditions</tt>: An SQL fragment like "administrator = 1" or [ "user_name = ?", username ]. See conditions in the intro.
|
445
|
+
# * <tt>:order</tt>: An SQL fragment like "created_at DESC, name".
|
446
|
+
# * <tt>:group</tt>: An attribute name by which the result should be grouped. Uses the GROUP BY SQL-clause.
|
447
|
+
# * <tt>:limit</tt>: An integer determining the limit on the number of rows that should be returned.
|
448
|
+
# * <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.
|
449
|
+
# * <tt>:joins</tt>: Either an SQL fragment for additional joins like "LEFT JOIN comments ON comments.post_id = id" (rarely needed)
|
450
|
+
# or named associations in the same form used for the :include option, which will perform an INNER JOIN on the associated table(s).
|
451
|
+
# 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.
|
452
|
+
# Pass :readonly => false to override.
|
453
|
+
# * <tt>:include</tt>: Names associations that should be loaded alongside using LEFT OUTER JOINs. The symbols named refer
|
454
|
+
# to already defined associations. See eager loading under Associations.
|
455
|
+
# * <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
|
456
|
+
# include the joined columns.
|
457
|
+
# * <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
|
458
|
+
# of a database view).
|
459
|
+
# * <tt>:readonly</tt>: Mark the returned records read-only so they cannot be saved or updated.
|
460
|
+
# * <tt>:lock</tt>: An SQL fragment like "FOR UPDATE" or "LOCK IN SHARE MODE".
|
461
|
+
# :lock => true gives connection's default exclusive lock, usually "FOR UPDATE".
|
462
|
+
#
|
463
|
+
# Examples for find by id:
|
464
|
+
# Person.find(1) # returns the object for ID = 1
|
465
|
+
# Person.find(1, 2, 6) # returns an array for objects with IDs in (1, 2, 6)
|
466
|
+
# Person.find([7, 17]) # returns an array for objects with IDs in (7, 17)
|
467
|
+
# Person.find([1]) # returns an array for the object with ID = 1
|
468
|
+
# Person.find(1, :conditions => "administrator = 1", :order => "created_on DESC")
|
469
|
+
#
|
470
|
+
# Note that returned records may not be in the same order as the ids you
|
471
|
+
# provide since database rows are unordered. Give an explicit :order
|
472
|
+
# to ensure the results are sorted.
|
473
|
+
#
|
474
|
+
# Examples for find first:
|
475
|
+
# Person.find(:first) # returns the first object fetched by SELECT * FROM people
|
476
|
+
# Person.find(:first, :conditions => [ "user_name = ?", user_name])
|
477
|
+
# Person.find(:first, :order => "created_on DESC", :offset => 5)
|
478
|
+
#
|
479
|
+
# Examples for find all:
|
480
|
+
# Person.find(:all) # returns an array of objects for all the rows fetched by SELECT * FROM people
|
481
|
+
# Person.find(:all, :conditions => [ "category IN (?)", categories], :limit => 50)
|
482
|
+
# Person.find(:all, :offset => 10, :limit => 10)
|
483
|
+
# Person.find(:all, :include => [ :account, :friends ])
|
484
|
+
# Person.find(:all, :group => "category")
|
485
|
+
#
|
486
|
+
# Example for find with a lock. Imagine two concurrent transactions:
|
487
|
+
# each will read person.visits == 2, add 1 to it, and save, resulting
|
488
|
+
# in two saves of person.visits = 3. By locking the row, the second
|
489
|
+
# transaction has to wait until the first is finished; we get the
|
490
|
+
# expected person.visits == 4.
|
491
|
+
# Person.transaction do
|
492
|
+
# person = Person.find(1, :lock => true)
|
493
|
+
# person.visits += 1
|
494
|
+
# person.save!
|
495
|
+
# end
|
496
|
+
def find(*args)
|
497
|
+
options = args.extract_options!
|
498
|
+
validate_find_options(options)
|
499
|
+
set_readonly_option!(options)
|
500
|
+
|
501
|
+
case args.first
|
502
|
+
when :first then find_initial(options)
|
503
|
+
when :all then find_every(options)
|
504
|
+
else find_from_ids(args, options)
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
508
|
+
#
|
509
|
+
# Executes a custom sql query against your database and returns all the results. The results will
|
510
|
+
# be returned as an array with columns requested encapsulated as attributes of the model you call
|
511
|
+
# this method from. If you call +Product.find_by_sql+ then the results will be returned in a Product
|
512
|
+
# object with the attributes you specified in the SQL query.
|
513
|
+
#
|
514
|
+
# If you call a complicated SQL query which spans multiple tables the columns specified by the
|
515
|
+
# SELECT will be attributes of the model, whether or not they are columns of the corresponding
|
516
|
+
# table.
|
517
|
+
#
|
518
|
+
# The +sql+ parameter is a full sql query as a string. It will be called as is, there will be
|
519
|
+
# no database agnostic conversions performed. This should be a last resort because using, for example,
|
520
|
+
# MySQL specific terms will lock you to using that particular database engine or require you to
|
521
|
+
# change your call if you switch engines
|
522
|
+
#
|
523
|
+
# ==== Examples
|
524
|
+
# # A simple sql query spanning multiple tables
|
525
|
+
# Post.find_by_sql "SELECT p.title, c.author FROM posts p, comments c WHERE p.id = c.post_id"
|
526
|
+
# > [#<Post:0x36bff9c @attributes={"title"=>"Ruby Meetup", "first_name"=>"Quentin"}>, ...]
|
527
|
+
#
|
528
|
+
# # You can use the same string replacement techniques as you can with ActiveRecord#find
|
529
|
+
# Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date]
|
530
|
+
# > [#<Post:0x36bff9c @attributes={"first_name"=>"The Cheap Man Buys Twice"}>, ...]
|
531
|
+
def find_by_sql(sql)
|
532
|
+
connection.select_all(sanitize_sql(sql), "#{name} Load").collect! { |record| instantiate(record) }
|
533
|
+
end
|
534
|
+
|
535
|
+
# Checks whether a record exists in the database that matches conditions given. These conditions
|
536
|
+
# can either be a single integer representing a primary key id to be found, or a condition to be
|
537
|
+
# matched like using ActiveRecord#find.
|
538
|
+
#
|
539
|
+
# The +id_or_conditions+ parameter can be an Integer or a String if you want to search the primary key
|
540
|
+
# column of the table for a matching id, or if you're looking to match against a condition you can use
|
541
|
+
# an Array or a Hash.
|
542
|
+
#
|
543
|
+
# Possible gotcha: You can't pass in a condition as a string e.g. "name = 'Jamie'", this would be
|
544
|
+
# sanitized and then queried against the primary key column as "id = 'name = \'Jamie"
|
545
|
+
#
|
546
|
+
# ==== Examples
|
547
|
+
# Person.exists?(5)
|
548
|
+
# Person.exists?('5')
|
549
|
+
# Person.exists?(:name => "David")
|
550
|
+
# Person.exists?(['name LIKE ?', "%#{query}%"])
|
551
|
+
def exists?(id_or_conditions)
|
552
|
+
!find(:first, :select => "#{quoted_table_name}.#{primary_key}",
|
553
|
+
:conditions => expand_id_conditions(id_or_conditions)).nil?
|
554
|
+
end
|
555
|
+
|
556
|
+
# Creates an object (or multiple objects) and saves it to the database, if validations pass.
|
557
|
+
# The resulting object is returned whether the object was saved successfully to the database or not.
|
558
|
+
#
|
559
|
+
# The +attributes+ parameter can be either be a Hash or an Array of Hashes. These Hashes describe the
|
560
|
+
# attributes on the objects that are to be created.
|
561
|
+
#
|
562
|
+
# ==== Examples
|
563
|
+
# # Create a single new object
|
564
|
+
# User.create(:first_name => 'Jamie')
|
565
|
+
# # Create an Array of new objects
|
566
|
+
# User.create([{:first_name => 'Jamie'}, {:first_name => 'Jeremy'}])
|
567
|
+
def create(attributes = nil)
|
568
|
+
if attributes.is_a?(Array)
|
569
|
+
attributes.collect { |attr| create(attr) }
|
570
|
+
else
|
571
|
+
object = new(attributes)
|
572
|
+
object.save
|
573
|
+
object
|
574
|
+
end
|
575
|
+
end
|
576
|
+
|
577
|
+
# Updates an object (or multiple objects) and saves it to the database, if validations pass.
|
578
|
+
# The resulting object is returned whether the object was saved successfully to the database or not.
|
579
|
+
#
|
580
|
+
# ==== Options
|
581
|
+
#
|
582
|
+
# +id+ This should be the id or an array of ids to be updated
|
583
|
+
# +attributes+ This should be a Hash of attributes to be set on the object, or an array of Hashes.
|
584
|
+
#
|
585
|
+
# ==== Examples
|
586
|
+
#
|
587
|
+
# # Updating one record:
|
588
|
+
# Person.update(15, {:user_name => 'Samuel', :group => 'expert'})
|
589
|
+
#
|
590
|
+
# # Updating multiple records:
|
591
|
+
# people = { 1 => { "first_name" => "David" }, 2 => { "first_name" => "Jeremy"} }
|
592
|
+
# Person.update(people.keys, people.values)
|
593
|
+
def update(id, attributes)
|
594
|
+
if id.is_a?(Array)
|
595
|
+
idx = -1
|
596
|
+
id.collect { |id| idx += 1; update(id, attributes[idx]) }
|
597
|
+
else
|
598
|
+
object = find(id)
|
599
|
+
object.update_attributes(attributes)
|
600
|
+
object
|
601
|
+
end
|
602
|
+
end
|
603
|
+
|
604
|
+
# Delete an object (or multiple objects) where the +id+ given matches the primary_key. A SQL +DELETE+ command
|
605
|
+
# is executed on the database which means that no callbacks are fired off running this. This is an efficient method
|
606
|
+
# of deleting records that don't need cleaning up after or other actions to be taken.
|
607
|
+
#
|
608
|
+
# Objects are _not_ instantiated with this method.
|
609
|
+
#
|
610
|
+
# ==== Options
|
611
|
+
#
|
612
|
+
# +id+ Can be either an Integer or an Array of Integers
|
613
|
+
#
|
614
|
+
# ==== Examples
|
615
|
+
#
|
616
|
+
# # Delete a single object
|
617
|
+
# Todo.delete(1)
|
618
|
+
#
|
619
|
+
# # Delete multiple objects
|
620
|
+
# todos = [1,2,3]
|
621
|
+
# Todo.delete(todos)
|
622
|
+
def delete(id)
|
623
|
+
delete_all([ "#{connection.quote_column_name(primary_key)} IN (?)", id ])
|
624
|
+
end
|
625
|
+
|
626
|
+
# Destroy an object (or multiple objects) that has the given id, the object is instantiated first,
|
627
|
+
# therefore all callbacks and filters are fired off before the object is deleted. This method is
|
628
|
+
# less efficient than ActiveRecord#delete but allows cleanup methods and other actions to be run.
|
629
|
+
#
|
630
|
+
# This essentially finds the object (or multiple objects) with the given id, creates a new object
|
631
|
+
# from the attributes, and then calls destroy on it.
|
632
|
+
#
|
633
|
+
# ==== Options
|
634
|
+
#
|
635
|
+
# +id+ Can be either an Integer or an Array of Integers
|
636
|
+
#
|
637
|
+
# ==== Examples
|
638
|
+
#
|
639
|
+
# # Destroy a single object
|
640
|
+
# Todo.destroy(1)
|
641
|
+
#
|
642
|
+
# # Destroy multiple objects
|
643
|
+
# todos = [1,2,3]
|
644
|
+
# Todo.destroy(todos)
|
645
|
+
def destroy(id)
|
646
|
+
id.is_a?(Array) ? id.each { |id| destroy(id) } : find(id).destroy
|
647
|
+
end
|
648
|
+
|
649
|
+
# Updates all records with details given if they match a set of conditions supplied, limits and order can
|
650
|
+
# also be supplied.
|
651
|
+
#
|
652
|
+
# ==== Options
|
653
|
+
#
|
654
|
+
# +updates+ A String of column and value pairs that will be set on any records that match conditions
|
655
|
+
# +conditions+ An SQL fragment like "administrator = 1" or [ "user_name = ?", username ].
|
656
|
+
# See conditions in the intro for more info.
|
657
|
+
# +options+ Additional options are :limit and/or :order, see the examples for usage.
|
658
|
+
#
|
659
|
+
# ==== Examples
|
660
|
+
#
|
661
|
+
# # Update all billing objects with the 3 different attributes given
|
662
|
+
# Billing.update_all( "category = 'authorized', approved = 1, author = 'David'" )
|
663
|
+
#
|
664
|
+
# # Update records that match our conditions
|
665
|
+
# Billing.update_all( "author = 'David'", "title LIKE '%Rails%'" )
|
666
|
+
#
|
667
|
+
# # Update records that match our conditions but limit it to 5 ordered by date
|
668
|
+
# Billing.update_all( "author = 'David'", "title LIKE '%Rails%'",
|
669
|
+
# :order => 'created_at', :limit => 5 )
|
670
|
+
def update_all(updates, conditions = nil, options = {})
|
671
|
+
sql = "UPDATE #{table_name} SET #{sanitize_sql_for_assignment(updates)} "
|
672
|
+
scope = scope(:find)
|
673
|
+
add_conditions!(sql, conditions, scope)
|
674
|
+
add_order!(sql, options[:order], scope)
|
675
|
+
add_limit!(sql, options, scope)
|
676
|
+
connection.update(sql, "#{name} Update")
|
677
|
+
end
|
678
|
+
|
679
|
+
# Destroys the records matching +conditions+ by instantiating each record and calling the destroy method.
|
680
|
+
# This means at least 2*N database queries to destroy N records, so avoid destroy_all if you are deleting
|
681
|
+
# many records. If you want to simply delete records without worrying about dependent associations or
|
682
|
+
# callbacks, use the much faster +delete_all+ method instead.
|
683
|
+
#
|
684
|
+
# ==== Options
|
685
|
+
#
|
686
|
+
# +conditions+ Conditions are specified the same way as with +find+ method.
|
687
|
+
#
|
688
|
+
# ==== Example
|
689
|
+
#
|
690
|
+
# Person.destroy_all "last_login < '2004-04-04'"
|
691
|
+
#
|
692
|
+
# This loads and destroys each person one by one, including its dependent associations and before_ and
|
693
|
+
# after_destroy callbacks.
|
694
|
+
def destroy_all(conditions = nil)
|
695
|
+
find(:all, :conditions => conditions).each { |object| object.destroy }
|
696
|
+
end
|
697
|
+
|
698
|
+
# Deletes the records matching +conditions+ without instantiating the records first, and hence not
|
699
|
+
# calling the destroy method and invoking callbacks. This is a single SQL query, much more efficient
|
700
|
+
# than destroy_all.
|
701
|
+
#
|
702
|
+
# ==== Options
|
703
|
+
#
|
704
|
+
# +conditions+ Conditions are specified the same way as with +find+ method.
|
705
|
+
#
|
706
|
+
# ==== Example
|
707
|
+
#
|
708
|
+
# Post.delete_all "person_id = 5 AND (category = 'Something' OR category = 'Else')"
|
709
|
+
#
|
710
|
+
# This deletes the affected posts all at once with a single DELETE query. If you need to destroy dependent
|
711
|
+
# associations or call your before_ or after_destroy callbacks, use the +destroy_all+ method instead.
|
712
|
+
def delete_all(conditions = nil)
|
713
|
+
sql = "DELETE FROM #{quoted_table_name} "
|
714
|
+
add_conditions!(sql, conditions, scope(:find))
|
715
|
+
connection.delete(sql, "#{name} Delete all")
|
716
|
+
end
|
717
|
+
|
718
|
+
# Returns the result of an SQL statement that should only include a COUNT(*) in the SELECT part.
|
719
|
+
# The use of this method should be restricted to complicated SQL queries that can't be executed
|
720
|
+
# using the ActiveRecord::Calculations class methods. Look into those before using this.
|
721
|
+
#
|
722
|
+
# ==== Options
|
723
|
+
#
|
724
|
+
# +sql+: An SQL statement which should return a count query from the database, see the example below
|
725
|
+
#
|
726
|
+
# ==== Examples
|
727
|
+
#
|
728
|
+
# Product.count_by_sql "SELECT COUNT(*) FROM sales s, customers c WHERE s.customer_id = c.id"
|
729
|
+
def count_by_sql(sql)
|
730
|
+
sql = sanitize_conditions(sql)
|
731
|
+
connection.select_value(sql, "#{name} Count").to_i
|
732
|
+
end
|
733
|
+
|
734
|
+
# A generic "counter updater" implementation, intended primarily to be
|
735
|
+
# used by increment_counter and decrement_counter, but which may also
|
736
|
+
# be useful on its own. It simply does a direct SQL update for the record
|
737
|
+
# with the given ID, altering the given hash of counters by the amount
|
738
|
+
# given by the corresponding value:
|
739
|
+
#
|
740
|
+
# ==== Options
|
741
|
+
#
|
742
|
+
# +id+ The id of the object you wish to update a counter on
|
743
|
+
# +counters+ An Array of Hashes containing the names of the fields
|
744
|
+
# to update as keys and the amount to update the field by as
|
745
|
+
# values
|
746
|
+
#
|
747
|
+
# ==== Examples
|
748
|
+
#
|
749
|
+
# # For the Post with id of 5, decrement the comment_count by 1, and
|
750
|
+
# # increment the action_count by 1
|
751
|
+
# Post.update_counters 5, :comment_count => -1, :action_count => 1
|
752
|
+
# # Executes the following SQL:
|
753
|
+
# # UPDATE posts
|
754
|
+
# # SET comment_count = comment_count - 1,
|
755
|
+
# # action_count = action_count + 1
|
756
|
+
# # WHERE id = 5
|
757
|
+
def update_counters(id, counters)
|
758
|
+
updates = counters.inject([]) { |list, (counter_name, increment)|
|
759
|
+
sign = increment < 0 ? "-" : "+"
|
760
|
+
list << "#{connection.quote_column_name(counter_name)} = #{connection.quote_column_name(counter_name)} #{sign} #{increment.abs}"
|
761
|
+
}.join(", ")
|
762
|
+
update_all(updates, "#{connection.quote_column_name(primary_key)} = #{quote_value(id)}")
|
763
|
+
end
|
764
|
+
|
765
|
+
# Increment a number field by one, usually representing a count.
|
766
|
+
#
|
767
|
+
# This is used for caching aggregate values, so that they don't need to be computed every time.
|
768
|
+
# For example, a DiscussionBoard may cache post_count and comment_count otherwise every time the board is
|
769
|
+
# shown it would have to run an SQL query to find how many posts and comments there are.
|
770
|
+
#
|
771
|
+
# ==== Options
|
772
|
+
#
|
773
|
+
# +counter_name+ The name of the field that should be incremented
|
774
|
+
# +id+ The id of the object that should be incremented
|
775
|
+
#
|
776
|
+
# ==== Examples
|
777
|
+
#
|
778
|
+
# # Increment the post_count column for the record with an id of 5
|
779
|
+
# DiscussionBoard.increment_counter(:post_count, 5)
|
780
|
+
def increment_counter(counter_name, id)
|
781
|
+
update_counters(id, counter_name => 1)
|
782
|
+
end
|
783
|
+
|
784
|
+
# Decrement a number field by one, usually representing a count.
|
785
|
+
#
|
786
|
+
# This works the same as increment_counter but reduces the column value by 1 instead of increasing it.
|
787
|
+
#
|
788
|
+
# ==== Options
|
789
|
+
#
|
790
|
+
# +counter_name+ The name of the field that should be decremented
|
791
|
+
# +id+ The id of the object that should be decremented
|
792
|
+
#
|
793
|
+
# ==== Examples
|
794
|
+
#
|
795
|
+
# # Decrement the post_count column for the record with an id of 5
|
796
|
+
# DiscussionBoard.decrement_counter(:post_count, 5)
|
797
|
+
def decrement_counter(counter_name, id)
|
798
|
+
update_counters(id, counter_name => -1)
|
799
|
+
end
|
800
|
+
|
801
|
+
|
802
|
+
# Attributes named in this macro are protected from mass-assignment, such as <tt>new(attributes)</tt> and
|
803
|
+
# <tt>attributes=(attributes)</tt>. Their assignment will simply be ignored. Instead, you can use the direct writer
|
804
|
+
# methods to do assignment. This is meant to protect sensitive attributes from being overwritten by URL/form hackers. Example:
|
805
|
+
#
|
806
|
+
# class Customer < ActiveRecord::Base
|
807
|
+
# attr_protected :credit_rating
|
808
|
+
# end
|
809
|
+
#
|
810
|
+
# customer = Customer.new("name" => David, "credit_rating" => "Excellent")
|
811
|
+
# customer.credit_rating # => nil
|
812
|
+
# customer.attributes = { "description" => "Jolly fellow", "credit_rating" => "Superb" }
|
813
|
+
# customer.credit_rating # => nil
|
814
|
+
#
|
815
|
+
# customer.credit_rating = "Average"
|
816
|
+
# customer.credit_rating # => "Average"
|
817
|
+
#
|
818
|
+
# To start from an all-closed default and enable attributes as needed, have a look at attr_accessible.
|
819
|
+
def attr_protected(*attributes)
|
820
|
+
write_inheritable_attribute("attr_protected", Set.new(attributes.map(&:to_s)) + (protected_attributes || []))
|
821
|
+
end
|
822
|
+
|
823
|
+
# Returns an array of all the attributes that have been protected from mass-assignment.
|
824
|
+
def protected_attributes # :nodoc:
|
825
|
+
read_inheritable_attribute("attr_protected")
|
826
|
+
end
|
827
|
+
|
828
|
+
# Similar to the attr_protected macro, this protects attributes of your model from mass-assignment,
|
829
|
+
# such as <tt>new(attributes)</tt> and <tt>attributes=(attributes)</tt>
|
830
|
+
# however, it does it in the opposite way. This locks all attributes and only allows access to the
|
831
|
+
# attributes specified. Assignment to attributes not in this list will be ignored and need to be set
|
832
|
+
# using the direct writer methods instead. This is meant to protect sensitive attributes from being
|
833
|
+
# overwritten by URL/form hackers. If you'd rather start from an all-open default and restrict
|
834
|
+
# attributes as needed, have a look at attr_protected.
|
835
|
+
#
|
836
|
+
# ==== Options
|
837
|
+
#
|
838
|
+
# <tt>*attributes</tt> A comma separated list of symbols that represent columns _not_ to be protected
|
839
|
+
#
|
840
|
+
# ==== Examples
|
841
|
+
#
|
842
|
+
# class Customer < ActiveRecord::Base
|
843
|
+
# attr_accessible :name, :nickname
|
844
|
+
# end
|
845
|
+
#
|
846
|
+
# customer = Customer.new(:name => "David", :nickname => "Dave", :credit_rating => "Excellent")
|
847
|
+
# customer.credit_rating # => nil
|
848
|
+
# customer.attributes = { :name => "Jolly fellow", :credit_rating => "Superb" }
|
849
|
+
# customer.credit_rating # => nil
|
850
|
+
#
|
851
|
+
# customer.credit_rating = "Average"
|
852
|
+
# customer.credit_rating # => "Average"
|
853
|
+
def attr_accessible(*attributes)
|
854
|
+
write_inheritable_attribute("attr_accessible", Set.new(attributes.map(&:to_s)) + (accessible_attributes || []))
|
855
|
+
end
|
856
|
+
|
857
|
+
# Returns an array of all the attributes that have been made accessible to mass-assignment.
|
858
|
+
def accessible_attributes # :nodoc:
|
859
|
+
read_inheritable_attribute("attr_accessible")
|
860
|
+
end
|
861
|
+
|
862
|
+
# Attributes listed as readonly can be set for a new record, but will be ignored in database updates afterwards.
|
863
|
+
def attr_readonly(*attributes)
|
864
|
+
write_inheritable_attribute("attr_readonly", Set.new(attributes.map(&:to_s)) + (readonly_attributes || []))
|
865
|
+
end
|
866
|
+
|
867
|
+
# Returns an array of all the attributes that have been specified as readonly.
|
868
|
+
def readonly_attributes
|
869
|
+
read_inheritable_attribute("attr_readonly")
|
870
|
+
end
|
871
|
+
|
872
|
+
# If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object,
|
873
|
+
# then specify the name of that attribute using this method and it will be handled automatically.
|
874
|
+
# The serialization is done through YAML. If +class_name+ is specified, the serialized object must be of that
|
875
|
+
# class on retrieval or +SerializationTypeMismatch+ will be raised.
|
876
|
+
#
|
877
|
+
# ==== Options
|
878
|
+
#
|
879
|
+
# +attr_name+ The field name that should be serialized
|
880
|
+
# +class_name+ Optional, class name that the object type should be equal to
|
881
|
+
#
|
882
|
+
# ==== Example
|
883
|
+
# # Serialize a preferences attribute
|
884
|
+
# class User
|
885
|
+
# serialize :preferences
|
886
|
+
# end
|
887
|
+
def serialize(attr_name, class_name = Object)
|
888
|
+
serialized_attributes[attr_name.to_s] = class_name
|
889
|
+
end
|
890
|
+
|
891
|
+
# Returns a hash of all the attributes that have been specified for serialization as keys and their class restriction as values.
|
892
|
+
def serialized_attributes
|
893
|
+
read_inheritable_attribute("attr_serialized") or write_inheritable_attribute("attr_serialized", {})
|
894
|
+
end
|
895
|
+
|
896
|
+
|
897
|
+
# Guesses the table name (in forced lower-case) based on the name of the class in the inheritance hierarchy descending
|
898
|
+
# directly from ActiveRecord. So if the hierarchy looks like: Reply < Message < ActiveRecord, then Message is used
|
899
|
+
# to guess the table name even when called on Reply. The rules used to do the guess are handled by the Inflector class
|
900
|
+
# in Active Support, which knows almost all common English inflections. You can add new inflections in config/initializers/inflections.rb.
|
901
|
+
#
|
902
|
+
# Nested classes are given table names prefixed by the singular form of
|
903
|
+
# the parent's table name. Enclosing modules are not considered. Examples:
|
904
|
+
#
|
905
|
+
# class Invoice < ActiveRecord::Base; end;
|
906
|
+
# file class table_name
|
907
|
+
# invoice.rb Invoice invoices
|
908
|
+
#
|
909
|
+
# class Invoice < ActiveRecord::Base; class Lineitem < ActiveRecord::Base; end; end;
|
910
|
+
# file class table_name
|
911
|
+
# invoice.rb Invoice::Lineitem invoice_lineitems
|
912
|
+
#
|
913
|
+
# module Invoice; class Lineitem < ActiveRecord::Base; end; end;
|
914
|
+
# file class table_name
|
915
|
+
# invoice/lineitem.rb Invoice::Lineitem lineitems
|
916
|
+
#
|
917
|
+
# Additionally, the class-level table_name_prefix is prepended and the
|
918
|
+
# table_name_suffix is appended. So if you have "myapp_" as a prefix,
|
919
|
+
# the table name guess for an Invoice class becomes "myapp_invoices".
|
920
|
+
# Invoice::Lineitem becomes "myapp_invoice_lineitems".
|
921
|
+
#
|
922
|
+
# You can also overwrite this class method to allow for unguessable
|
923
|
+
# links, such as a Mouse class with a link to a "mice" table. Example:
|
924
|
+
#
|
925
|
+
# class Mouse < ActiveRecord::Base
|
926
|
+
# set_table_name "mice"
|
927
|
+
# end
|
928
|
+
def table_name
|
929
|
+
reset_table_name
|
930
|
+
end
|
931
|
+
|
932
|
+
def reset_table_name #:nodoc:
|
933
|
+
base = base_class
|
934
|
+
|
935
|
+
name =
|
936
|
+
# STI subclasses always use their superclass' table.
|
937
|
+
unless self == base
|
938
|
+
base.table_name
|
939
|
+
else
|
940
|
+
# Nested classes are prefixed with singular parent table name.
|
941
|
+
if parent < ActiveRecord::Base && !parent.abstract_class?
|
942
|
+
contained = parent.table_name
|
943
|
+
contained = contained.singularize if parent.pluralize_table_names
|
944
|
+
contained << '_'
|
945
|
+
end
|
946
|
+
name = "#{table_name_prefix}#{contained}#{undecorated_table_name(base.name)}#{table_name_suffix}"
|
947
|
+
end
|
948
|
+
|
949
|
+
set_table_name(name)
|
950
|
+
name
|
951
|
+
end
|
952
|
+
|
953
|
+
# Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the
|
954
|
+
# primary_key_prefix_type setting, though.
|
955
|
+
def primary_key
|
956
|
+
reset_primary_key
|
957
|
+
end
|
958
|
+
|
959
|
+
def reset_primary_key #:nodoc:
|
960
|
+
key = 'id'
|
961
|
+
case primary_key_prefix_type
|
962
|
+
when :table_name
|
963
|
+
key = Inflector.foreign_key(base_class.name, false)
|
964
|
+
when :table_name_with_underscore
|
965
|
+
key = Inflector.foreign_key(base_class.name)
|
966
|
+
end
|
967
|
+
set_primary_key(key)
|
968
|
+
key
|
969
|
+
end
|
970
|
+
|
971
|
+
# Defines the column name for use with single table inheritance
|
972
|
+
# -- can be set in subclasses like so: self.inheritance_column = "type_id"
|
973
|
+
def inheritance_column
|
974
|
+
@inheritance_column ||= "type".freeze
|
975
|
+
end
|
976
|
+
|
977
|
+
# Lazy-set the sequence name to the connection's default. This method
|
978
|
+
# is only ever called once since set_sequence_name overrides it.
|
979
|
+
def sequence_name #:nodoc:
|
980
|
+
reset_sequence_name
|
981
|
+
end
|
982
|
+
|
983
|
+
def reset_sequence_name #:nodoc:
|
984
|
+
default = connection.default_sequence_name(table_name, primary_key)
|
985
|
+
set_sequence_name(default)
|
986
|
+
default
|
987
|
+
end
|
988
|
+
|
989
|
+
# Sets the table name to use to the given value, or (if the value
|
990
|
+
# is nil or false) to the value returned by the given block.
|
991
|
+
#
|
992
|
+
# Example:
|
993
|
+
#
|
994
|
+
# class Project < ActiveRecord::Base
|
995
|
+
# set_table_name "project"
|
996
|
+
# end
|
997
|
+
def set_table_name(value = nil, &block)
|
998
|
+
define_attr_method :table_name, value, &block
|
999
|
+
end
|
1000
|
+
alias :table_name= :set_table_name
|
1001
|
+
|
1002
|
+
# Sets the name of the primary key column to use to the given value,
|
1003
|
+
# or (if the value is nil or false) to the value returned by the given
|
1004
|
+
# block.
|
1005
|
+
#
|
1006
|
+
# Example:
|
1007
|
+
#
|
1008
|
+
# class Project < ActiveRecord::Base
|
1009
|
+
# set_primary_key "sysid"
|
1010
|
+
# end
|
1011
|
+
def set_primary_key(value = nil, &block)
|
1012
|
+
define_attr_method :primary_key, value, &block
|
1013
|
+
end
|
1014
|
+
alias :primary_key= :set_primary_key
|
1015
|
+
|
1016
|
+
# Sets the name of the inheritance column to use to the given value,
|
1017
|
+
# or (if the value # is nil or false) to the value returned by the
|
1018
|
+
# given block.
|
1019
|
+
#
|
1020
|
+
# Example:
|
1021
|
+
#
|
1022
|
+
# class Project < ActiveRecord::Base
|
1023
|
+
# set_inheritance_column do
|
1024
|
+
# original_inheritance_column + "_id"
|
1025
|
+
# end
|
1026
|
+
# end
|
1027
|
+
def set_inheritance_column(value = nil, &block)
|
1028
|
+
define_attr_method :inheritance_column, value, &block
|
1029
|
+
end
|
1030
|
+
alias :inheritance_column= :set_inheritance_column
|
1031
|
+
|
1032
|
+
# Sets the name of the sequence to use when generating ids to the given
|
1033
|
+
# value, or (if the value is nil or false) to the value returned by the
|
1034
|
+
# given block. This is required for Oracle and is useful for any
|
1035
|
+
# database which relies on sequences for primary key generation.
|
1036
|
+
#
|
1037
|
+
# If a sequence name is not explicitly set when using Oracle or Firebird,
|
1038
|
+
# it will default to the commonly used pattern of: #{table_name}_seq
|
1039
|
+
#
|
1040
|
+
# If a sequence name is not explicitly set when using PostgreSQL, it
|
1041
|
+
# will discover the sequence corresponding to your primary key for you.
|
1042
|
+
#
|
1043
|
+
# Example:
|
1044
|
+
#
|
1045
|
+
# class Project < ActiveRecord::Base
|
1046
|
+
# set_sequence_name "projectseq" # default would have been "project_seq"
|
1047
|
+
# end
|
1048
|
+
def set_sequence_name(value = nil, &block)
|
1049
|
+
define_attr_method :sequence_name, value, &block
|
1050
|
+
end
|
1051
|
+
alias :sequence_name= :set_sequence_name
|
1052
|
+
|
1053
|
+
# Turns the +table_name+ back into a class name following the reverse rules of +table_name+.
|
1054
|
+
def class_name(table_name = table_name) # :nodoc:
|
1055
|
+
# remove any prefix and/or suffix from the table name
|
1056
|
+
class_name = table_name[table_name_prefix.length..-(table_name_suffix.length + 1)].camelize
|
1057
|
+
class_name = class_name.singularize if pluralize_table_names
|
1058
|
+
class_name
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
# Indicates whether the table associated with this class exists
|
1062
|
+
def table_exists?
|
1063
|
+
if connection.respond_to?(:tables)
|
1064
|
+
connection.tables.include? table_name
|
1065
|
+
else
|
1066
|
+
# if the connection adapter hasn't implemented tables, there are two crude tests that can be
|
1067
|
+
# used - see if getting column info raises an error, or if the number of columns returned is zero
|
1068
|
+
begin
|
1069
|
+
reset_column_information
|
1070
|
+
columns.size > 0
|
1071
|
+
rescue ActiveRecord::StatementInvalid
|
1072
|
+
false
|
1073
|
+
end
|
1074
|
+
end
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
# Returns an array of column objects for the table associated with this class.
|
1078
|
+
def columns
|
1079
|
+
unless @columns
|
1080
|
+
@columns = connection.columns(table_name, "#{name} Columns")
|
1081
|
+
@columns.each {|column| column.primary = column.name == primary_key}
|
1082
|
+
end
|
1083
|
+
@columns
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
# Returns a hash of column objects for the table associated with this class.
|
1087
|
+
def columns_hash
|
1088
|
+
@columns_hash ||= columns.inject({}) { |hash, column| hash[column.name] = column; hash }
|
1089
|
+
end
|
1090
|
+
|
1091
|
+
# Returns an array of column names as strings.
|
1092
|
+
def column_names
|
1093
|
+
@column_names ||= columns.map { |column| column.name }
|
1094
|
+
end
|
1095
|
+
|
1096
|
+
# Returns an array of column objects where the primary id, all columns ending in "_id" or "_count",
|
1097
|
+
# and columns used for single table inheritance have been removed.
|
1098
|
+
def content_columns
|
1099
|
+
@content_columns ||= columns.reject { |c| c.primary || c.name =~ /(_id|_count)$/ || c.name == inheritance_column }
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
# Returns a hash of all the methods added to query each of the columns in the table with the name of the method as the key
|
1103
|
+
# and true as the value. This makes it possible to do O(1) lookups in respond_to? to check if a given method for attribute
|
1104
|
+
# is available.
|
1105
|
+
def column_methods_hash #:nodoc:
|
1106
|
+
@dynamic_methods_hash ||= column_names.inject(Hash.new(false)) do |methods, attr|
|
1107
|
+
attr_name = attr.to_s
|
1108
|
+
methods[attr.to_sym] = attr_name
|
1109
|
+
methods["#{attr}=".to_sym] = attr_name
|
1110
|
+
methods["#{attr}?".to_sym] = attr_name
|
1111
|
+
methods["#{attr}_before_type_cast".to_sym] = attr_name
|
1112
|
+
methods
|
1113
|
+
end
|
1114
|
+
end
|
1115
|
+
|
1116
|
+
# Resets all the cached information about columns, which will cause them to be reloaded on the next request.
|
1117
|
+
def reset_column_information
|
1118
|
+
generated_methods.each { |name| undef_method(name) }
|
1119
|
+
@column_names = @columns = @columns_hash = @content_columns = @dynamic_methods_hash = @generated_methods = @inheritance_column = nil
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
def reset_column_information_and_inheritable_attributes_for_all_subclasses#:nodoc:
|
1123
|
+
subclasses.each { |klass| klass.reset_inheritable_attributes; klass.reset_column_information }
|
1124
|
+
end
|
1125
|
+
|
1126
|
+
# Transforms attribute key names into a more humane format, such as "First name" instead of "first_name". Example:
|
1127
|
+
# Person.human_attribute_name("first_name") # => "First name"
|
1128
|
+
# Deprecated in favor of just calling "first_name".humanize
|
1129
|
+
def human_attribute_name(attribute_key_name) #:nodoc:
|
1130
|
+
attribute_key_name.humanize
|
1131
|
+
end
|
1132
|
+
|
1133
|
+
# True if this isn't a concrete subclass needing a STI type condition.
|
1134
|
+
def descends_from_active_record?
|
1135
|
+
if superclass.abstract_class?
|
1136
|
+
superclass.descends_from_active_record?
|
1137
|
+
else
|
1138
|
+
superclass == Base || !columns_hash.include?(inheritance_column)
|
1139
|
+
end
|
1140
|
+
end
|
1141
|
+
|
1142
|
+
def finder_needs_type_condition? #:nodoc:
|
1143
|
+
# This is like this because benchmarking justifies the strange :false stuff
|
1144
|
+
:true == (@finder_needs_type_condition ||= descends_from_active_record? ? :false : :true)
|
1145
|
+
end
|
1146
|
+
|
1147
|
+
# Returns a string like 'Post id:integer, title:string, body:text'
|
1148
|
+
def inspect
|
1149
|
+
if self == Base
|
1150
|
+
super
|
1151
|
+
elsif abstract_class?
|
1152
|
+
"#{super}(abstract)"
|
1153
|
+
elsif table_exists?
|
1154
|
+
attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', '
|
1155
|
+
"#{super}(#{attr_list})"
|
1156
|
+
else
|
1157
|
+
"#{super}(Table doesn't exist)"
|
1158
|
+
end
|
1159
|
+
end
|
1160
|
+
|
1161
|
+
|
1162
|
+
def quote_value(value, column = nil) #:nodoc:
|
1163
|
+
connection.quote(value,column)
|
1164
|
+
end
|
1165
|
+
|
1166
|
+
# Used to sanitize objects before they're used in an SQL SELECT statement. Delegates to <tt>connection.quote</tt>.
|
1167
|
+
def sanitize(object) #:nodoc:
|
1168
|
+
connection.quote(object)
|
1169
|
+
end
|
1170
|
+
|
1171
|
+
# Log and benchmark multiple statements in a single block. Example:
|
1172
|
+
#
|
1173
|
+
# Project.benchmark("Creating project") do
|
1174
|
+
# project = Project.create("name" => "stuff")
|
1175
|
+
# project.create_manager("name" => "David")
|
1176
|
+
# project.milestones << Milestone.find(:all)
|
1177
|
+
# end
|
1178
|
+
#
|
1179
|
+
# The benchmark is only recorded if the current level of the logger matches the <tt>log_level</tt>, which makes it
|
1180
|
+
# easy to include benchmarking statements in production software that will remain inexpensive because the benchmark
|
1181
|
+
# will only be conducted if the log level is low enough.
|
1182
|
+
#
|
1183
|
+
# The logging of the multiple statements is turned off unless <tt>use_silence</tt> is set to false.
|
1184
|
+
def benchmark(title, log_level = Logger::DEBUG, use_silence = true)
|
1185
|
+
if logger && logger.level == log_level
|
1186
|
+
result = nil
|
1187
|
+
seconds = Benchmark.realtime { result = use_silence ? silence { yield } : yield }
|
1188
|
+
logger.add(log_level, "#{title} (#{'%.5f' % seconds})")
|
1189
|
+
result
|
1190
|
+
else
|
1191
|
+
yield
|
1192
|
+
end
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
# Silences the logger for the duration of the block.
|
1196
|
+
def silence
|
1197
|
+
old_logger_level, logger.level = logger.level, Logger::ERROR if logger
|
1198
|
+
yield
|
1199
|
+
ensure
|
1200
|
+
logger.level = old_logger_level if logger
|
1201
|
+
end
|
1202
|
+
|
1203
|
+
# Overwrite the default class equality method to provide support for association proxies.
|
1204
|
+
def ===(object)
|
1205
|
+
object.is_a?(self)
|
1206
|
+
end
|
1207
|
+
|
1208
|
+
# Returns the base AR subclass that this class descends from. If A
|
1209
|
+
# extends AR::Base, A.base_class will return A. If B descends from A
|
1210
|
+
# through some arbitrarily deep hierarchy, B.base_class will return A.
|
1211
|
+
def base_class
|
1212
|
+
class_of_active_record_descendant(self)
|
1213
|
+
end
|
1214
|
+
|
1215
|
+
# Set this to true if this is an abstract class (see #abstract_class?).
|
1216
|
+
attr_accessor :abstract_class
|
1217
|
+
|
1218
|
+
# Returns whether this class is a base AR class. If A is a base class and
|
1219
|
+
# B descends from A, then B.base_class will return B.
|
1220
|
+
def abstract_class?
|
1221
|
+
abstract_class == true
|
1222
|
+
end
|
1223
|
+
|
1224
|
+
private
|
1225
|
+
def find_initial(options)
|
1226
|
+
options.update(:limit => 1) unless options[:include]
|
1227
|
+
find_every(options).first
|
1228
|
+
end
|
1229
|
+
|
1230
|
+
def find_every(options)
|
1231
|
+
records = scoped?(:find, :include) || options[:include] ?
|
1232
|
+
find_with_associations(options) :
|
1233
|
+
find_by_sql(construct_finder_sql(options))
|
1234
|
+
|
1235
|
+
records.each { |record| record.readonly! } if options[:readonly]
|
1236
|
+
|
1237
|
+
records
|
1238
|
+
end
|
1239
|
+
|
1240
|
+
def find_from_ids(ids, options)
|
1241
|
+
expects_array = ids.first.kind_of?(Array)
|
1242
|
+
return ids.first if expects_array && ids.first.empty?
|
1243
|
+
|
1244
|
+
ids = ids.flatten.compact.uniq
|
1245
|
+
|
1246
|
+
case ids.size
|
1247
|
+
when 0
|
1248
|
+
raise RecordNotFound, "Couldn't find #{name} without an ID"
|
1249
|
+
when 1
|
1250
|
+
result = find_one(ids.first, options)
|
1251
|
+
expects_array ? [ result ] : result
|
1252
|
+
else
|
1253
|
+
find_some(ids, options)
|
1254
|
+
end
|
1255
|
+
end
|
1256
|
+
|
1257
|
+
def find_one(id, options)
|
1258
|
+
conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]
|
1259
|
+
options.update :conditions => "#{quoted_table_name}.#{connection.quote_column_name(primary_key)} = #{quote_value(id,columns_hash[primary_key])}#{conditions}"
|
1260
|
+
|
1261
|
+
# Use find_every(options).first since the primary key condition
|
1262
|
+
# already ensures we have a single record. Using find_initial adds
|
1263
|
+
# a superfluous :limit => 1.
|
1264
|
+
if result = find_every(options).first
|
1265
|
+
result
|
1266
|
+
else
|
1267
|
+
raise RecordNotFound, "Couldn't find #{name} with ID=#{id}#{conditions}"
|
1268
|
+
end
|
1269
|
+
end
|
1270
|
+
|
1271
|
+
def find_some(ids, options)
|
1272
|
+
conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]
|
1273
|
+
ids_list = ids.map { |id| quote_value(id,columns_hash[primary_key]) }.join(',')
|
1274
|
+
options.update :conditions => "#{quoted_table_name}.#{connection.quote_column_name(primary_key)} IN (#{ids_list})#{conditions}"
|
1275
|
+
|
1276
|
+
result = find_every(options)
|
1277
|
+
|
1278
|
+
# Determine expected size from limit and offset, not just ids.size.
|
1279
|
+
expected_size =
|
1280
|
+
if options[:limit] && ids.size > options[:limit]
|
1281
|
+
options[:limit]
|
1282
|
+
else
|
1283
|
+
ids.size
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
# 11 ids with limit 3, offset 9 should give 2 results.
|
1287
|
+
if options[:offset] && (ids.size - options[:offset] < expected_size)
|
1288
|
+
expected_size = ids.size - options[:offset]
|
1289
|
+
end
|
1290
|
+
|
1291
|
+
if result.size == expected_size
|
1292
|
+
result
|
1293
|
+
else
|
1294
|
+
raise RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids_list})#{conditions} (found #{result.size} results, but was looking for #{expected_size})"
|
1295
|
+
end
|
1296
|
+
end
|
1297
|
+
|
1298
|
+
# Finder methods must instantiate through this method to work with the
|
1299
|
+
# single-table inheritance model that makes it possible to create
|
1300
|
+
# objects of different types from the same table.
|
1301
|
+
def instantiate(record)
|
1302
|
+
object =
|
1303
|
+
if subclass_name = record[inheritance_column]
|
1304
|
+
# No type given.
|
1305
|
+
if subclass_name.empty?
|
1306
|
+
allocate
|
1307
|
+
|
1308
|
+
else
|
1309
|
+
# Ignore type if no column is present since it was probably
|
1310
|
+
# pulled in from a sloppy join.
|
1311
|
+
unless columns_hash.include?(inheritance_column)
|
1312
|
+
allocate
|
1313
|
+
|
1314
|
+
else
|
1315
|
+
begin
|
1316
|
+
compute_type(subclass_name).allocate
|
1317
|
+
rescue NameError
|
1318
|
+
raise SubclassNotFound,
|
1319
|
+
"The single-table inheritance mechanism failed to locate the subclass: '#{record[inheritance_column]}'. " +
|
1320
|
+
"This error is raised because the column '#{inheritance_column}' is reserved for storing the class in case of inheritance. " +
|
1321
|
+
"Please rename this column if you didn't intend it to be used for storing the inheritance class " +
|
1322
|
+
"or overwrite #{self.to_s}.inheritance_column to use another column for that information."
|
1323
|
+
end
|
1324
|
+
end
|
1325
|
+
end
|
1326
|
+
else
|
1327
|
+
allocate
|
1328
|
+
end
|
1329
|
+
|
1330
|
+
object.instance_variable_set("@attributes", record)
|
1331
|
+
object.instance_variable_set("@attributes_cache", Hash.new)
|
1332
|
+
|
1333
|
+
if object.respond_to_without_attributes?(:after_find)
|
1334
|
+
object.send(:callback, :after_find)
|
1335
|
+
end
|
1336
|
+
|
1337
|
+
if object.respond_to_without_attributes?(:after_initialize)
|
1338
|
+
object.send(:callback, :after_initialize)
|
1339
|
+
end
|
1340
|
+
|
1341
|
+
object
|
1342
|
+
end
|
1343
|
+
|
1344
|
+
# Nest the type name in the same module as this class.
|
1345
|
+
# Bar is "MyApp::Business::Bar" relative to MyApp::Business::Foo
|
1346
|
+
def type_name_with_module(type_name)
|
1347
|
+
(/^::/ =~ type_name) ? type_name : "#{parent.name}::#{type_name}"
|
1348
|
+
end
|
1349
|
+
|
1350
|
+
def construct_finder_sql(options)
|
1351
|
+
scope = scope(:find)
|
1352
|
+
sql = "SELECT #{(scope && scope[:select]) || options[:select] || (options[:joins] && quoted_table_name + '.*') || '*'} "
|
1353
|
+
sql << "FROM #{(scope && scope[:from]) || options[:from] || quoted_table_name} "
|
1354
|
+
|
1355
|
+
add_joins!(sql, options, scope)
|
1356
|
+
add_conditions!(sql, options[:conditions], scope)
|
1357
|
+
|
1358
|
+
add_group!(sql, options[:group], scope)
|
1359
|
+
add_order!(sql, options[:order], scope)
|
1360
|
+
add_limit!(sql, options, scope)
|
1361
|
+
add_lock!(sql, options, scope)
|
1362
|
+
|
1363
|
+
sql
|
1364
|
+
end
|
1365
|
+
|
1366
|
+
# Merges includes so that the result is a valid +include+
|
1367
|
+
def merge_includes(first, second)
|
1368
|
+
(safe_to_array(first) + safe_to_array(second)).uniq
|
1369
|
+
end
|
1370
|
+
|
1371
|
+
# Object#to_a is deprecated, though it does have the desired behavior
|
1372
|
+
def safe_to_array(o)
|
1373
|
+
case o
|
1374
|
+
when NilClass
|
1375
|
+
[]
|
1376
|
+
when Array
|
1377
|
+
o
|
1378
|
+
else
|
1379
|
+
[o]
|
1380
|
+
end
|
1381
|
+
end
|
1382
|
+
|
1383
|
+
def add_order!(sql, order, scope = :auto)
|
1384
|
+
scope = scope(:find) if :auto == scope
|
1385
|
+
scoped_order = scope[:order] if scope
|
1386
|
+
if order
|
1387
|
+
sql << " ORDER BY #{order}"
|
1388
|
+
sql << ", #{scoped_order}" if scoped_order
|
1389
|
+
else
|
1390
|
+
sql << " ORDER BY #{scoped_order}" if scoped_order
|
1391
|
+
end
|
1392
|
+
end
|
1393
|
+
|
1394
|
+
def add_group!(sql, group, scope = :auto)
|
1395
|
+
if group
|
1396
|
+
sql << " GROUP BY #{group}"
|
1397
|
+
else
|
1398
|
+
scope = scope(:find) if :auto == scope
|
1399
|
+
if scope && (scoped_group = scope[:group])
|
1400
|
+
sql << " GROUP BY #{scoped_group}"
|
1401
|
+
end
|
1402
|
+
end
|
1403
|
+
end
|
1404
|
+
|
1405
|
+
# The optional scope argument is for the current :find scope.
|
1406
|
+
def add_limit!(sql, options, scope = :auto)
|
1407
|
+
scope = scope(:find) if :auto == scope
|
1408
|
+
|
1409
|
+
if scope
|
1410
|
+
options[:limit] ||= scope[:limit]
|
1411
|
+
options[:offset] ||= scope[:offset]
|
1412
|
+
end
|
1413
|
+
|
1414
|
+
connection.add_limit_offset!(sql, options)
|
1415
|
+
end
|
1416
|
+
|
1417
|
+
# The optional scope argument is for the current :find scope.
|
1418
|
+
# The :lock option has precedence over a scoped :lock.
|
1419
|
+
def add_lock!(sql, options, scope = :auto)
|
1420
|
+
scope = scope(:find) if :auto == scope
|
1421
|
+
options = options.reverse_merge(:lock => scope[:lock]) if scope
|
1422
|
+
connection.add_lock!(sql, options)
|
1423
|
+
end
|
1424
|
+
|
1425
|
+
# The optional scope argument is for the current :find scope.
|
1426
|
+
def add_joins!(sql, options, scope = :auto)
|
1427
|
+
scope = scope(:find) if :auto == scope
|
1428
|
+
join = (scope && scope[:joins]) || options[:joins]
|
1429
|
+
case join
|
1430
|
+
when Symbol, Hash, Array
|
1431
|
+
join_dependency = ActiveRecord::Associations::ClassMethods::InnerJoinDependency.new(self, join, nil)
|
1432
|
+
sql << " #{join_dependency.join_associations.collect{|join| join.association_join }.join} "
|
1433
|
+
else
|
1434
|
+
sql << " #{join} "
|
1435
|
+
end
|
1436
|
+
end
|
1437
|
+
|
1438
|
+
# Adds a sanitized version of +conditions+ to the +sql+ string. Note that the passed-in +sql+ string is changed.
|
1439
|
+
# The optional scope argument is for the current :find scope.
|
1440
|
+
def add_conditions!(sql, conditions, scope = :auto)
|
1441
|
+
scope = scope(:find) if :auto == scope
|
1442
|
+
segments = []
|
1443
|
+
segments << sanitize_sql(scope[:conditions]) if scope && !scope[:conditions].blank?
|
1444
|
+
segments << sanitize_sql(conditions) unless conditions.blank?
|
1445
|
+
segments << type_condition if finder_needs_type_condition?
|
1446
|
+
segments.delete_if{|s| s.blank?}
|
1447
|
+
sql << "WHERE (#{segments.join(") AND (")}) " unless segments.empty?
|
1448
|
+
end
|
1449
|
+
|
1450
|
+
def type_condition
|
1451
|
+
quoted_inheritance_column = connection.quote_column_name(inheritance_column)
|
1452
|
+
type_condition = subclasses.inject("#{quoted_table_name}.#{quoted_inheritance_column} = '#{name.demodulize}' ") do |condition, subclass|
|
1453
|
+
condition << "OR #{quoted_table_name}.#{quoted_inheritance_column} = '#{subclass.name.demodulize}' "
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
" (#{type_condition}) "
|
1457
|
+
end
|
1458
|
+
|
1459
|
+
# Guesses the table name, but does not decorate it with prefix and suffix information.
|
1460
|
+
def undecorated_table_name(class_name = base_class.name)
|
1461
|
+
table_name = Inflector.underscore(Inflector.demodulize(class_name))
|
1462
|
+
table_name = Inflector.pluralize(table_name) if pluralize_table_names
|
1463
|
+
table_name
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
# Enables dynamic finders like find_by_user_name(user_name) and find_by_user_name_and_password(user_name, password) that are turned into
|
1467
|
+
# find(:first, :conditions => ["user_name = ?", user_name]) and find(:first, :conditions => ["user_name = ? AND password = ?", user_name, password])
|
1468
|
+
# respectively. Also works for find(:all) by using find_all_by_amount(50) that is turned into find(:all, :conditions => ["amount = ?", 50]).
|
1469
|
+
#
|
1470
|
+
# It's even possible to use all the additional parameters to find. For example, the full interface for find_all_by_amount
|
1471
|
+
# is actually find_all_by_amount(amount, options).
|
1472
|
+
#
|
1473
|
+
# This also enables you to initialize a record if it is not found, such as find_or_initialize_by_amount(amount)
|
1474
|
+
# or find_or_create_by_user_and_password(user, password).
|
1475
|
+
#
|
1476
|
+
# Each dynamic finder or initializer/creator is also defined in the class after it is first invoked, so that future
|
1477
|
+
# attempts to use it do not run through method_missing.
|
1478
|
+
def method_missing(method_id, *arguments)
|
1479
|
+
if match = /^find_(all_by|by)_([_a-zA-Z]\w*)$/.match(method_id.to_s)
|
1480
|
+
finder = determine_finder(match)
|
1481
|
+
|
1482
|
+
attribute_names = extract_attribute_names_from_match(match)
|
1483
|
+
super unless all_attributes_exists?(attribute_names)
|
1484
|
+
|
1485
|
+
self.class_eval %{
|
1486
|
+
def self.#{method_id}(*args)
|
1487
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
1488
|
+
attributes = construct_attributes_from_arguments([:#{attribute_names.join(',:')}], args)
|
1489
|
+
finder_options = { :conditions => attributes }
|
1490
|
+
validate_find_options(options)
|
1491
|
+
set_readonly_option!(options)
|
1492
|
+
|
1493
|
+
if options[:conditions]
|
1494
|
+
with_scope(:find => finder_options) do
|
1495
|
+
ActiveSupport::Deprecation.silence { send(:#{finder}, options) }
|
1496
|
+
end
|
1497
|
+
else
|
1498
|
+
ActiveSupport::Deprecation.silence { send(:#{finder}, options.merge(finder_options)) }
|
1499
|
+
end
|
1500
|
+
end
|
1501
|
+
}, __FILE__, __LINE__
|
1502
|
+
send(method_id, *arguments)
|
1503
|
+
elsif match = /^find_or_(initialize|create)_by_([_a-zA-Z]\w*)$/.match(method_id.to_s)
|
1504
|
+
instantiator = determine_instantiator(match)
|
1505
|
+
attribute_names = extract_attribute_names_from_match(match)
|
1506
|
+
super unless all_attributes_exists?(attribute_names)
|
1507
|
+
|
1508
|
+
self.class_eval %{
|
1509
|
+
def self.#{method_id}(*args)
|
1510
|
+
if args[0].is_a?(Hash)
|
1511
|
+
attributes = args[0].with_indifferent_access
|
1512
|
+
find_attributes = attributes.slice(*[:#{attribute_names.join(',:')}])
|
1513
|
+
else
|
1514
|
+
find_attributes = attributes = construct_attributes_from_arguments([:#{attribute_names.join(',:')}], args)
|
1515
|
+
end
|
1516
|
+
|
1517
|
+
options = { :conditions => find_attributes }
|
1518
|
+
set_readonly_option!(options)
|
1519
|
+
|
1520
|
+
record = find_initial(options)
|
1521
|
+
if record.nil?
|
1522
|
+
record = self.new { |r| r.send(:attributes=, attributes, false) }
|
1523
|
+
#{'record.save' if instantiator == :create}
|
1524
|
+
record
|
1525
|
+
else
|
1526
|
+
record
|
1527
|
+
end
|
1528
|
+
end
|
1529
|
+
}, __FILE__, __LINE__
|
1530
|
+
send(method_id, *arguments)
|
1531
|
+
else
|
1532
|
+
super
|
1533
|
+
end
|
1534
|
+
end
|
1535
|
+
|
1536
|
+
def determine_finder(match)
|
1537
|
+
match.captures.first == 'all_by' ? :find_every : :find_initial
|
1538
|
+
end
|
1539
|
+
|
1540
|
+
def determine_instantiator(match)
|
1541
|
+
match.captures.first == 'initialize' ? :new : :create
|
1542
|
+
end
|
1543
|
+
|
1544
|
+
def extract_attribute_names_from_match(match)
|
1545
|
+
match.captures.last.split('_and_')
|
1546
|
+
end
|
1547
|
+
|
1548
|
+
def construct_attributes_from_arguments(attribute_names, arguments)
|
1549
|
+
attributes = {}
|
1550
|
+
attribute_names.each_with_index { |name, idx| attributes[name] = arguments[idx] }
|
1551
|
+
attributes
|
1552
|
+
end
|
1553
|
+
|
1554
|
+
def all_attributes_exists?(attribute_names)
|
1555
|
+
attribute_names.all? { |name| column_methods_hash.include?(name.to_sym) }
|
1556
|
+
end
|
1557
|
+
|
1558
|
+
def attribute_condition(argument)
|
1559
|
+
case argument
|
1560
|
+
when nil then "IS ?"
|
1561
|
+
when Array, ActiveRecord::Associations::AssociationCollection then "IN (?)"
|
1562
|
+
when Range then "BETWEEN ? AND ?"
|
1563
|
+
else "= ?"
|
1564
|
+
end
|
1565
|
+
end
|
1566
|
+
|
1567
|
+
# Interpret Array and Hash as conditions and anything else as an id.
|
1568
|
+
def expand_id_conditions(id_or_conditions)
|
1569
|
+
case id_or_conditions
|
1570
|
+
when Array, Hash then id_or_conditions
|
1571
|
+
else sanitize_sql(primary_key => id_or_conditions)
|
1572
|
+
end
|
1573
|
+
end
|
1574
|
+
|
1575
|
+
|
1576
|
+
# Defines an "attribute" method (like #inheritance_column or
|
1577
|
+
# #table_name). A new (class) method will be created with the
|
1578
|
+
# given name. If a value is specified, the new method will
|
1579
|
+
# return that value (as a string). Otherwise, the given block
|
1580
|
+
# will be used to compute the value of the method.
|
1581
|
+
#
|
1582
|
+
# The original method will be aliased, with the new name being
|
1583
|
+
# prefixed with "original_". This allows the new method to
|
1584
|
+
# access the original value.
|
1585
|
+
#
|
1586
|
+
# Example:
|
1587
|
+
#
|
1588
|
+
# class A < ActiveRecord::Base
|
1589
|
+
# define_attr_method :primary_key, "sysid"
|
1590
|
+
# define_attr_method( :inheritance_column ) do
|
1591
|
+
# original_inheritance_column + "_id"
|
1592
|
+
# end
|
1593
|
+
# end
|
1594
|
+
def define_attr_method(name, value=nil, &block)
|
1595
|
+
sing = class << self; self; end
|
1596
|
+
sing.send :alias_method, "original_#{name}", name
|
1597
|
+
if block_given?
|
1598
|
+
sing.send :define_method, name, &block
|
1599
|
+
else
|
1600
|
+
# use eval instead of a block to work around a memory leak in dev
|
1601
|
+
# mode in fcgi
|
1602
|
+
sing.class_eval "def #{name}; #{value.to_s.inspect}; end"
|
1603
|
+
end
|
1604
|
+
end
|
1605
|
+
|
1606
|
+
protected
|
1607
|
+
# Scope parameters to method calls within the block. Takes a hash of method_name => parameters hash.
|
1608
|
+
# method_name may be :find or :create. :find parameters may include the <tt>:conditions</tt>, <tt>:joins</tt>,
|
1609
|
+
# <tt>:include</tt>, <tt>:offset</tt>, <tt>:limit</tt>, and <tt>:readonly</tt> options. :create parameters are an attributes hash.
|
1610
|
+
#
|
1611
|
+
# class Article < ActiveRecord::Base
|
1612
|
+
# def self.create_with_scope
|
1613
|
+
# with_scope(:find => { :conditions => "blog_id = 1" }, :create => { :blog_id => 1 }) do
|
1614
|
+
# find(1) # => SELECT * from articles WHERE blog_id = 1 AND id = 1
|
1615
|
+
# a = create(1)
|
1616
|
+
# a.blog_id # => 1
|
1617
|
+
# end
|
1618
|
+
# end
|
1619
|
+
# end
|
1620
|
+
#
|
1621
|
+
# In nested scopings, all previous parameters are overwritten by the innermost rule, with the exception of
|
1622
|
+
# :conditions and :include options in :find, which are merged.
|
1623
|
+
#
|
1624
|
+
# class Article < ActiveRecord::Base
|
1625
|
+
# def self.find_with_scope
|
1626
|
+
# with_scope(:find => { :conditions => "blog_id = 1", :limit => 1 }, :create => { :blog_id => 1 }) do
|
1627
|
+
# with_scope(:find => { :limit => 10})
|
1628
|
+
# find(:all) # => SELECT * from articles WHERE blog_id = 1 LIMIT 10
|
1629
|
+
# end
|
1630
|
+
# with_scope(:find => { :conditions => "author_id = 3" })
|
1631
|
+
# find(:all) # => SELECT * from articles WHERE blog_id = 1 AND author_id = 3 LIMIT 1
|
1632
|
+
# end
|
1633
|
+
# end
|
1634
|
+
# end
|
1635
|
+
# end
|
1636
|
+
#
|
1637
|
+
# You can ignore any previous scopings by using the <tt>with_exclusive_scope</tt> method.
|
1638
|
+
#
|
1639
|
+
# class Article < ActiveRecord::Base
|
1640
|
+
# def self.find_with_exclusive_scope
|
1641
|
+
# with_scope(:find => { :conditions => "blog_id = 1", :limit => 1 }) do
|
1642
|
+
# with_exclusive_scope(:find => { :limit => 10 })
|
1643
|
+
# find(:all) # => SELECT * from articles LIMIT 10
|
1644
|
+
# end
|
1645
|
+
# end
|
1646
|
+
# end
|
1647
|
+
# end
|
1648
|
+
def with_scope(method_scoping = {}, action = :merge, &block)
|
1649
|
+
method_scoping = method_scoping.method_scoping if method_scoping.respond_to?(:method_scoping)
|
1650
|
+
|
1651
|
+
# Dup first and second level of hash (method and params).
|
1652
|
+
method_scoping = method_scoping.inject({}) do |hash, (method, params)|
|
1653
|
+
hash[method] = (params == true) ? params : params.dup
|
1654
|
+
hash
|
1655
|
+
end
|
1656
|
+
|
1657
|
+
method_scoping.assert_valid_keys([ :find, :create ])
|
1658
|
+
|
1659
|
+
if f = method_scoping[:find]
|
1660
|
+
f.assert_valid_keys(VALID_FIND_OPTIONS)
|
1661
|
+
set_readonly_option! f
|
1662
|
+
end
|
1663
|
+
|
1664
|
+
# Merge scopings
|
1665
|
+
if action == :merge && current_scoped_methods
|
1666
|
+
method_scoping = current_scoped_methods.inject(method_scoping) do |hash, (method, params)|
|
1667
|
+
case hash[method]
|
1668
|
+
when Hash
|
1669
|
+
if method == :find
|
1670
|
+
(hash[method].keys + params.keys).uniq.each do |key|
|
1671
|
+
merge = hash[method][key] && params[key] # merge if both scopes have the same key
|
1672
|
+
if key == :conditions && merge
|
1673
|
+
hash[method][key] = [params[key], hash[method][key]].collect{ |sql| "( %s )" % sanitize_sql(sql) }.join(" AND ")
|
1674
|
+
elsif key == :include && merge
|
1675
|
+
hash[method][key] = merge_includes(hash[method][key], params[key]).uniq
|
1676
|
+
else
|
1677
|
+
hash[method][key] = hash[method][key] || params[key]
|
1678
|
+
end
|
1679
|
+
end
|
1680
|
+
else
|
1681
|
+
hash[method] = params.merge(hash[method])
|
1682
|
+
end
|
1683
|
+
else
|
1684
|
+
hash[method] = params
|
1685
|
+
end
|
1686
|
+
hash
|
1687
|
+
end
|
1688
|
+
end
|
1689
|
+
|
1690
|
+
self.scoped_methods << method_scoping
|
1691
|
+
|
1692
|
+
begin
|
1693
|
+
yield
|
1694
|
+
ensure
|
1695
|
+
self.scoped_methods.pop
|
1696
|
+
end
|
1697
|
+
end
|
1698
|
+
|
1699
|
+
# Works like with_scope, but discards any nested properties.
|
1700
|
+
def with_exclusive_scope(method_scoping = {}, &block)
|
1701
|
+
with_scope(method_scoping, :overwrite, &block)
|
1702
|
+
end
|
1703
|
+
|
1704
|
+
def subclasses #:nodoc:
|
1705
|
+
@@subclasses[self] ||= []
|
1706
|
+
@@subclasses[self] + extra = @@subclasses[self].inject([]) {|list, subclass| list + subclass.subclasses }
|
1707
|
+
end
|
1708
|
+
|
1709
|
+
# Test whether the given method and optional key are scoped.
|
1710
|
+
def scoped?(method, key = nil) #:nodoc:
|
1711
|
+
if current_scoped_methods && (scope = current_scoped_methods[method])
|
1712
|
+
!key || scope.has_key?(key)
|
1713
|
+
end
|
1714
|
+
end
|
1715
|
+
|
1716
|
+
# Retrieve the scope for the given method and optional key.
|
1717
|
+
def scope(method, key = nil) #:nodoc:
|
1718
|
+
if current_scoped_methods && (scope = current_scoped_methods[method])
|
1719
|
+
key ? scope[key] : scope
|
1720
|
+
end
|
1721
|
+
end
|
1722
|
+
|
1723
|
+
def thread_safe_scoped_methods #:nodoc:
|
1724
|
+
scoped_methods = (Thread.current[:scoped_methods] ||= {})
|
1725
|
+
scoped_methods[self] ||= []
|
1726
|
+
end
|
1727
|
+
|
1728
|
+
def single_threaded_scoped_methods #:nodoc:
|
1729
|
+
@scoped_methods ||= []
|
1730
|
+
end
|
1731
|
+
|
1732
|
+
# pick up the correct scoped_methods version from @@allow_concurrency
|
1733
|
+
if @@allow_concurrency
|
1734
|
+
alias_method :scoped_methods, :thread_safe_scoped_methods
|
1735
|
+
else
|
1736
|
+
alias_method :scoped_methods, :single_threaded_scoped_methods
|
1737
|
+
end
|
1738
|
+
|
1739
|
+
def current_scoped_methods #:nodoc:
|
1740
|
+
scoped_methods.last
|
1741
|
+
end
|
1742
|
+
|
1743
|
+
# Returns the class type of the record using the current module as a prefix. So descendents of
|
1744
|
+
# MyApp::Business::Account would appear as MyApp::Business::AccountSubclass.
|
1745
|
+
def compute_type(type_name)
|
1746
|
+
modularized_name = type_name_with_module(type_name)
|
1747
|
+
begin
|
1748
|
+
class_eval(modularized_name, __FILE__, __LINE__)
|
1749
|
+
rescue NameError
|
1750
|
+
class_eval(type_name, __FILE__, __LINE__)
|
1751
|
+
end
|
1752
|
+
end
|
1753
|
+
|
1754
|
+
# Returns the class descending directly from ActiveRecord in the inheritance hierarchy.
|
1755
|
+
def class_of_active_record_descendant(klass)
|
1756
|
+
if klass.superclass == Base || klass.superclass.abstract_class?
|
1757
|
+
klass
|
1758
|
+
elsif klass.superclass.nil?
|
1759
|
+
raise ActiveRecordError, "#{name} doesn't belong in a hierarchy descending from ActiveRecord"
|
1760
|
+
else
|
1761
|
+
class_of_active_record_descendant(klass.superclass)
|
1762
|
+
end
|
1763
|
+
end
|
1764
|
+
|
1765
|
+
# Returns the name of the class descending directly from ActiveRecord in the inheritance hierarchy.
|
1766
|
+
def class_name_of_active_record_descendant(klass) #:nodoc:
|
1767
|
+
klass.base_class.name
|
1768
|
+
end
|
1769
|
+
|
1770
|
+
# Accepts an array, hash, or string of sql conditions and sanitizes
|
1771
|
+
# them into a valid SQL fragment for a WHERE clause.
|
1772
|
+
# ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'"
|
1773
|
+
# { :name => "foo'bar", :group_id => 4 } returns "name='foo''bar' and group_id='4'"
|
1774
|
+
# "name='foo''bar' and group_id='4'" returns "name='foo''bar' and group_id='4'"
|
1775
|
+
def sanitize_sql_for_conditions(condition)
|
1776
|
+
case condition
|
1777
|
+
when Array; sanitize_sql_array(condition)
|
1778
|
+
when Hash; sanitize_sql_hash_for_conditions(condition)
|
1779
|
+
else condition
|
1780
|
+
end
|
1781
|
+
end
|
1782
|
+
alias_method :sanitize_sql, :sanitize_sql_for_conditions
|
1783
|
+
|
1784
|
+
# Accepts an array, hash, or string of sql conditions and sanitizes
|
1785
|
+
# them into a valid SQL fragment for a SET clause.
|
1786
|
+
# { :name => nil, :group_id => 4 } returns "name = NULL , group_id='4'"
|
1787
|
+
def sanitize_sql_for_assignment(assignments)
|
1788
|
+
case assignments
|
1789
|
+
when Array; sanitize_sql_array(assignments)
|
1790
|
+
when Hash; sanitize_sql_hash_for_assignment(assignments)
|
1791
|
+
else assignments
|
1792
|
+
end
|
1793
|
+
end
|
1794
|
+
|
1795
|
+
# Sanitizes a hash of attribute/value pairs into SQL conditions for a WHERE clause.
|
1796
|
+
# { :name => "foo'bar", :group_id => 4 }
|
1797
|
+
# # => "name='foo''bar' and group_id= 4"
|
1798
|
+
# { :status => nil, :group_id => [1,2,3] }
|
1799
|
+
# # => "status IS NULL and group_id IN (1,2,3)"
|
1800
|
+
# { :age => 13..18 }
|
1801
|
+
# # => "age BETWEEN 13 AND 18"
|
1802
|
+
# { 'other_records.id' => 7 }
|
1803
|
+
# # => "`other_records`.`id` = 7"
|
1804
|
+
def sanitize_sql_hash_for_conditions(attrs)
|
1805
|
+
conditions = attrs.map do |attr, value|
|
1806
|
+
attr = attr.to_s
|
1807
|
+
|
1808
|
+
# Extract table name from qualified attribute names.
|
1809
|
+
if attr.include?('.')
|
1810
|
+
table_name, attr = attr.split('.', 2)
|
1811
|
+
table_name = connection.quote_table_name(table_name)
|
1812
|
+
else
|
1813
|
+
table_name = quoted_table_name
|
1814
|
+
end
|
1815
|
+
|
1816
|
+
"#{table_name}.#{connection.quote_column_name(attr)} #{attribute_condition(value)}"
|
1817
|
+
end.join(' AND ')
|
1818
|
+
|
1819
|
+
replace_bind_variables(conditions, expand_range_bind_variables(attrs.values))
|
1820
|
+
end
|
1821
|
+
alias_method :sanitize_sql_hash, :sanitize_sql_hash_for_conditions
|
1822
|
+
|
1823
|
+
# Sanitizes a hash of attribute/value pairs into SQL conditions for a SET clause.
|
1824
|
+
# { :status => nil, :group_id => 1 }
|
1825
|
+
# # => "status = NULL , group_id = 1"
|
1826
|
+
def sanitize_sql_hash_for_assignment(attrs)
|
1827
|
+
conditions = attrs.map do |attr, value|
|
1828
|
+
"#{connection.quote_column_name(attr)} = #{quote_bound_value(value)}"
|
1829
|
+
end.join(', ')
|
1830
|
+
end
|
1831
|
+
|
1832
|
+
# Accepts an array of conditions. The array has each value
|
1833
|
+
# sanitized and interpolated into the sql statement.
|
1834
|
+
# ["name='%s' and group_id='%s'", "foo'bar", 4] returns "name='foo''bar' and group_id='4'"
|
1835
|
+
def sanitize_sql_array(ary)
|
1836
|
+
statement, *values = ary
|
1837
|
+
if values.first.is_a?(Hash) and statement =~ /:\w+/
|
1838
|
+
replace_named_bind_variables(statement, values.first)
|
1839
|
+
elsif statement.include?('?')
|
1840
|
+
replace_bind_variables(statement, values)
|
1841
|
+
else
|
1842
|
+
statement % values.collect { |value| connection.quote_string(value.to_s) }
|
1843
|
+
end
|
1844
|
+
end
|
1845
|
+
|
1846
|
+
alias_method :sanitize_conditions, :sanitize_sql
|
1847
|
+
|
1848
|
+
def replace_bind_variables(statement, values) #:nodoc:
|
1849
|
+
raise_if_bind_arity_mismatch(statement, statement.count('?'), values.size)
|
1850
|
+
bound = values.dup
|
1851
|
+
statement.gsub('?') { quote_bound_value(bound.shift) }
|
1852
|
+
end
|
1853
|
+
|
1854
|
+
def replace_named_bind_variables(statement, bind_vars) #:nodoc:
|
1855
|
+
statement.gsub(/:(\w+)/) do
|
1856
|
+
match = $1.to_sym
|
1857
|
+
if bind_vars.include?(match)
|
1858
|
+
quote_bound_value(bind_vars[match])
|
1859
|
+
else
|
1860
|
+
raise PreparedStatementInvalid, "missing value for :#{match} in #{statement}"
|
1861
|
+
end
|
1862
|
+
end
|
1863
|
+
end
|
1864
|
+
|
1865
|
+
def expand_range_bind_variables(bind_vars) #:nodoc:
|
1866
|
+
bind_vars.each_with_index do |var, index|
|
1867
|
+
bind_vars[index, 1] = [var.first, var.last] if var.is_a?(Range)
|
1868
|
+
end
|
1869
|
+
bind_vars
|
1870
|
+
end
|
1871
|
+
|
1872
|
+
def quote_bound_value(value) #:nodoc:
|
1873
|
+
if value.respond_to?(:map) && !value.is_a?(String)
|
1874
|
+
if value.respond_to?(:empty?) && value.empty?
|
1875
|
+
connection.quote(nil)
|
1876
|
+
else
|
1877
|
+
value.map { |v| connection.quote(v) }.join(',')
|
1878
|
+
end
|
1879
|
+
else
|
1880
|
+
connection.quote(value)
|
1881
|
+
end
|
1882
|
+
end
|
1883
|
+
|
1884
|
+
def raise_if_bind_arity_mismatch(statement, expected, provided) #:nodoc:
|
1885
|
+
unless expected == provided
|
1886
|
+
raise PreparedStatementInvalid, "wrong number of bind variables (#{provided} for #{expected}) in: #{statement}"
|
1887
|
+
end
|
1888
|
+
end
|
1889
|
+
|
1890
|
+
VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset,
|
1891
|
+
:order, :select, :readonly, :group, :from, :lock ]
|
1892
|
+
|
1893
|
+
def validate_find_options(options) #:nodoc:
|
1894
|
+
options.assert_valid_keys(VALID_FIND_OPTIONS)
|
1895
|
+
end
|
1896
|
+
|
1897
|
+
def set_readonly_option!(options) #:nodoc:
|
1898
|
+
# Inherit :readonly from finder scope if set. Otherwise,
|
1899
|
+
# if :joins is not blank then :readonly defaults to true.
|
1900
|
+
unless options.has_key?(:readonly)
|
1901
|
+
if scoped_readonly = scope(:find, :readonly)
|
1902
|
+
options[:readonly] = scoped_readonly
|
1903
|
+
elsif !options[:joins].blank? && !options[:select]
|
1904
|
+
options[:readonly] = true
|
1905
|
+
end
|
1906
|
+
end
|
1907
|
+
end
|
1908
|
+
|
1909
|
+
def encode_quoted_value(value) #:nodoc:
|
1910
|
+
quoted_value = connection.quote(value)
|
1911
|
+
quoted_value = "'#{quoted_value[1..-2].gsub(/\'/, "\\\\'")}'" if quoted_value.include?("\\\'") # (for ruby mode) "
|
1912
|
+
quoted_value
|
1913
|
+
end
|
1914
|
+
end
|
1915
|
+
|
1916
|
+
public
|
1917
|
+
# New objects can be instantiated as either empty (pass no construction parameter) or pre-set with
|
1918
|
+
# attributes but not yet saved (pass a hash with key names matching the associated table column names).
|
1919
|
+
# In both instances, valid attribute keys are determined by the column names of the associated table --
|
1920
|
+
# hence you can't have attributes that aren't part of the table columns.
|
1921
|
+
def initialize(attributes = nil)
|
1922
|
+
@attributes = attributes_from_column_definition
|
1923
|
+
@attributes_cache = {}
|
1924
|
+
@new_record = true
|
1925
|
+
ensure_proper_type
|
1926
|
+
self.attributes = attributes unless attributes.nil?
|
1927
|
+
self.class.send(:scope, :create).each { |att,value| self.send("#{att}=", value) } if self.class.send(:scoped?, :create)
|
1928
|
+
result = yield self if block_given?
|
1929
|
+
callback(:after_initialize) if respond_to_without_attributes?(:after_initialize)
|
1930
|
+
result
|
1931
|
+
end
|
1932
|
+
|
1933
|
+
# A model instance's primary key is always available as model.id
|
1934
|
+
# whether you name it the default 'id' or set it to something else.
|
1935
|
+
def id
|
1936
|
+
attr_name = self.class.primary_key
|
1937
|
+
column = column_for_attribute(attr_name)
|
1938
|
+
|
1939
|
+
self.class.send(:define_read_method, :id, attr_name, column)
|
1940
|
+
# now that the method exists, call it
|
1941
|
+
self.send attr_name.to_sym
|
1942
|
+
|
1943
|
+
end
|
1944
|
+
|
1945
|
+
# Enables Active Record objects to be used as URL parameters in Action Pack automatically.
|
1946
|
+
def to_param
|
1947
|
+
# We can't use alias_method here, because method 'id' optimizes itself on the fly.
|
1948
|
+
(id = self.id) ? id.to_s : nil # Be sure to stringify the id for routes
|
1949
|
+
end
|
1950
|
+
|
1951
|
+
def id_before_type_cast #:nodoc:
|
1952
|
+
read_attribute_before_type_cast(self.class.primary_key)
|
1953
|
+
end
|
1954
|
+
|
1955
|
+
def quoted_id #:nodoc:
|
1956
|
+
quote_value(id, column_for_attribute(self.class.primary_key))
|
1957
|
+
end
|
1958
|
+
|
1959
|
+
# Sets the primary ID.
|
1960
|
+
def id=(value)
|
1961
|
+
write_attribute(self.class.primary_key, value)
|
1962
|
+
end
|
1963
|
+
|
1964
|
+
# Returns true if this object hasn't been saved yet -- that is, a record for the object doesn't exist yet.
|
1965
|
+
def new_record?
|
1966
|
+
@new_record
|
1967
|
+
end
|
1968
|
+
|
1969
|
+
# * No record exists: Creates a new record with values matching those of the object attributes.
|
1970
|
+
# * A record does exist: Updates the record with values matching those of the object attributes.
|
1971
|
+
def save
|
1972
|
+
create_or_update
|
1973
|
+
end
|
1974
|
+
|
1975
|
+
# Attempts to save the record, but instead of just returning false if it couldn't happen, it raises a
|
1976
|
+
# RecordNotSaved exception
|
1977
|
+
def save!
|
1978
|
+
create_or_update || raise(RecordNotSaved)
|
1979
|
+
end
|
1980
|
+
|
1981
|
+
# Deletes the record in the database and freezes this instance to reflect that no changes should
|
1982
|
+
# be made (since they can't be persisted).
|
1983
|
+
def destroy
|
1984
|
+
unless new_record?
|
1985
|
+
connection.delete <<-end_sql, "#{self.class.name} Destroy"
|
1986
|
+
DELETE FROM #{self.class.quoted_table_name}
|
1987
|
+
WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quoted_id}
|
1988
|
+
end_sql
|
1989
|
+
end
|
1990
|
+
|
1991
|
+
freeze
|
1992
|
+
end
|
1993
|
+
|
1994
|
+
# Returns a clone of the record that hasn't been assigned an id yet and
|
1995
|
+
# is treated as a new record. Note that this is a "shallow" clone:
|
1996
|
+
# it copies the object's attributes only, not its associations.
|
1997
|
+
# The extent of a "deep" clone is application-specific and is therefore
|
1998
|
+
# left to the application to implement according to its need.
|
1999
|
+
def clone
|
2000
|
+
attrs = self.attributes_before_type_cast
|
2001
|
+
attrs.delete(self.class.primary_key)
|
2002
|
+
record = self.class.new
|
2003
|
+
record.send :instance_variable_set, '@attributes', attrs
|
2004
|
+
record
|
2005
|
+
end
|
2006
|
+
|
2007
|
+
# Returns an instance of the specified klass with the attributes of the current record. This is mostly useful in relation to
|
2008
|
+
# single-table inheritance structures where you want a subclass to appear as the superclass. This can be used along with record
|
2009
|
+
# identification in Action Pack to allow, say, Client < Company to do something like render :partial => @client.becomes(Company)
|
2010
|
+
# to render that instance using the companies/company partial instead of clients/client.
|
2011
|
+
#
|
2012
|
+
# Note: The new instance will share a link to the same attributes as the original class. So any change to the attributes in either
|
2013
|
+
# instance will affect the other.
|
2014
|
+
def becomes(klass)
|
2015
|
+
returning klass.new do |became|
|
2016
|
+
became.instance_variable_set("@attributes", @attributes)
|
2017
|
+
became.instance_variable_set("@attributes_cache", @attributes_cache)
|
2018
|
+
became.instance_variable_set("@new_record", new_record?)
|
2019
|
+
end
|
2020
|
+
end
|
2021
|
+
|
2022
|
+
# Updates a single attribute and saves the record. This is especially useful for boolean flags on existing records.
|
2023
|
+
# Note: This method is overwritten by the Validation module that'll make sure that updates made with this method
|
2024
|
+
# aren't subjected to validation checks. Hence, attributes can be updated even if the full object isn't valid.
|
2025
|
+
def update_attribute(name, value)
|
2026
|
+
send(name.to_s + '=', value)
|
2027
|
+
save
|
2028
|
+
end
|
2029
|
+
|
2030
|
+
# Updates all the attributes from the passed-in Hash and saves the record. If the object is invalid, the saving will
|
2031
|
+
# fail and false will be returned.
|
2032
|
+
def update_attributes(attributes)
|
2033
|
+
self.attributes = attributes
|
2034
|
+
save
|
2035
|
+
end
|
2036
|
+
|
2037
|
+
# Updates an object just like Base.update_attributes but calls save! instead of save so an exception is raised if the record is invalid.
|
2038
|
+
def update_attributes!(attributes)
|
2039
|
+
self.attributes = attributes
|
2040
|
+
save!
|
2041
|
+
end
|
2042
|
+
|
2043
|
+
# Initializes the +attribute+ to zero if nil and adds one. Only makes sense for number-based attributes. Returns self.
|
2044
|
+
def increment(attribute)
|
2045
|
+
self[attribute] ||= 0
|
2046
|
+
self[attribute] += 1
|
2047
|
+
self
|
2048
|
+
end
|
2049
|
+
|
2050
|
+
# Increments the +attribute+ and saves the record.
|
2051
|
+
def increment!(attribute)
|
2052
|
+
increment(attribute).update_attribute(attribute, self[attribute])
|
2053
|
+
end
|
2054
|
+
|
2055
|
+
# Initializes the +attribute+ to zero if nil and subtracts one. Only makes sense for number-based attributes. Returns self.
|
2056
|
+
def decrement(attribute)
|
2057
|
+
self[attribute] ||= 0
|
2058
|
+
self[attribute] -= 1
|
2059
|
+
self
|
2060
|
+
end
|
2061
|
+
|
2062
|
+
# Decrements the +attribute+ and saves the record.
|
2063
|
+
def decrement!(attribute)
|
2064
|
+
decrement(attribute).update_attribute(attribute, self[attribute])
|
2065
|
+
end
|
2066
|
+
|
2067
|
+
# Turns an +attribute+ that's currently true into false and vice versa. Returns self.
|
2068
|
+
def toggle(attribute)
|
2069
|
+
self[attribute] = !send("#{attribute}?")
|
2070
|
+
self
|
2071
|
+
end
|
2072
|
+
|
2073
|
+
# Toggles the +attribute+ and saves the record.
|
2074
|
+
def toggle!(attribute)
|
2075
|
+
toggle(attribute).update_attribute(attribute, self[attribute])
|
2076
|
+
end
|
2077
|
+
|
2078
|
+
# Reloads the attributes of this object from the database.
|
2079
|
+
# The optional options argument is passed to find when reloading so you
|
2080
|
+
# may do e.g. record.reload(:lock => true) to reload the same record with
|
2081
|
+
# an exclusive row lock.
|
2082
|
+
def reload(options = nil)
|
2083
|
+
clear_aggregation_cache
|
2084
|
+
clear_association_cache
|
2085
|
+
@attributes.update(self.class.find(self.id, options).instance_variable_get('@attributes'))
|
2086
|
+
@attributes_cache = {}
|
2087
|
+
self
|
2088
|
+
end
|
2089
|
+
|
2090
|
+
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
|
2091
|
+
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
|
2092
|
+
# (Alias for the protected read_attribute method).
|
2093
|
+
def [](attr_name)
|
2094
|
+
read_attribute(attr_name)
|
2095
|
+
end
|
2096
|
+
|
2097
|
+
# Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.
|
2098
|
+
# (Alias for the protected write_attribute method).
|
2099
|
+
def []=(attr_name, value)
|
2100
|
+
write_attribute(attr_name, value)
|
2101
|
+
end
|
2102
|
+
|
2103
|
+
# Allows you to set all the attributes at once by passing in a hash with keys
|
2104
|
+
# matching the attribute names (which again matches the column names). Sensitive attributes can be protected
|
2105
|
+
# from this form of mass-assignment by using the +attr_protected+ macro. Or you can alternatively
|
2106
|
+
# specify which attributes *can* be accessed with the +attr_accessible+ macro. Then all the
|
2107
|
+
# attributes not included in that won't be allowed to be mass-assigned.
|
2108
|
+
def attributes=(new_attributes, guard_protected_attributes = true)
|
2109
|
+
return if new_attributes.nil?
|
2110
|
+
attributes = new_attributes.dup
|
2111
|
+
attributes.stringify_keys!
|
2112
|
+
|
2113
|
+
multi_parameter_attributes = []
|
2114
|
+
attributes = remove_attributes_protected_from_mass_assignment(attributes) if guard_protected_attributes
|
2115
|
+
|
2116
|
+
attributes.each do |k, v|
|
2117
|
+
k.include?("(") ? multi_parameter_attributes << [ k, v ] : send(k + "=", v)
|
2118
|
+
end
|
2119
|
+
|
2120
|
+
assign_multiparameter_attributes(multi_parameter_attributes)
|
2121
|
+
end
|
2122
|
+
|
2123
|
+
|
2124
|
+
# Returns a hash of all the attributes with their names as keys and clones of their objects as values.
|
2125
|
+
def attributes(options = nil)
|
2126
|
+
attributes = clone_attributes :read_attribute
|
2127
|
+
|
2128
|
+
if options.nil?
|
2129
|
+
attributes
|
2130
|
+
else
|
2131
|
+
if except = options[:except]
|
2132
|
+
except = Array(except).collect { |attribute| attribute.to_s }
|
2133
|
+
except.each { |attribute_name| attributes.delete(attribute_name) }
|
2134
|
+
attributes
|
2135
|
+
elsif only = options[:only]
|
2136
|
+
only = Array(only).collect { |attribute| attribute.to_s }
|
2137
|
+
attributes.delete_if { |key, value| !only.include?(key) }
|
2138
|
+
attributes
|
2139
|
+
else
|
2140
|
+
raise ArgumentError, "Options does not specify :except or :only (#{options.keys.inspect})"
|
2141
|
+
end
|
2142
|
+
end
|
2143
|
+
end
|
2144
|
+
|
2145
|
+
# Returns a hash of cloned attributes before typecasting and deserialization.
|
2146
|
+
def attributes_before_type_cast
|
2147
|
+
clone_attributes :read_attribute_before_type_cast
|
2148
|
+
end
|
2149
|
+
|
2150
|
+
# Format attributes nicely for inspect.
|
2151
|
+
def attribute_for_inspect(attr_name)
|
2152
|
+
value = read_attribute(attr_name)
|
2153
|
+
|
2154
|
+
if value.is_a?(String) && value.length > 50
|
2155
|
+
"#{value[0..50]}...".inspect
|
2156
|
+
elsif value.is_a?(Date) || value.is_a?(Time)
|
2157
|
+
%("#{value.to_s(:db)}")
|
2158
|
+
else
|
2159
|
+
value.inspect
|
2160
|
+
end
|
2161
|
+
end
|
2162
|
+
|
2163
|
+
# Returns true if the specified +attribute+ has been set by the user or by a database load and is neither
|
2164
|
+
# nil nor empty? (the latter only applies to objects that respond to empty?, most notably Strings).
|
2165
|
+
def attribute_present?(attribute)
|
2166
|
+
value = read_attribute(attribute)
|
2167
|
+
!value.blank?
|
2168
|
+
end
|
2169
|
+
|
2170
|
+
# Returns true if the given attribute is in the attributes hash
|
2171
|
+
def has_attribute?(attr_name)
|
2172
|
+
@attributes.has_key?(attr_name.to_s)
|
2173
|
+
end
|
2174
|
+
|
2175
|
+
# Returns an array of names for the attributes available on this object sorted alphabetically.
|
2176
|
+
def attribute_names
|
2177
|
+
@attributes.keys.sort
|
2178
|
+
end
|
2179
|
+
|
2180
|
+
# Returns the column object for the named attribute.
|
2181
|
+
def column_for_attribute(name)
|
2182
|
+
self.class.columns_hash[name.to_s]
|
2183
|
+
end
|
2184
|
+
|
2185
|
+
# Returns true if the +comparison_object+ is the same object, or is of the same type and has the same id.
|
2186
|
+
def ==(comparison_object)
|
2187
|
+
comparison_object.equal?(self) ||
|
2188
|
+
(comparison_object.instance_of?(self.class) &&
|
2189
|
+
comparison_object.id == id &&
|
2190
|
+
!comparison_object.new_record?)
|
2191
|
+
end
|
2192
|
+
|
2193
|
+
# Delegates to ==
|
2194
|
+
def eql?(comparison_object)
|
2195
|
+
self == (comparison_object)
|
2196
|
+
end
|
2197
|
+
|
2198
|
+
# Delegates to id in order to allow two records of the same type and id to work with something like:
|
2199
|
+
# [ Person.find(1), Person.find(2), Person.find(3) ] & [ Person.find(1), Person.find(4) ] # => [ Person.find(1) ]
|
2200
|
+
def hash
|
2201
|
+
id.hash
|
2202
|
+
end
|
2203
|
+
|
2204
|
+
# Freeze the attributes hash such that associations are still accessible, even on destroyed records.
|
2205
|
+
def freeze
|
2206
|
+
@attributes.freeze; self
|
2207
|
+
end
|
2208
|
+
|
2209
|
+
# Returns +true+ if the attributes hash has been frozen.
|
2210
|
+
def frozen?
|
2211
|
+
@attributes.frozen?
|
2212
|
+
end
|
2213
|
+
|
2214
|
+
# Returns +true+ if the record is read only. Records loaded through joins with piggy-back
|
2215
|
+
# attributes will be marked as read only since they cannot be saved.
|
2216
|
+
def readonly?
|
2217
|
+
@readonly == true
|
2218
|
+
end
|
2219
|
+
|
2220
|
+
# Marks this record as read only.
|
2221
|
+
def readonly!
|
2222
|
+
@readonly = true
|
2223
|
+
end
|
2224
|
+
|
2225
|
+
# Returns the contents of the record as a nicely formatted string.
|
2226
|
+
def inspect
|
2227
|
+
attributes_as_nice_string = self.class.column_names.collect { |name|
|
2228
|
+
if has_attribute?(name) || new_record?
|
2229
|
+
"#{name}: #{attribute_for_inspect(name)}"
|
2230
|
+
end
|
2231
|
+
}.compact.join(", ")
|
2232
|
+
"#<#{self.class} #{attributes_as_nice_string}>"
|
2233
|
+
end
|
2234
|
+
|
2235
|
+
private
|
2236
|
+
def create_or_update
|
2237
|
+
raise ReadOnlyRecord if readonly?
|
2238
|
+
result = new_record? ? create : update
|
2239
|
+
result != false
|
2240
|
+
end
|
2241
|
+
|
2242
|
+
# Updates the associated record with values matching those of the instance attributes.
|
2243
|
+
# Returns the number of affected rows.
|
2244
|
+
def update
|
2245
|
+
quoted_attributes = attributes_with_quotes(false, false)
|
2246
|
+
return 0 if quoted_attributes.empty?
|
2247
|
+
connection.update(
|
2248
|
+
"UPDATE #{self.class.quoted_table_name} " +
|
2249
|
+
"SET #{quoted_comma_pair_list(connection, quoted_attributes)} " +
|
2250
|
+
"WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quote_value(id)}",
|
2251
|
+
"#{self.class.name} Update"
|
2252
|
+
)
|
2253
|
+
end
|
2254
|
+
|
2255
|
+
# Creates a record with values matching those of the instance attributes
|
2256
|
+
# and returns its id.
|
2257
|
+
def create
|
2258
|
+
if self.id.nil? && connection.prefetch_primary_key?(self.class.table_name)
|
2259
|
+
self.id = connection.next_sequence_value(self.class.sequence_name)
|
2260
|
+
end
|
2261
|
+
|
2262
|
+
quoted_attributes = attributes_with_quotes
|
2263
|
+
|
2264
|
+
statement = if quoted_attributes.empty?
|
2265
|
+
connection.empty_insert_statement(self.class.table_name)
|
2266
|
+
else
|
2267
|
+
"INSERT INTO #{self.class.quoted_table_name} " +
|
2268
|
+
"(#{quoted_column_names.join(', ')}) " +
|
2269
|
+
"VALUES(#{quoted_attributes.values.join(', ')})"
|
2270
|
+
end
|
2271
|
+
|
2272
|
+
self.id = connection.insert(statement, "#{self.class.name} Create",
|
2273
|
+
self.class.primary_key, self.id, self.class.sequence_name)
|
2274
|
+
|
2275
|
+
@new_record = false
|
2276
|
+
id
|
2277
|
+
end
|
2278
|
+
|
2279
|
+
# Sets the attribute used for single table inheritance to this class name if this is not the ActiveRecord descendent.
|
2280
|
+
# Considering the hierarchy Reply < Message < ActiveRecord, this makes it possible to do Reply.new without having to
|
2281
|
+
# set Reply[Reply.inheritance_column] = "Reply" yourself. No such attribute would be set for objects of the
|
2282
|
+
# Message class in that example.
|
2283
|
+
def ensure_proper_type
|
2284
|
+
unless self.class.descends_from_active_record?
|
2285
|
+
write_attribute(self.class.inheritance_column, Inflector.demodulize(self.class.name))
|
2286
|
+
end
|
2287
|
+
end
|
2288
|
+
|
2289
|
+
def convert_number_column_value(value)
|
2290
|
+
case value
|
2291
|
+
when FalseClass; 0
|
2292
|
+
when TrueClass; 1
|
2293
|
+
when ''; nil
|
2294
|
+
else value
|
2295
|
+
end
|
2296
|
+
end
|
2297
|
+
|
2298
|
+
def remove_attributes_protected_from_mass_assignment(attributes)
|
2299
|
+
safe_attributes =
|
2300
|
+
if self.class.accessible_attributes.nil? && self.class.protected_attributes.nil?
|
2301
|
+
attributes.reject { |key, value| attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) }
|
2302
|
+
elsif self.class.protected_attributes.nil?
|
2303
|
+
attributes.reject { |key, value| !self.class.accessible_attributes.include?(key.gsub(/\(.+/, "")) || attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) }
|
2304
|
+
elsif self.class.accessible_attributes.nil?
|
2305
|
+
attributes.reject { |key, value| self.class.protected_attributes.include?(key.gsub(/\(.+/,"")) || attributes_protected_by_default.include?(key.gsub(/\(.+/, "")) }
|
2306
|
+
else
|
2307
|
+
raise "Declare either attr_protected or attr_accessible for #{self.class}, but not both."
|
2308
|
+
end
|
2309
|
+
|
2310
|
+
removed_attributes = attributes.keys - safe_attributes.keys
|
2311
|
+
|
2312
|
+
if removed_attributes.any?
|
2313
|
+
logger.debug "WARNING: Can't mass-assign these protected attributes: #{removed_attributes.join(', ')}"
|
2314
|
+
end
|
2315
|
+
|
2316
|
+
safe_attributes
|
2317
|
+
end
|
2318
|
+
|
2319
|
+
# Removes attributes which have been marked as readonly.
|
2320
|
+
def remove_readonly_attributes(attributes)
|
2321
|
+
unless self.class.readonly_attributes.nil?
|
2322
|
+
attributes.delete_if { |key, value| self.class.readonly_attributes.include?(key.gsub(/\(.+/,"")) }
|
2323
|
+
else
|
2324
|
+
attributes
|
2325
|
+
end
|
2326
|
+
end
|
2327
|
+
|
2328
|
+
# The primary key and inheritance column can never be set by mass-assignment for security reasons.
|
2329
|
+
def attributes_protected_by_default
|
2330
|
+
default = [ self.class.primary_key, self.class.inheritance_column ]
|
2331
|
+
default << 'id' unless self.class.primary_key.eql? 'id'
|
2332
|
+
default
|
2333
|
+
end
|
2334
|
+
|
2335
|
+
# Returns a copy of the attributes hash where all the values have been safely quoted for use in
|
2336
|
+
# an SQL statement.
|
2337
|
+
def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true)
|
2338
|
+
quoted = attributes.inject({}) do |quoted, (name, value)|
|
2339
|
+
if column = column_for_attribute(name)
|
2340
|
+
quoted[name] = quote_value(value, column) unless !include_primary_key && column.primary
|
2341
|
+
end
|
2342
|
+
quoted
|
2343
|
+
end
|
2344
|
+
include_readonly_attributes ? quoted : remove_readonly_attributes(quoted)
|
2345
|
+
end
|
2346
|
+
|
2347
|
+
# Quote strings appropriately for SQL statements.
|
2348
|
+
def quote_value(value, column = nil)
|
2349
|
+
self.class.connection.quote(value, column)
|
2350
|
+
end
|
2351
|
+
|
2352
|
+
# Interpolate custom sql string in instance context.
|
2353
|
+
# Optional record argument is meant for custom insert_sql.
|
2354
|
+
def interpolate_sql(sql, record = nil)
|
2355
|
+
instance_eval("%@#{sql.gsub('@', '\@')}@")
|
2356
|
+
end
|
2357
|
+
|
2358
|
+
# Initializes the attributes array with keys matching the columns from the linked table and
|
2359
|
+
# the values matching the corresponding default value of that column, so
|
2360
|
+
# that a new instance, or one populated from a passed-in Hash, still has all the attributes
|
2361
|
+
# that instances loaded from the database would.
|
2362
|
+
def attributes_from_column_definition
|
2363
|
+
self.class.columns.inject({}) do |attributes, column|
|
2364
|
+
attributes[column.name] = column.default unless column.name == self.class.primary_key
|
2365
|
+
attributes
|
2366
|
+
end
|
2367
|
+
end
|
2368
|
+
|
2369
|
+
# Instantiates objects for all attribute classes that needs more than one constructor parameter. This is done
|
2370
|
+
# by calling new on the column type or aggregation type (through composed_of) object with these parameters.
|
2371
|
+
# So having the pairs written_on(1) = "2004", written_on(2) = "6", written_on(3) = "24", will instantiate
|
2372
|
+
# written_on (a date type) with Date.new("2004", "6", "24"). You can also specify a typecast character in the
|
2373
|
+
# parentheses to have the parameters typecasted before they're used in the constructor. Use i for Fixnum, f for Float,
|
2374
|
+
# s for String, and a for Array. If all the values for a given attribute are empty, the attribute will be set to nil.
|
2375
|
+
def assign_multiparameter_attributes(pairs)
|
2376
|
+
execute_callstack_for_multiparameter_attributes(
|
2377
|
+
extract_callstack_for_multiparameter_attributes(pairs)
|
2378
|
+
)
|
2379
|
+
end
|
2380
|
+
|
2381
|
+
# Includes an ugly hack for Time.local instead of Time.new because the latter is reserved by Time itself.
|
2382
|
+
def execute_callstack_for_multiparameter_attributes(callstack)
|
2383
|
+
errors = []
|
2384
|
+
callstack.each do |name, values|
|
2385
|
+
klass = (self.class.reflect_on_aggregation(name.to_sym) || column_for_attribute(name)).klass
|
2386
|
+
if values.empty?
|
2387
|
+
send(name + "=", nil)
|
2388
|
+
else
|
2389
|
+
begin
|
2390
|
+
send(name + "=", Time == klass ? (@@default_timezone == :utc ? klass.utc(*values) : klass.local(*values)) : klass.new(*values))
|
2391
|
+
rescue => ex
|
2392
|
+
errors << AttributeAssignmentError.new("error on assignment #{values.inspect} to #{name}", ex, name)
|
2393
|
+
end
|
2394
|
+
end
|
2395
|
+
end
|
2396
|
+
unless errors.empty?
|
2397
|
+
raise MultiparameterAssignmentErrors.new(errors), "#{errors.size} error(s) on assignment of multiparameter attributes"
|
2398
|
+
end
|
2399
|
+
end
|
2400
|
+
|
2401
|
+
def extract_callstack_for_multiparameter_attributes(pairs)
|
2402
|
+
attributes = { }
|
2403
|
+
|
2404
|
+
for pair in pairs
|
2405
|
+
multiparameter_name, value = pair
|
2406
|
+
attribute_name = multiparameter_name.split("(").first
|
2407
|
+
attributes[attribute_name] = [] unless attributes.include?(attribute_name)
|
2408
|
+
|
2409
|
+
unless value.empty?
|
2410
|
+
attributes[attribute_name] <<
|
2411
|
+
[ find_parameter_position(multiparameter_name), type_cast_attribute_value(multiparameter_name, value) ]
|
2412
|
+
end
|
2413
|
+
end
|
2414
|
+
|
2415
|
+
attributes.each { |name, values| attributes[name] = values.sort_by{ |v| v.first }.collect { |v| v.last } }
|
2416
|
+
end
|
2417
|
+
|
2418
|
+
def type_cast_attribute_value(multiparameter_name, value)
|
2419
|
+
multiparameter_name =~ /\([0-9]*([a-z])\)/ ? value.send("to_" + $1) : value
|
2420
|
+
end
|
2421
|
+
|
2422
|
+
def find_parameter_position(multiparameter_name)
|
2423
|
+
multiparameter_name.scan(/\(([0-9]*).*\)/).first.first
|
2424
|
+
end
|
2425
|
+
|
2426
|
+
# Returns a comma-separated pair list, like "key1 = val1, key2 = val2".
|
2427
|
+
def comma_pair_list(hash)
|
2428
|
+
hash.inject([]) { |list, pair| list << "#{pair.first} = #{pair.last}" }.join(", ")
|
2429
|
+
end
|
2430
|
+
|
2431
|
+
def quoted_column_names(attributes = attributes_with_quotes)
|
2432
|
+
attributes.keys.collect do |column_name|
|
2433
|
+
self.class.connection.quote_column_name(column_name)
|
2434
|
+
end
|
2435
|
+
end
|
2436
|
+
|
2437
|
+
def self.quoted_table_name
|
2438
|
+
self.connection.quote_table_name(self.table_name)
|
2439
|
+
end
|
2440
|
+
|
2441
|
+
def quote_columns(quoter, hash)
|
2442
|
+
hash.inject({}) do |quoted, (name, value)|
|
2443
|
+
quoted[quoter.quote_column_name(name)] = value
|
2444
|
+
quoted
|
2445
|
+
end
|
2446
|
+
end
|
2447
|
+
|
2448
|
+
def quoted_comma_pair_list(quoter, hash)
|
2449
|
+
comma_pair_list(quote_columns(quoter, hash))
|
2450
|
+
end
|
2451
|
+
|
2452
|
+
def object_from_yaml(string)
|
2453
|
+
return string unless string.is_a?(String)
|
2454
|
+
YAML::load(string) rescue string
|
2455
|
+
end
|
2456
|
+
|
2457
|
+
def clone_attributes(reader_method = :read_attribute, attributes = {})
|
2458
|
+
self.attribute_names.inject(attributes) do |attributes, name|
|
2459
|
+
attributes[name] = clone_attribute_value(reader_method, name)
|
2460
|
+
attributes
|
2461
|
+
end
|
2462
|
+
end
|
2463
|
+
|
2464
|
+
def clone_attribute_value(reader_method, attribute_name)
|
2465
|
+
value = send(reader_method, attribute_name)
|
2466
|
+
value.duplicable? ? value.clone : value
|
2467
|
+
rescue TypeError, NoMethodError
|
2468
|
+
value
|
2469
|
+
end
|
2470
|
+
end
|
2471
|
+
end
|