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 / heroku_ssl_error.md
Last active August 15, 2019 21:11
heroku push openssl

Do you see this error pushing to the hub from Heroku?

/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:918:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)

This indicates that ruby is unable to find the certification authority certificates. You can probably confirm this by setting the following in your code:

@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)
initializer 'spree.register.calculators' do |app|
app.config.spree.calculators.shipping_methods << Spree::Calculator::Shipping::MyCalc
end
@peterberkenbosch
peterberkenbosch / one_time_user_promotion.rb
Last active December 31, 2015 13:48
decorate user promotion rule to allow only a 1 time use
Spree::Promotion::Rules::User.class_eval do
def eligible?(order, options = {})
user = order.user
promotion_count = Spree::Adjustment.promotion.where(source_id: Spree::Order.select(:id).where(user_id: user.id).collect(&:id) ).count
users.include?(user) && promotion_count == 0
end
end
<% if rate.respond_to(:pickup_date) %>
<%= ship_form.text_field :pickup_date %>
<% end %>
@peterberkenbosch
peterberkenbosch / add_snippet.html.erb.deface
Created December 6, 2013 21:59
Deface the category (taxon/show) template here app/overrides/spree/taxons/show/add_snippet.html.erb.deface 'sample' is the slug of the page.
<!-- insert_before "[data-hook='taxon_products']" -->
<%=render_snippet('sample')%>
def compute(computable)
# Spree::LineItem -> :compute_line_item
computable_name = computable.class.name.demodulize.underscore
method = "compute_#{computable_name}".to_sym
calculator_class = self.class
begin
self.send(method, computable)
rescue NoMethodError
raise NotImplementedError, "Please implement '#{method}(#{computable_name})' in your calculator: #{calculator_class.name}"
end