Skip to content

Instantly share code, notes, and snippets.

@rterbush
rterbush / _brand.html.erb
Created April 9, 2013 20:54
Filter template for use with jbrien/spree_sunspot_search
<div class="filter" data-field="<%= filter.search_param %>">
<h4 class="filter-title"><%= t :shop_by_taxonomy, :taxonomy => filter.display_name %></h4>
<ul class="filter_choices">
<select name="<%= "s[#{filter.search_param}][]" %>" class="sidebar" size="10" multiple="true">
<% options = [] %>
<% filter.html_values.each_with_index.each do |hv, index| %>
<% options << hv[:value] %>
<% end %>
<% sortopts = options.sort %>
<% sortopts.each do |hv| %>
@rterbush
rterbush / shipment_state_decorator.rb
Last active December 16, 2015 02:49
Add states to Spree::Shipment model
Spree::Shipment.class_eval do
scope :sent, -> { with_state('sent') }
scope :confirmed, -> { with_state('confirmed') }
Spree::Shipment.state_machines[:state] =
StateMachine::Machine.new(Spree::Shipment, initial: :pending, use_transactions: false) do
event :ready do
transition from: :pending, to: :ready, if: lambda { |shipment|
# fixup order
a40.each_key do |k|
pair = k.split('|')
oid = pair[0]
sku = pair[1]
next unless oid == id
puts format("sku: %s ordered: %s filled: %s\n", sku, a40[k][0].to_i, a40[k][1].to_i)
ordered = a40[k][0].to_i
@rterbush
rterbush / routes.rb
Last active December 16, 2015 22:20
Spree::Core::Engine.routes.prepend do
match 'news/tag/:tag', :to => 'blog_entries#tag', :as => :tag
match 'news/:year/:month/:day/:slug', :to => 'blog_entries#show', :as => :news_entry_permalink
match 'news/:year(/:month)(/:day)', :to => 'blog_entries#archive', :as => :news_archive,:constraints => {:year => /(19|20)\d{2}/, :month => /[01]?\d/, :day => /[0-3]?\d/}
match 'news/feed', :to => 'blog_entries#feed', :as => :blog_feed, :format => :rss
match 'news', :to => 'blog_entries#index', :as => :news
end
ftp = Net::FTP.new
ftp.passive = true
ftp.connect(host)
ftp.login(uname,passwd)
lmtime = File.mtime("#{home}/.rsrtimestamp")
File.write("#{home}/.rsrtimestamp", tstart)
CSV.foreach(fd, :col_sep => ';', :quote_char => '|', :encoding => "CP1252") do |row|
ckeditor /ckeditor Ckeditor::Engine
spree / Spree::Core::Engine
Routes for Ckeditor::Engine:
pictures GET /pictures(.:format) ckeditor/pictures#index
POST /pictures(.:format) ckeditor/pictures#create
picture DELETE /pictures/:id(.:format) ckeditor/pictures#destroy
attachment_files GET /attachment_files(.:format) ckeditor/attachment_files#index
POST /attachment_files(.:format) ckeditor/attachment_files#create
attachment_file DELETE /attachment_files/:id(.:format) ckeditor/attachment_files#destroy
Spree::Image.class_eval do
# before_post_process :rename_attachment
attachment_definitions[:attachment][:convert_options] = {
'all' => "-strip -trim -gravity center -filter Catrom",
'mini' => "-strip -trim -gravity center -filter Catrom",
'small' => "-strip -trim -gravity center -filter Catrom",
'product' => "-strip -trim -gravity center -filter Catrom",
'large' => "-strip -trim -gravity center -filter Catrom"
NoMethodError (undefined method `count_on_hand' for nil:NilClass):
vendor/bundle/ruby/1.9.1/bundler/gems/spree-008ea0178f00/core/app/models/spree/stock_location.rb:50:in `fill_status'
vendor/bundle/ruby/1.9.1/bundler/gems/spree-008ea0178f00/core/app/models/spree/stock/packer.rb:19:in `block in default_package'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/associations/collection_proxy.rb:89:in `each'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/associations/collection_proxy.rb:89:in `method_missing'
vendor/bundle/ruby/1.9.1/bundler/gems/spree-008ea0178f00/core/app/models/spree/stock/packer.rb:18:in `default_package'
vendor/bundle/ruby/1.9.1/bundler/gems/spree-008ea0178f00/core/app/models/spree/stock/packer.rb:13:in `packages'
vendor/bundle/ruby/1.9.1/bundler/gems/spree-008ea0178f00/core/app/models/spree/stock/coordinator.rb:21:in `block in build_packages'
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/relation/delegation.rb:6:in
def destination_address(address)
addrobj = TaxCloud::Address.new({
:address1 => address.address1,
:address2 => address.address2,
:city => address.city,
:state => address.state.abbr,
:zip5 => address.zipcode[0..4]
})
<h5 class="stock-shipping-method-title"><%= Spree.t(:shipping_method) %></h5>
<ul class="field radios shipping-methods">
<% ship_form.object.shipping_rates.each do |rate| %>
<li class="shipping-method">
<label>
<%= ship_form.radio_button :selected_shipping_rate_id, rate.id %>
<span class="rate-name"><%= rate.name %></span>
<span class="rate-cost"><%= number_to_currency rate.cost %></span>
</label>
</li><br />