💵 Spree is a complete open source e-commerce solution for Ruby on Rails.
Switch branches/tags
0.60.0-paperclip 1-1-stable 1-1-stableish 1-2-stable 1-3-3-aws-bump 1-3-rebased 1-3-rebased2 1-3-stable 1-3-stableish 2-0-adjustments 2-0-stable 2-0-stickermule-shipping 2-0-stickermule 2-1-adjustments 2-1-stable-me 2-2-idempotent_processing 2-2-lav-addcapture 2-2-lav-helperfix 2-2-lav-rebased 2-2-lav 2-2-rebased 2-2-review_comments 2-2-stable-me 2-2-stable-money-version 2-2-stable+mu 2-2-stable 2-2-wellamy 2-4-wellamy 2071-optional-api-authentication 2072-country-states-required 2079-refactor-controller-helpers ME_2-0-5 ME_2-0-10 active-merchant-amount-fix active_model_promotion_build add_customer_id_to_gateway_options admin-page-actions-overflow admin-redesign admin_cart_cleanup_squashed admin_cart_cleanup advance_after_approve around_block_inventory_test auto_capture aws-bump aws-sdk-bump-master bashisms better_coupon_errors bonobos_2-2-dev_backend-cart-cleanup build_searcher cancan_improvements carton-shared-examples coupon-code-style-master coupon-code-style currency-gateway currency-itemprop currency-price-in-cart-fix currency-product-search currency-split currency-support-squashed currency-support current_order_18hash debugging-api default-tax-rate define_callbacks_terminator display_image_specific_subject extract-gateway-order-id fix-default-tax-vat-calculation fix-for-hates-vat fix-nav-confirmations fix_edit_payment fix_infinite_redirect fix_payment_radio fix_preferences force_non_ssl_redirect force_non_ssl_redirect_2-0-5 gateway_method_missing guides-merge guides-tree-rewrite idempotent_processing in-stock-availability inventory_management_improvements item_adjustments jirafe-v2 kill_alternative_billing_phone kill_billing_integration kill_checkout_spec kill_current_spree_page kill_gem_available kill_object_params kill_order_contains kill_payment_method_environment kill_product_scope kill_shipped_shipments kill_shipping_method_private_class_methods kill_spree_configuration kill_tracker_environment kill_variant_scope like_any_arel line_item_description master-advance_approve master merge-api-to-core mo_money_money next_on_approve order_details_local_order order_split payment_required permitted_attributes plug_leaky_database preferences_allow_ssl preferences_printf_debugging price_adjustment_totals product_admin_speedups product_image_check_removal products_optimization protocol-specific-google-font rails-3-2-2 rails-3.2.7.rc1 refactor-available-to-order refactor_product_autocomplete remove_allow_return_item_amount_editing remove_attachment_settings remove_cc_fields remove_order_by_ remove_preferred_shipment remove_redirect_https_to_http remove_ssl_options remove_states_required_by_country remove_unused_cc_fields remove_update_line_items remove_useless_param_on_discounts resource_controller_routes shipment_adjustment_api_fix shipping-instructions-master shipping-instructions-style simplify-admin-order-tabs split-prices-migration spree-issue-2335 squashing-migrations store_model taxon_refactor tiny_checkout_comment_fix wellamy/reduce_queries
Nothing to show
Clone or download
Pull request Compare This branch is 7176 commits behind spree:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
api
backend
cmd
core
frontend
lib
sample
.gitignore
.travis.yml
CONTRIBUTING.md
Gemfile
README.md
Rakefile
SPREE_VERSION
build.sh
common_spree_dependencies.rb
install.rb
license.md
missing_translations.rb
spree.gemspec

README.md

THIS README IS FOR THE MASTER BRANCH OF SPREE AND REFLECTS THE WORK CURRENTLY EXISTING ON THE MASTER BRANCH. IF YOU ARE WISHING TO USE A NON-MASTER BRANCH OF SPREE, PLEASE CONSULT THAT BRANCH'S README AND NOT THIS ONE.

SUMMARY

Spree is a complete open source e-commerce solution built with Ruby on Rails. It was originally developed by Sean Schofield and is now maintained by a dedicated core team. You can find out more by visiting the Spree e-commerce project page.

