Spree is a complete open source e-commerce solution for Ruby on Rails. Ecommerce Storefront and Platform Solutions | Spree Commerce

Spree 's latest version does this on remote - undefined method `set_preference' for nil:NilClass

Everything works perfect on my local. I installed everything appropriately on the server, and when I run rake db:bootstrap or rake db:migrate, I get this :

rake aborted!
undefined method `set_preference' for nil:NilClass
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/whiny_nil.rb:48:in `method_missing'
/home/chrisisraw/webapps/rails/gems/bundler/gems/spree-17e74dd1e908/core/lib/spree/preference_access.rb:18:in `set'
/home/chrisisraw/webapps/rails/gems/bundler/gems/spree-17e74dd1e908/core/lib/spree/preference_access.rb:17:in `each'
/home/chrisisraw/webapps/rails/gems/bundler/gems/spree-17e74dd1e908/core/lib/spree/preference_access.rb:17:in `set'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in `load'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in `load'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:596:in `new_constants_in'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in `load'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/engine.rb:200:in `each'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/initializable.rb:25:in `instance_exec'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/initializable.rb:25:in `run'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/initializable.rb:50:in `run_initializers'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/initializable.rb:49:in `each'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/initializable.rb:49:in `run_initializers'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/application.rb:134:in `initialize!'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/application.rb:77:in `send'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/application.rb:77:in `method_missing'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:596:in `new_constants_in'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/application.rb:103:in `require_environment!'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/local/ruby1.8.7ee/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/local/ruby1.8.7ee/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/local/ruby1.8.7ee/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/chrisisraw/webapps/rails/bin/rake:19:in `load'

Anyone figure this out?

Source: (StackOverflow)

Spree Commerce: any themes?

I searched whole morning, and find out that there aren't any themes either to purchase or download for Spree. It seems that I have to build custom store front myself.

Spree seems to be very limited in this aspect when compared to OpenCart and PrestaShops.

Am I right?

Source: (StackOverflow)

Spree as multilingual/bilingual site

Is spree suitable for multi/bilingual e-commerce site?

By default it supports internationalization (i18n - It gives an impression that spree is bilingual friendly but I'm missing one piece of the puzzle. Translation of product names, descriptions, attributes, categories.

What is your good practice when it comes to translation of products and categories (including metadata)?

gem version: Spree 1.1.1

Source: (StackOverflow)

Adding a step to the Spree checkout process

I'm trying to add an extra step to my Spree 1.2 store which will allow a customer to create a subscription. I've inserted the step, and rendered the correct view, but when the user clicks 'save and continue' the next step is rendered, but nothing is actually saved.

I understand that I need to add a state_callback, but I'm not sure how to do this and the Spree documentation is very lacking around this (presumably because it's quite new)

At present I've got the following in my extension:


Spree::Order.class_eval do
  belongs_to :subscription

  accepts_nested_attributes_for :subscription

  # This doesn't appear to be called
  Spree::Order.state_machine.after_transition :from => :subscription,
                                              :do => :valid_subs?

  checkout_flow do
    go_to_state :address
    go_to_state :subscription
    go_to_state :payment, :if => lambda { |order| order.payment_required? }
    go_to_state :confirm, :if => lambda { |order| order.confirmation_required? }
    go_to_state :complete
    remove_transition :from => :delivery, :to => :confirm

Not entirely sure that accepts_nested_attributes is necessary, but my dev approach for this has been trial and error so far, so it ended up staying there.

In models/subscription.rb

class Subscription < ActiveRecord::Base

  attr_accessible :start_date, :frequency

  belongs_to :user 
  has_many :orders
  has_many :products

  validates :start_date, :frequency, :presence => true

  def schedule
    ...code that returns a list of dates rendered on FE...

  private #----

  ... some methods used in schedule ...

  def valid_subs?
    binding.pry # never called

  def after_subscription
    binding.pry # never called either...


<h1><%= t(:"subscription.title") %></h1>

<div class="columns alpha six" data-hook="subscription_calendar_fieldset_wrapper">
  <fieldset id="subscription_calendar" data-hook>
    <%= form.fields_for :subscription_picker do |subscription_picker| %>
      <legend><%= t(:"subscription.first_delivery") %></legend>
      <%= render :partial => 'subscription/picker' %>
    <% end %>

<div class="columns omega six" data-hook="subscription_dates_fieldset_wrapper">
  <fieldset id="subscription_dates" data-hook>
    <legend align="center"><%= t(:"subscription.next_deliveries") %></legend>
    <div class='dates'></div>

