Skip to content

Instantly share code, notes, and snippets.

View BDQ's full-sized avatar
💥

Brian Quinn BDQ

💥
View GitHub Profile
@BDQ
BDQ / development.log
Last active December 15, 2015 18:19
line_item.destroy using after_destroy callback (stock 1-3-stable)
(0.1ms) begin transaction
Spree::Adjustment Load (0.1ms) SELECT "spree_adjustments".* FROM "spree_adjustments" WHERE "spree_adjustments"."adjustable_id" = 10 AND "spree_adjustments"."adjustable_type" = 'Spree::LineItem'
Spree::Order Load (0.1ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."id" = 3 LIMIT 1
Spree::InventoryUnit Load (0.1ms) SELECT "spree_inventory_units".* FROM "spree_inventory_units" WHERE "spree_inventory_units"."order_id" = 3
SQL (0.2ms) DELETE FROM "spree_line_items" WHERE "spree_line_items"."id" = ? [["id", 10]]
Spree::Adjustment Load (0.1ms) SELECT "spree_adjustments".* FROM "spree_adjustments" WHERE "spree_adjustments"."adjustable_id" = 3 AND "spree_adjustments"."adjustable_type" = 'Spree::Order' AND "spree_adjustments"."originator_type" = 'Spree::TaxRate' AND "spree_adjustments"."adjustable_type" = 'Spree::Order' ORDER BY created_at ASC
Spree::LineItem Load (0.1ms) SELECT "spree_line_items".* FROM "spree_line_items" WHERE "spree_line_items"."o
@BDQ
BDQ / development.log
Last active December 15, 2015 18:19
line_item.destroy with after_commit callback
(0.1ms) begin transaction
Spree::Adjustment Load (0.1ms) SELECT "spree_adjustments".* FROM "spree_adjustments" WHERE "spree_adjustments"."adjustable_id" = 9 AND "spree_adjustments"."adjustable_type" = 'Spree::LineItem'
Spree::Order Load (0.1ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."id" = 3 LIMIT 1
Spree::InventoryUnit Load (0.1ms) SELECT "spree_inventory_units".* FROM "spree_inventory_units" WHERE "spree_inventory_units"."order_id" = 3
SQL (0.3ms) DELETE FROM "spree_line_items" WHERE "spree_line_items"."id" = ? [["id", 9]]
(1.1ms) commit transaction
Spree::Adjustment Load (0.1ms) SELECT "spree_adjustments".* FROM "spree_adjustments" WHERE "spree_adjustments"."adjustable_id" = 3 AND "spree_adjustments"."adjustable_type" = 'Spree::Order' AND "spree_adjustments"."originator_type" = 'Spree::TaxRate' AND "spree_adjustments"."adjustable_type" = 'Spree::Order' ORDER BY created_at ASC
Spree::LineItem Load (0.1ms) SELECT "spree_line_items".* FROM "spree_line_items" W
p = Spree::Product.find_by_name('Ruby on Rails Bag')
si = p.master.stock_items.first
si.update_attribute(:count_on_hand, 0)
sl = Spree::StockLocation.create(name: 'Second Location')
sl.stock_items.create(variant: p.master, count_on_hand: 10)
sl.active = true
sl.save!
Generating dummy Rails application...
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
Setting up dummy database...
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
Generating dummy Rails application...
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
Setting up dummy database...
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
Generating dummy Rails application...
WARNING: Nokogiri was built against LibXML version 2.8.0, but has dynamically loaded 2.7.8
apt-get install ufw -y
ufw allow ssh/tcp
ufw allow 80
ufw allow 443
ufw logging on
ufw enable
@BDQ
BDQ / bash.sh
Created November 16, 2012 10:55
Foreman - bluepill - custom template
bundle exec foreman export bluepill --template=/data/bluepill/ /etc/init
@BDQ
BDQ / order_decorator.rb
Created November 9, 2012 17:09
Spree API patches to allow 'checkout'.
#order model decorator
Order.class_eval do
accepts_nested_attributes_for :line_items, :allow_destroy => true
def self.build_from_api(user, params)
order = create
params[:line_items_attributes].each do |line_item|
order.add_variant(Spree::Variant.find(line_item[:variant_id]), line_item[:quantity])
end
@BDQ
BDQ / bash
Created October 26, 2012 08:40
Re-run specs until they fail (handy for random / inconsistent failures).
RET=0;until [[ $RET = 1 ]];do bundle exec rspec; RET="$?";sleep 1;done
---
CensusInfo:
CityName:
Country:
County:
CountyNum:
FinanceNumber:
FirmOrRecipient:
GeoLocationInfo:
IntelligentMailBarcodeKey:
ActionView::Template::Error (undefined method `states' for nil:NilClass):
109: </p>
110:
111: <% if Spree::Config[:address_requires_state] %>
112: <p class="field" id="sstate">
113: <% have_states = [email protected]_address.country.states.empty? %>
114: <%= ship_form.label :state, t(:state) %><span class="required">*</span><br><% state_elements = [
115: ship_form.collection_select(:state_id, @order.ship_address.country.states,
/Users/briandquinn/.rvm/gems/ruby-1.9.3-p194/bundler/gems/spree-7df8f8d05580/core/app/views/spree/checkout/_address.html.erb:112:in `block in _c9611975a5f69558aac0f93cee17dc89'
actionpack (3.2.8) lib/action_view/helpers/capture_helper.rb:40:in `block in capture'