Spree actually consists of several different gems, each of which are maintained in a single repository and documented in a single set of online documentation. By requiring the Spree gem you automatically require all of the necessary gem dependencies which are:

  • spree_api (RESTful API)
  • spree_frontend (User-facing components)
  • spree_backend (Admin area)
  • spree_cmd (Command-line tools)
  • spree_core (Models & Mailers, the basic components of Spree that it can't run without)
  • spree_sample (Sample data)

All of the gems are designed to work together to provide a fully functional e-commerce platform. It is also possible, however, to use only the pieces you are interested in. For example, you could use just the barebones spree_core gem and perhaps combine it with your own custom backend admin instead of using spree_api.

Code Climate

Installation

THIS README IS FOR THE MASTER BRANCH OF SPREE AND REFLECTS THE WORK CURRENTLY EXISTING ON THE MASTER BRANCH. IF YOU ARE WISHING TO USE A NON-MASTER BRANCH OF SPREE, PLEASE CONSULT THAT BRANCH'S README AND NOT THIS ONE.

The fastest way to get started is by using the spree command line tool available in the spree gem which will add Spree to an existing Rails application.

gem install rails -v 4.0.5
gem install spree
rails _4.0.5_ new my_store
spree install my_store

This will add the Spree gem to your Gemfile, create initializers, copy migrations and optionally generate sample products and orders.

If you get an "Unable to resolve dependencies" error when installing the Spree gem then you can try installing just the spree_cmd gem which should avoid any circular dependency issues.

gem install spree_cmd

To auto accept all prompts while running the install generator, pass -A as an option

spree install my_store -A

Using stable builds and bleeding edge

To use a stable build of Spree, you can manually add Spree to your Rails 4.0.x application. To use the 2-2-stable branch of Spree, add this line to your Gemfile.

gem 'spree', github: 'spree/spree', branch: '2-2-stable'

Alternatively, if you want to use the bleeding edge version of Spree, use this line:

gem 'spree', github: 'spree/spree'

Note: The master branch is not guaranteed to ever be in a fully functioning state. It is unwise to use this branch in a production system you care deeply about.

Note: The master branch is depending on the latest Rails 4.1 release.

If you wish to have authentication included also, you will need to add the spree_auth_devise gem as well. Either this:

gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-2-stable'

Or this:

gem 'spree_auth_devise', github: 'spree/spree_auth_devise'

Once you've done that, then you can install these gems using this command:

bundle install

Use the install generator to set up Spree:

rails g spree:install --sample=false --seed=false

At this point, if you are using spree_auth_devise you will need to change this line in config/initializers/spree.rb:

Spree.user_class = "Spree::LegacyUser"

To this:

Spree.user_class = "Spree::User"

You can avoid running migrations or generating seed and sample data by passing in these flags:

rails g spree:install --migrate=false --sample=false --seed=false

You can always perform the steps later by using these commands.

bundle exec rake railties:install:migrations
bundle exec rake db:migrate
bundle exec rake db:seed
bundle exec rake spree_sample:load

Browse Store

http://localhost:nnnn

Browse Admin Interface

http://localhost:nnnn/admin

Working with the edge source (latest and greatest features)

The source code is essentially a collection of gems. Spree is meant to be run within the context of Rails application. You can easily create a sandbox application inside of your cloned source directory for testing purposes.

  1. Clone the Git repo
git clone git://github.com/spree/spree.git
cd spree
  1. Install the gem dependencies
bundle install
  1. Create a sandbox Rails application for testing purposes (and automatically perform all necessary database setup)
bundle exec rake sandbox
  1. Start the server
cd sandbox
rails server

Performance

You may notice that your Spree store runs slowly in development mode. This is a side-effect of how Rails works in development mode which is to continuously reload your Ruby objects on each request. The introduction of the asset pipeline in Rails 3.1 made default performance in development mode significantly worse. There are, however, a few tricks to speeding up performance in development mode.

You can precompile your assets as follows:

bundle exec rake assets:precompile:nondigest

If you want to remove precompiled assets (recommended before you commit to Git and push your changes) use the following rake task:

bundle exec rake assets:clean

Use Dedicated Spree Devise Authentication

Add the following to your Gemfile

gem 'spree_auth_devise', github: 'spree/spree_auth_devise'

Then run bundle install. Authentication will then work exactly as it did in previous versions of Spree.

This line is automatically added by the spree install command.

If you're installing this in a new Spree 1.2+ application, you'll need to install and run the migrations with

bundle exec rake spree_auth:install:migrations
bundle exec rake db:migrate

change the following line in config/initializers/spree.rb

Spree.user_class = 'Spree::LegacyUser'

to

Spree.user_class = 'Spree::User'

In order to set up the admin user for the application you should then run:

bundle exec rake spree_auth:admin:create

Running Tests

Team City

We use TeamCity to run the tests for Spree.

You can see the build statuses at http://ci.spree.fm.


Each gem contains its own series of tests, and for each directory, you need to do a quick one-time creation of a test application and then you can use it to run the tests. For example, to run the tests for the core project.

cd core
bundle exec rake test_app
bundle exec rspec spec

If you would like to run specs against a particular database you may specify the dummy apps database, which defaults to sqlite3.

DB=postgres bundle exec rake test_app

If you want to run specs for only a single spec file

bundle exec rspec spec/models/state_spec.rb

If you want to run a particular line of spec

bundle exec rspec spec/models/state_spec.rb:7

You can also enable fail fast in order to stop tests at the first failure

FAIL_FAST=true bundle exec rspec spec/models/state_spec.rb

If you want to run the simplecov code coverage report

COVERAGE=true bundle exec rspec spec

If you're working on multiple facets of Spree to test, please ensure that you have a postgres user:

createuser -s -r postgres

And also ensure that you have PhantomJS installed as well:

brew update && brew install phantomjs

To execute all the tests, you may want to run this command at the root of the Spree project to generate test applications and run specs for all the facets:

bash build.sh

Further Documentation

Spree has a number of really useful guides online at http://guides.spreecommerce.com.

Contributing

Spree is an open source project and we encourage contributions. Please see the contributors guidelines before contributing.