<div class="form-buttons" data-hook="buttons" style='clear:both;'>
  <%= submit_tag t(:save_and_continue), :class => 'continue button primary' %>


<div class='row'>
  <label for="subscription_frequency">Occurs every:</label>
  <% frequency_options = [["2 Weeks", 14], ["3 Weeks", 21], ["Month", 30], ["2 Months", 60], ["3 Months", 90]] %>
  <%= select(:subscription, :frequency, options_for_select(frequency_options, 30), {}) %>
<div id="start-date-picker" class="calendar"></div>
<%= hidden_field(:subscription, :start_date, {value: ( + 14).to_date.iso8601}) %>

... JS that creates the calendar ...

On clicking 'save and continue' I see the following params sent:

                  "utf8" => "✓",
               "_method" => "put",
    "authenticity_token" => "...BLAH...",
          "subscription" => {
         "frequency" => "30",
        "start_date" => "2012-11-17"
                "commit" => "Save and Continue",
            "controller" => "spree/checkout",
                "action" => "update",
                 "state" => "subscription"

Source: (StackOverflow)

spree-paypal-express fails with "Gateway Error: translation missing: en.the_totals_of_the_cart_item_amounts_do_not_match_order_amounts "

I'm using spree 1-2-stable, and I'm using spree-paypap-express 1-2-stable branch (tried with master too but failed again). When I try to checkout an order and select PayPal express as the payment method it fails with an error: "Gateway Error: translation missing: en.the_totals_of_the_cart_item_amounts_do_not_match_order_amounts". For some reason the order total does not match cart item amounts. I spent whole weekend on this and still have no idea why this is happening.

The issue only happens if I include shipping with price > 0 (it works if I set the shipping price to 0). As soon as I change the shipping price to be a value >0 or some % it breaks. I tried with both "Shipment including VAT" true and false - same thing.

Any ideas? Is this a bug in ppx or I'm I missing something?

UPDATE: 12/12/12

Here are the values I'm using to reproduce the problem: I am using VAT (icnluded in the price - 25%), the price of the item I'm trying to purchase is 265 EUR (the currecy does not matter), item quantity is 1 and the shipping is 15EUR (again vat is included in shipping price) this is flat order tax.

I get the error that order total does not match summed items amount. After some debugging i found that indeed those are different before sending to PayPal.

Why are is my total calculated wrong? I'm using the 1-2-stable branch of spree. My gemfile:

gem 'spree', :git => 'git://', :branch => '1-2-stable'
#gem 'spree_usa_epay'
#gem 'spree_skrill'
gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch => '1-2-stable'
gem 'spree_paypal_express', :github => 'spree/spree_paypal_express', :branch => '1-2-stable'

My real question is how do I recalculate shipping and taxes just before the payment step (after the delivery step) and also how do I override the calculators so that they calculate correctly?

Source: (StackOverflow)

Adding Routes to Rails' Spree E-Commerce

I just recently upgraded to 1.0.3, and the routes.rb file in my config/routes folder seems to ignore all my custom routes.

MY routes.rb

JollyStore::Application.routes.draw do
  # Mount Spree's routes
  mount Spree::Core::Engine, :at => '/'

  root :to => 'pages#index'

  namespace :admin do
    resources :wysiwygs

  match 'about_us/', :to => "pages#about_us"
  match 'services/', :to => "pages#services"
  match 'raw_resources/', :to => "pages#raw_resources"
  match 'contact_us/', :to => "pages#contact_us"

  match 'privacy_policy/', :to => "pages#privacy_policy"
  match 'return_policy/', :to => "pages#return_policy"
  match 'refund_policy/', :to => "pages#refund_policy"
  match 'cancellation_policy/', :to => "pages#cancellation_policy"
  match 'delivery_shipping_policy/', :to => "pages#delivery_shipping_policy"


If I run bundle exec rake routes, it returns all the approriate routes. But when I try to reach that specific page, I get :

undefined local variable or method `about_us_path'

Or the same error for every link that is within my custom routes. Somehow my routes are being ignored. Does anyone know a way to circumvent this issue?

Source: (StackOverflow)

Security Update for Spree Finding Nil for Money:Class

This security update for spree just released, but after running some Cucumber tests, I had this recurring issue:

undefined method `assume_from_symbol' for Money:Class (ActionView::Template::Error)

I searched the project repo on GH and we don't use the method. Searched the Money repo and also no findings. Searched Spree and found this. The method appears to be undefined on my development environment.

I don't know if its Spree or the project I'm dealing with. Does anyone know how to fix this?

Update: When I run bundle exec zeus cucumber I don't get these errors...

Source: (StackOverflow)

Spree 2.1 strong parameters

Is there a easy way to add a new permitted parameter to controllers in Spree without altering the defaults ?

I'm trying to change the orders_params method in OrdersController.

Source: (StackOverflow)

Spree: customize the key attributes of a product

Does anyone know if it's possible to add a new attribute to the set of key attributes (Name, Description, Permalink, Meta Description etc) of a product? The idea is that I want to have these attributes available when I create a product instead of adding them afterwards through Product Properties.


Source: (StackOverflow)

Asset Path Error in Spree / Ruby on Rails

I am setting up my second "spree" store in a local development environment to work on an ecommerce project using the Spree gem for RubyOnRails.

The first store works, but when I shut off the "rails server" for store1 and try to fire it up for store2, when I go to http://localhost:3000 I get this this error:

Sprockets::Rails::Helper::AbsoluteAssetPathError in Spree::Home#index

Showing /Users/pivot/.rvm/gems/ruby-2.0.0-p481/gems/spree_frontend-2.3.2/app/views/spree/shared/_head.html.erb where line #7 raised:

Asset names passed to helpers should not include the "/assets/" prefix. Instead of "/assets/favicon.ico", use "favicon.ico"

Extracted source (around line #7):

  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1" name="viewport">
  <%== meta_data_tags %>
  <%= canonical_tag(current_store.url) %>
  <%= favicon_link_tag image_path('favicon.ico') %> #THIS IS THE HIGHLIGHTED LINE
  <%= stylesheet_link_tag 'spree/frontend/all', :media => 'screen' %>
  <%= csrf_meta_tags %>
  <%= javascript_include_tag 'spree/frontend/all' %>

Trace of template inclusion: /Users/pivot/.rvm/gems/ruby-2.0.0-p481/gems/spree_frontend-2.3.2/app/views/spree/layouts/spree_application.html.erb

This error is coming from a spree view file, and the offending line is actually just passing in "favicon.ico" not "assets/favicon.ico", so I don't know what's going on.

Source: (StackOverflow)

how to change the Spree default home page?

I want to change the root path of spree site to a static page.

Can anyone please tell how can I change the spree default home page?

Source: (StackOverflow)

What does this Rails Engine code mean: config.to_prepare &method(:activate).to_proc

I'm working with Spree, which uses Rails engines extensively. A common pattern I find is this. However I have trouble understanding this code.

class Engine < Rails::Engine 
  def self.activate

  config.to_prepare &method(:activate).to_proc
  1. What does .to_prepare do
  2. What does the &method operator do?
  3. What is the overall effect of the code?

Many Thanks!

Source: (StackOverflow)

Spree overriding helper method

I'm trying to overriding a helper method of base_helper.rb by using this:

module Spree
  module BaseHelper.class_eval do

    def taxons_tree(root_taxon, current_taxon, max_level = 1)


It's not working for me. Anyone know what I am missing here?

Thank you!


I should use:

Spree::BaseHelper.module_eval do

    def taxons_tree(root_taxon, current_taxon, max_level = 1)



Source: (StackOverflow)

What causes the "ArgumentError (dump format error)"?

While troubleshooting a misbehavior in Spree where the product list was not paginating and was only listing the first 10 products or so, I attempted to reproduce the error in my local development environment and on the first page load I received the error:

ArgumentError (dump format error)

As always, I checked my other brain first. The top search result was:

Although the the user who started that thread and several of the other posters were attempting an upgrade from Rails 3.0.9 to Rails 3.1, I didn't think it would apply to my case. The Spree 0.60.2 app I'm running is at Rails 3.0.9.

However, as it turns out, simply clearing my localhost cookies solved the problem. Why?

Source: (StackOverflow)

Spree search filter for properties and variants

I'm running Spree 1.3.1 and I'm trying to customize the Taxon show page.

I would like it to return the products contained inside the current Taxon, eventually filtered by a property or by an option value.

For example let's say that I'm seeing the Taxon of an underwear collection. I'd like to filter the products shown, by providing a certain size (option_type). In this case I should list only products that have variants with the requested size.

I would like also to be able to filter the products by the "fit" property. Filtering by the slip fit, I should be able to list only products inside the current Taxon that have the required property.

This is the Taxon controller show action:

Spree::TaxonsController.class_eval do

    def show
      @taxon = Spree::Taxon.find_by_permalink!(params[:id])
      return unless @taxon

      @searcher =
      @searcher.current_user = try_spree_current_user
      @searcher.current_currency = current_currency
      @products = @searcher.retrieve_products



How should I modify it to fit my needs?

Source: (StackOverflow)