Skip to content

Instantly share code, notes, and snippets.

View peterberkenbosch's full-sized avatar
:shipit:

Peter Berkenbosch peterberkenbosch

:shipit:
View GitHub Profile

Rails 7 Solidus demo

Rails Starter Template

Use this template

(optional) Rebase upstream template repo

Make note of upstream sha when templated: 2add9da (https://cln.sh/ETfqYT) and the first commit sha from templated new repo: 85f49ba

@peterberkenbosch
peterberkenbosch / gist:0c35e74380bb6c46417459713aa81290
Created September 14, 2020 09:00
Stacktrace rubocop-ast 0.4.0 affirm_v2
An error occurred while Layout/LineLength cop was inspecting /Users/peterberkenbosch/code/solidusio-contrib/solidus_affirm_v2/spec/views/spree/checkout/payment/affirm_v2_spec.rb:14:4.
can't modify frozen Array
/Users/peterberkenbosch/.gem/ruby/2.6.6/gems/rubocop-0.87.1/lib/rubocop/cop/mixin/check_line_breakable.rb:174:in `pop'
/Users/peterberkenbosch/.gem/ruby/2.6.6/gems/rubocop-0.87.1/lib/rubocop/cop/mixin/check_line_breakable.rb:174:in `process_args'
/Users/peterberkenbosch/.gem/ruby/2.6.6/gems/rubocop-0.87.1/lib/rubocop/cop/mixin/check_line_breakable.rb:47:in `extract_breakable_node'
/Users/peterberkenbosch/.gem/ruby/2.6.6/gems/rubocop-0.87.1/lib/rubocop/cop/layout/line_length.rb:102:in `check_for_breakable_node'
/Users/peterberkenbosch/.gem/ruby/2.6.6/gems/rubocop-0.87.1/lib/rubocop/cop/layout/line_length.rb:75:in `on_potential_breakable_node'
/Users/peterberkenbosch/.gem/ruby/2.6.6/gems/rubocop-0.87.1/lib/rubocop/cop/commissioner.rb:91:in `block (2 levels) in trigger_responding_cops'
/Users/peterberkenbo
@peterberkenbosch
peterberkenbosch / contribute-spree.md
Created August 17, 2018 19:16
Contribute to Spree - Setup git and github

In this small guide I will share the setup I use to contribute to SpreeCommerce.

Disclaimer: This post contains some content written by me and others for the developer guides at SpreeCommerce.

Fork and setup upstream remote

Fork the repo the spree repository on github and clone the spree project on your local machine:

git clone YOUR-REPO-URL
set = [1.1, 1.2, 0.85, 2.0, 1.3, 3.2]
geo_avg = (set.inject{|a,b| a*b}) ** (1.0/set.size)
@peterberkenbosch
peterberkenbosch / spree.rb
Created January 23, 2015 11:35
disable mail in Spree
Spree.config do |config|
config.send_core_emails = false
end
@peterberkenbosch
peterberkenbosch / wombat.rb
Created October 13, 2014 16:51
Wombat RB sample complete orders
config.payload_builder = {
#... rest omitted for clearity.
"Spree::Order" => { serializer: "Spree::Wombat::OrderSerializer", root: "orders", filter: "complete" }
}
@peterberkenbosch
peterberkenbosch / order_push_wombat_sample.rb
Last active August 29, 2015 14:07
push current order to wombat after_commit
Spree::Order.class_eval do
after_commit :wombat_push_spree_orders
def wombat_push_spree_orders
if self.state == "complete"
payload_builder = Spree::Wombat::Config[:payload_builder]["Spree::Order"]
payload = ActiveModel::ArraySerializer.new([order],
each_serializer: payload_builder[:serializer].constantize,
root: payload_builder[:root]
).to_json
Spree::Wombat::Client.push(payload)
@peterberkenbosch
peterberkenbosch / s3_assets_spree.rb
Created August 25, 2014 15:47
Use S3 to store images with Spree
attachment_config = {
s3_credentials: {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
bucket: ENV['S3_BUCKET_NAME']
},
storage: :s3,
s3_headers: { "Cache-Control" => "max-age=31557600" },
@peterberkenbosch
peterberkenbosch / extend_products.md
Created August 18, 2014 12:41
add additional content for products

Extend the product sample

Generate migration to add the columns:

bundle exec rails g migration AddExtraContentToProducts
class AddExtraContentToProducts < ActiveRecord::Migration
@peterberkenbosch
peterberkenbosch / count_complete_orders_by_sku.rb
Created August 12, 2014 20:39
Count number of sold products
Spree::LineItem.joins(:variant).merge(Spree::Variant.where(sku: "ROR-00011")).joins(:order).merge(Spree::Order.where(state: 'complete')).count