Created
October 19, 2016 10:06
-
-
Save kimadactyl/6f3394c317d03ba920383a09e0ad9431 to your computer and use it in GitHub Desktop.
Spree error when progressing to payment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::HomeController.class_eval do | |
# Makes sure our products are reverse sorted by creation date. | |
# Only addition to stock should be the .order method. | |
def index | |
@searcher = build_searcher(params) | |
@products = @searcher.retrieve_products.order("created_at DESC") | |
@products = @products.includes(:possible_promotions) if @products.respond_to?(:includes) | |
@taxonomies = Spree::Taxonomy.includes(root: :children) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::OrdersController.class_eval do | |
# Makes sure that people are signed in before doing anything with their cart. | |
# The first if block is the only thing that should be different from stock. | |
def populate | |
if !current_user | |
# flash[:success] = "Sign up to register for online content!" | |
redirect_to main_app.signup_url and return | |
end | |
order = current_order(create_order_if_necessary: true) | |
variant = Spree::Variant.find(params[:variant_id]) | |
quantity = params[:quantity].to_i | |
options = params[:options] || {} | |
# 2,147,483,647 is crazy. See issue #2695. | |
if quantity.between?(1, 2_147_483_647) | |
begin | |
order.contents.add(variant, quantity, options) | |
rescue ActiveRecord::RecordInvalid => e | |
error = e.record.errors.full_messages.join(", ") | |
end | |
else | |
error = Spree.t(:please_enter_reasonable_quantity) | |
end | |
if error | |
flash[:error] = error | |
redirect_back_or_default(spree.root_path) | |
else | |
respond_with(order) do |format| | |
format.html { redirect_to cart_path } | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::ProductsController.class_eval do | |
def show | |
@variants = @product.variants_including_master.active(current_currency).includes([:option_values, :images]) | |
@product_properties = @product.product_properties.includes(:property) | |
@taxon = Spree::Taxon.find(params[:taxon_id]) if params[:taxon_id] | |
@taxonomies = Spree::Taxonomy.includes(root: :children) | |
redirect_if_legacy_path | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Started PATCH "/shop/checkout/update/address" for 127.0.0.1 at 2016-10-19 11:02:58 +0100 | |
Processing by Spree::CheckoutController#update as HTML | |
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Wr4CSN3bs2Ft8GeveWat+eKqjkcjR7pOsDZKYtJWncHShITVJjHV+gWaE3pNGzz94nceB/sX0B45MNKcrUvQ7g==", "order"=>{"email"=>"[email protected]", "state_lock_version"=>"2", "bill_address_attributes"=>{"firstname"=>"Kim", "lastname"=>"Foale", "address1"=>"5 Ribston St", "address2"=>"", "city"=>"Manchester", "country_id"=>"77", "zipcode"=>"M15 5RH", "phone"=>"3423423423432", "id"=>"44"}, "use_billing"=>"1", "ship_address_attributes"=>{"id"=>"45"}}, "commit"=>"Save and Continue", "save_user_address"=>"1", "state"=>"address"} | |
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 136]] | |
Spree::Store Load (0.3ms) SELECT "spree_stores".* FROM "spree_stores" ORDER BY "spree_stores"."id" ASC LIMIT 1 | |
Spree::Order Load (0.2ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."completed_at" IS NULL AND "spree_orders"."currency" = $1 AND "spree_orders"."guest_token" = $2 AND "spree_orders"."user_id" = $3 AND "spree_orders"."store_id" = 1 LIMIT 1 [["currency", "GBP"], ["guest_token", "-d2u7s_EwOtwzXAKj70jfw"], ["user_id", 136]] | |
Spree::Order Load (0.3ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = $1 AND "spree_orders"."completed_at" IS NULL ORDER BY created_at DESC LIMIT 1 [["user_id", 136]] | |
Spree::LineItem Load (0.4ms) SELECT "spree_line_items".* FROM "spree_line_items" WHERE "spree_line_items"."order_id" IN (47) ORDER BY "spree_line_items"."created_at" ASC | |
Spree::Variant Load (0.3ms) SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."deleted_at" IS NULL AND "spree_variants"."id" IN (18) | |
Spree::Image Load (1.2ms) SELECT "spree_assets".* FROM "spree_assets" WHERE "spree_assets"."type" IN ('Spree::Image') AND "spree_assets"."viewable_type" = 'Spree::Variant' AND "spree_assets"."viewable_id" IN (18) ORDER BY "spree_assets"."position" ASC | |
Spree::OptionValueVariant Load (0.5ms) SELECT "spree_option_value_variants".* FROM "spree_option_value_variants" WHERE "spree_option_value_variants"."variant_id" IN (18) | |
Spree::Product Load (0.7ms) SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."deleted_at" IS NULL AND "spree_products"."id" IN (18) | |
Spree::Order Load (0.3ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."user_id" = $1 AND "spree_orders"."completed_at" IS NULL AND (id != 47) [["user_id", 136]] | |
Spree::Preference Load (0.1ms) SELECT "spree_preferences".* FROM "spree_preferences" WHERE "spree_preferences"."key" = $1 LIMIT 1 [["key", "spree/frontend_configuration/locale"]] | |
(0.2ms) BEGIN | |
Spree::Order Load (0.4ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."id" = $1 LIMIT 1 FOR UPDATE [["id", 47]] | |
SQL (0.3ms) UPDATE "spree_orders" SET "state_lock_version" = $1, "updated_at" = $2 WHERE "spree_orders"."id" = $3 [["state_lock_version", 3], ["updated_at", "2016-10-19 10:02:58.416667"], ["id", 47]] | |
(1.6ms) COMMIT | |
Spree::Payment Load (0.3ms) SELECT "spree_payments".* FROM "spree_payments" WHERE "spree_payments"."order_id" = $1 AND ("spree_payments"."state" NOT IN ('failed', 'invalid')) ORDER BY "spree_payments"."created_at" ASC [["order_id", 47]] | |
CACHE (0.0ms) SELECT "spree_payments".* FROM "spree_payments" WHERE "spree_payments"."order_id" = $1 AND ("spree_payments"."state" NOT IN ('failed', 'invalid')) ORDER BY "spree_payments"."created_at" ASC [["order_id", 47]] | |
CACHE (0.0ms) SELECT "spree_payments".* FROM "spree_payments" WHERE "spree_payments"."order_id" = $1 AND ("spree_payments"."state" NOT IN ('failed', 'invalid')) ORDER BY "spree_payments"."created_at" ASC [["order_id", 47]] | |
CACHE (0.0ms) SELECT "spree_payments".* FROM "spree_payments" WHERE "spree_payments"."order_id" = $1 AND ("spree_payments"."state" NOT IN ('failed', 'invalid')) ORDER BY "spree_payments"."created_at" ASC [["order_id", 47]] | |
(0.3ms) SELECT COUNT(*) FROM "spree_line_items" WHERE "spree_line_items"."order_id" = $1 [["order_id", 47]] | |
Spree::LineItem Load (0.2ms) SELECT "spree_line_items".* FROM "spree_line_items" WHERE "spree_line_items"."order_id" = $1 ORDER BY "spree_line_items"."created_at" ASC [["order_id", 47]] | |
Spree::Variant Load (0.2ms) SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."deleted_at" IS NULL AND "spree_variants"."id" = $1 LIMIT 1 [["id", 18]] | |
Spree::Product Load (0.3ms) SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."id" = $1 LIMIT 1 [["id", 18]] | |
CACHE (0.0ms) SELECT "spree_payments".* FROM "spree_payments" WHERE "spree_payments"."order_id" = $1 AND ("spree_payments"."state" NOT IN ('failed', 'invalid')) ORDER BY "spree_payments"."created_at" ASC [["order_id", 47]] | |
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 136]] | |
Spree::Role Load (0.2ms) SELECT "spree_roles".* FROM "spree_roles" INNER JOIN "spree_role_users" ON "spree_roles"."id" = "spree_role_users"."role_id" WHERE "spree_role_users"."user_id" = $1 [["user_id", 136]] | |
Spree::Address Load (0.2ms) SELECT "spree_addresses".* FROM "spree_addresses" WHERE "spree_addresses"."id" = $1 LIMIT 1 [["id", 44]] | |
CACHE (0.0ms) SELECT "spree_payments".* FROM "spree_payments" WHERE "spree_payments"."order_id" = $1 AND ("spree_payments"."state" NOT IN ('failed', 'invalid')) ORDER BY "spree_payments"."created_at" ASC [["order_id", 47]] | |
Spree::Address Load (0.2ms) SELECT "spree_addresses".* FROM "spree_addresses" WHERE "spree_addresses"."id" = $1 LIMIT 1 [["id", 45]] | |
(0.2ms) BEGIN | |
Spree::Order Exists (0.4ms) SELECT 1 AS one FROM "spree_orders" WHERE ("spree_orders"."number" = 'R845049322' AND "spree_orders"."id" != 47) LIMIT 1 | |
Spree::Country Load (0.7ms) SELECT "spree_countries".* FROM "spree_countries" WHERE "spree_countries"."id" = $1 LIMIT 1 [["id", 77]] | |
CACHE (0.0ms) SELECT "spree_countries".* FROM "spree_countries" WHERE "spree_countries"."id" = $1 LIMIT 1 [["id", 77]] | |
Spree::Order Exists (0.5ms) SELECT 1 AS one FROM "spree_orders" WHERE ("spree_orders"."number" = 'R845049322' AND "spree_orders"."id" != 47) LIMIT 1 | |
(0.2ms) COMMIT | |
Spree::Shipment Exists (0.5ms) SELECT 1 AS one FROM "spree_shipments" WHERE "spree_shipments"."order_id" = $1 LIMIT 1 [["order_id", 47]] | |
(0.1ms) BEGIN | |
SQL (0.5ms) SELECT "spree_zones"."id" AS t0_r0, "spree_zones"."name" AS t0_r1, "spree_zones"."description" AS t0_r2, "spree_zones"."default_tax" AS t0_r3, "spree_zones"."zone_members_count" AS t0_r4, "spree_zones"."created_at" AS t0_r5, "spree_zones"."updated_at" AS t0_r6, "spree_zones"."kind" AS t0_r7, "spree_zone_members"."id" AS t1_r0, "spree_zone_members"."zoneable_id" AS t1_r1, "spree_zone_members"."zoneable_type" AS t1_r2, "spree_zone_members"."zone_id" AS t1_r3, "spree_zone_members"."created_at" AS t1_r4, "spree_zone_members"."updated_at" AS t1_r5 FROM "spree_zones" LEFT OUTER JOIN "spree_zone_members" ON "spree_zone_members"."zone_id" = "spree_zones"."id" WHERE ((spree_zone_members.zoneable_type = 'Spree::Country' AND spree_zone_members.zoneable_id = 77) OR (spree_zone_members.zoneable_type = 'Spree::State' AND spree_zone_members.zoneable_id = NULL)) ORDER BY spree_zones.zone_members_count, spree_zones.created_at | |
Spree::Price Load (0.2ms) SELECT "spree_prices".* FROM "spree_prices" WHERE "spree_prices"."variant_id" = $1 AND "spree_prices"."currency" = $2 LIMIT 1 [["variant_id", 18], ["currency", "GBP"]] | |
Spree::Variant Load (0.4ms) SELECT "spree_variants".* FROM "spree_variants" WHERE "spree_variants"."id" = $1 LIMIT 1 [["id", 18]] | |
CACHE (0.0ms) SELECT "spree_products".* FROM "spree_products" WHERE "spree_products"."id" = $1 LIMIT 1 [["id", 18]] | |
Spree::TaxCategory Load (0.3ms) SELECT "spree_tax_categories".* FROM "spree_tax_categories" WHERE "spree_tax_categories"."deleted_at" IS NULL AND "spree_tax_categories"."is_default" = $1 LIMIT 1 [["is_default", "t"]] | |
Spree::Zone Load (0.2ms) SELECT "spree_zones".* FROM "spree_zones" WHERE "spree_zones"."default_tax" = $1 LIMIT 1 [["default_tax", "t"]] | |
Spree::Order Exists (0.3ms) SELECT 1 AS one FROM "spree_orders" WHERE ("spree_orders"."number" = 'R845049322' AND "spree_orders"."id" != 47) LIMIT 1 | |
Spree::Order Exists (0.2ms) SELECT 1 AS one FROM "spree_orders" WHERE ("spree_orders"."number" = 'R845049322' AND "spree_orders"."id" != 47) LIMIT 1 | |
(0.2ms) COMMIT | |
(1.0ms) SELECT DISTINCT "spree_zones"."id" FROM "spree_zones" INNER JOIN "spree_zone_members" ON "spree_zone_members"."zone_id" = "spree_zones"."id" AND "spree_zone_members"."zoneable_type" = $1 INNER JOIN "spree_countries" ON "spree_countries"."id" = "spree_zone_members"."zoneable_id" INNER JOIN "spree_zone_members" "zone_members_spree_countries_join" ON "zone_members_spree_countries_join"."zoneable_id" = "spree_countries"."id" AND "zone_members_spree_countries_join"."zoneable_type" = $2 INNER JOIN "spree_zones" "zones_spree_countries" ON "zones_spree_countries"."id" = "zone_members_spree_countries_join"."zone_id" WHERE (zone_members_spree_countries_join.zone_id = 1) [["zoneable_type", "Spree::Country"], ["zoneable_type", "Spree::Country"]] | |
Spree::TaxRate Load (0.3ms) SELECT "spree_tax_rates".* FROM "spree_tax_rates" WHERE "spree_tax_rates"."deleted_at" IS NULL AND "spree_tax_rates"."zone_id" = 1 | |
Spree::TaxCategory Load (0.3ms) SELECT "spree_tax_categories".* FROM "spree_tax_categories" WHERE "spree_tax_categories"."deleted_at" IS NULL AND "spree_tax_categories"."id" = $1 LIMIT 1 [["id", 2]] | |
Spree::Adjustment Load (0.4ms) SELECT "spree_adjustments".* FROM "spree_adjustments" WHERE "spree_adjustments"."adjustable_type" = 'Spree::LineItem' AND "spree_adjustments"."adjustable_id" IN (SELECT "spree_line_items"."id" FROM "spree_line_items" WHERE "spree_line_items"."order_id" = $1 ORDER BY "spree_line_items"."created_at" ASC) AND "spree_adjustments"."source_type" = $2 [["order_id", 47], ["source_type", "Spree::TaxRate"]] | |
CACHE (0.0ms) SELECT "spree_tax_categories".* FROM "spree_tax_categories" WHERE "spree_tax_categories"."deleted_at" IS NULL AND "spree_tax_categories"."id" = $1 LIMIT 1 [["id", 2]] | |
SQL (1.5ms) UPDATE "spree_line_items" SET "pre_tax_amount" = 8.0 WHERE "spree_line_items"."id" = $1 [["id", 75]] | |
Spree::Calculator Load (0.3ms) SELECT "spree_calculators".* FROM "spree_calculators" WHERE "spree_calculators"."deleted_at" IS NULL AND "spree_calculators"."calculable_id" = $1 AND "spree_calculators"."calculable_type" = $2 LIMIT 1 [["calculable_id", 1], ["calculable_type", "Spree::TaxRate"]] | |
Spree::Shipment Exists (1.1ms) SELECT 1 AS one FROM "spree_shipments" WHERE "spree_shipments"."order_id" = $1 LIMIT 1 [["order_id", 47]] | |
SQL (0.2ms) DELETE FROM "spree_adjustments" WHERE "spree_adjustments"."order_id" = $1 AND "spree_adjustments"."adjustable_type" = $2 [["order_id", 47], ["adjustable_type", "Spree::Shipment"]] | |
Spree::Shipment Load (0.3ms) SELECT "spree_shipments".* FROM "spree_shipments" WHERE "spree_shipments"."order_id" = $1 [["order_id", 47]] | |
Spree::StockLocation Load (0.5ms) SELECT "spree_stock_locations".* FROM "spree_stock_locations" INNER JOIN "spree_stock_items" ON "spree_stock_items"."stock_location_id" = "spree_stock_locations"."id" AND "spree_stock_items"."deleted_at" IS NULL WHERE "spree_stock_locations"."active" = $1 AND "spree_stock_items"."variant_id" = 18 [["active", "t"]] | |
Completed 500 Internal Server Error in 112ms (ActiveRecord: 20.5ms) | |
ArgumentError - When assigning attributes, you must pass a hash as an argument.: | |
activerecord (4.2.7.1) lib/active_record/attribute_assignment.rb:25:in `assign_attributes' | |
activerecord (4.2.7.1) lib/active_record/core.rb:566:in `init_attributes' | |
activerecord (4.2.7.1) lib/active_record/core.rb:281:in `initialize' | |
activerecord (4.2.7.1) lib/active_record/inheritance.rb:61:in `new' | |
spree_core (3.1.1) app/models/spree/stock/packer.rb:21:in `default_package' | |
spree_core (3.1.1) app/models/spree/stock/packer.rb:16:in `packages' | |
spree_core (3.1.1) app/models/spree/stock/coordinator.rb:25:in `block in build_packages' | |
activerecord (4.2.7.1) lib/active_record/relation/delegation.rb:46:in `each' | |
spree_core (3.1.1) app/models/spree/stock/coordinator.rb:24:in `build_packages' | |
spree_core (3.1.1) app/models/spree/stock/coordinator.rb:18:in `packages' | |
spree_core (3.1.1) app/models/spree/stock/coordinator.rb:12:in `shipments' | |
spree_core (3.1.1) app/models/spree/order.rb:492:in `create_proposed_shipments' | |
state_machines (0.4.0) lib/state_machines/eval_helpers.rb:58:in `evaluate_method' | |
state_machines (0.4.0) lib/state_machines/callback.rb:192:in `block in run_methods' | |
state_machines (0.4.0) lib/state_machines/callback.rb:191:in `run_methods' | |
state_machines (0.4.0) lib/state_machines/callback.rb:159:in `call' | |
state_machines (0.4.0) lib/state_machines/transition.rb:364:in `before' | |
state_machines (0.4.0) lib/state_machines/transition.rb:190:in `block in run_callbacks' | |
state_machines (0.4.0) lib/state_machines/transition.rb:292:in `block in pausable' | |
state_machines (0.4.0) lib/state_machines/transition.rb:292:in `pausable' | |
state_machines (0.4.0) lib/state_machines/transition.rb:190:in `run_callbacks' | |
state_machines (0.4.0) lib/state_machines/transition_collection.rb:127:in `run_callbacks' | |
state_machines (0.4.0) lib/state_machines/transition_collection.rb:63:in `block (2 levels) in perform' | |
state_machines (0.4.0) lib/state_machines/transition_collection.rb:63:in `block in perform' | |
state_machines (0.4.0) lib/state_machines/transition_collection.rb:186:in `within_transaction' | |
state_machines (0.4.0) lib/state_machines/transition_collection.rb:62:in `perform' | |
state_machines (0.4.0) lib/state_machines/transition.rb:163:in `perform' | |
state_machines (0.4.0) lib/state_machines/event.rb:155:in `fire' | |
state_machines (0.4.0) lib/state_machines/event.rb:219:in `block in add_actions' | |
state_machines (0.4.0) lib/state_machines/machine.rb:725:in `block (2 levels) in define_helper' | |
spree_frontend (3.1.1) app/controllers/spree/checkout_controller.rb:31:in `update' | |
actionpack (4.2.7.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action' | |
actionpack (4.2.7.1) lib/abstract_controller/base.rb:198:in `process_action' | |
actionpack (4.2.7.1) lib/action_controller/metal/rendering.rb:10:in `process_action' | |
actionpack (4.2.7.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action' | |
activesupport (4.2.7.1) lib/active_support/callbacks.rb:117:in `call' | |
activesupport (4.2.7.1) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile' | |
activesupport (4.2.7.1) lib/active_support/callbacks.rb:505:in `call' | |
activesupport (4.2.7.1) lib/active_support/callbacks.rb:92:in `__run_callbacks__' | |
activesupport (4.2.7.1) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks' | |
activesupport (4.2.7.1) lib/active_support/callbacks.rb:81:in `run_callbacks' | |
actionpack (4.2.7.1) lib/abstract_controller/callbacks.rb:19:in `process_action' | |
actionpack (4.2.7.1) lib/action_controller/metal/rescue.rb:29:in `process_action' | |
actionpack (4.2.7.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action' | |
activesupport (4.2.7.1) lib/active_support/notifications.rb:164:in `block in instrument' | |
activesupport (4.2.7.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument' | |
activesupport (4.2.7.1) lib/active_support/notifications.rb:164:in `instrument' | |
actionpack (4.2.7.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action' | |
actionpack (4.2.7.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action' | |
activerecord (4.2.7.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action' | |
actionpack (4.2.7.1) lib/abstract_controller/base.rb:137:in `process' | |
actionview (4.2.7.1) lib/action_view/rendering.rb:30:in `process' | |
actionpack (4.2.7.1) lib/action_controller/metal.rb:196:in `dispatch' | |
actionpack (4.2.7.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch' | |
actionpack (4.2.7.1) lib/action_controller/metal.rb:237:in `block in action' | |
actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:74:in `dispatch' | |
actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:43:in `serve' | |
actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:43:in `block in serve' | |
actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:30:in `serve' | |
actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:817:in `call' | |
railties (4.2.7.1) lib/rails/engine.rb:518:in `call' | |
railties (4.2.7.1) lib/rails/railtie.rb:194:in `method_missing' | |
actionpack (4.2.7.1) lib/action_dispatch/routing/mapper.rb:51:in `serve' | |
actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:43:in `block in serve' | |
actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:30:in `serve' | |
actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:817:in `call' | |
rack (1.6.4) lib/rack/etag.rb:24:in `call' | |
rack (1.6.4) lib/rack/conditionalget.rb:38:in `call' | |
rack (1.6.4) lib/rack/head.rb:13:in `call' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/flash.rb:260:in `call' | |
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context' | |
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/cookies.rb:560:in `call' | |
activerecord (4.2.7.1) lib/active_record/query_cache.rb:36:in `call' | |
activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call' | |
activerecord (4.2.7.1) lib/active_record/migration.rb:377:in `call' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call' | |
activesupport (4.2.7.1) lib/active_support/callbacks.rb:88:in `__run_callbacks__' | |
activesupport (4.2.7.1) lib/active_support/callbacks.rb:778:in `_run_call_callbacks' | |
activesupport (4.2.7.1) lib/active_support/callbacks.rb:81:in `run_callbacks' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/reloader.rb:73:in `call' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/remote_ip.rb:78:in `call' | |
better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call' | |
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call' | |
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call' | |
web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call' | |
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call' | |
railties (4.2.7.1) lib/rails/rack/logger.rb:38:in `call_app' | |
railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `block in call' | |
activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `block in tagged' | |
activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:26:in `tagged' | |
activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `tagged' | |
railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `call' | |
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/request_id.rb:21:in `call' | |
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call' | |
rack (1.6.4) lib/rack/runtime.rb:18:in `call' | |
activesupport (4.2.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call' | |
rack (1.6.4) lib/rack/lock.rb:17:in `call' | |
rack-livereload (0.3.16) lib/rack/livereload.rb:23:in `_call' | |
rack-livereload (0.3.16) lib/rack/livereload.rb:14:in `call' | |
actionpack (4.2.7.1) lib/action_dispatch/middleware/static.rb:120:in `call' | |
rack (1.6.4) lib/rack/sendfile.rb:113:in `call' | |
railties (4.2.7.1) lib/rails/engine.rb:518:in `call' | |
railties (4.2.7.1) lib/rails/application.rb:165:in `call' | |
rack (1.6.4) lib/rack/lock.rb:17:in `call' | |
rack (1.6.4) lib/rack/content_length.rb:15:in `call' | |
rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service' | |
/home/kim/.rbenv/versions/2.3.1/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service' | |
/home/kim/.rbenv/versions/2.3.1/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run' | |
/home/kim/.rbenv/versions/2.3.1/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread' | |
Started POST "/shop/__better_errors/c002239b18d62978/variables" for 127.0.0.1 at 2016-10-19 11:02:58 +0100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::LineItem.class_eval do | |
# If it's a normal product, can have as many as you like. | |
# If it's a one_per_user product, can only have one in cart. | |
validates :quantity, numericality: { | |
only_integer: true, | |
greater_than: -1, | |
message: Spree.t('validation.must_be_int') | |
} | |
validates :quantity, if: :is_one_per_user?, numericality: { | |
only_integer: true, | |
less_than: 2, | |
message: "error: You already have this in your cart! (Max 1)." | |
} | |
def is_one_per_user? | |
self.product.limit_one_to_user | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::Order.class_eval do | |
# Assign any packages that match stubs in the order | |
state_machine do | |
after_transition :to => :complete, :do => :assign_packages | |
end | |
private | |
# If any packages have a course code, add them to the user. | |
def assign_packages | |
# Iterate all the products in the order | |
self.products.each do |product| | |
# If any of them have a package, give it to the user who created the order | |
if product.package | |
self.created_by.packages << product.package | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::Product.class_eval do | |
belongs_to :package | |
has_one :unit | |
has_one :course | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment