Adding Spree to an existing Rails application
gem 'spree' # core and API
gem 'spree_backend' # Rails admin panel (optional)
gem 'spree_emails' # transactional emails (optional)
gem 'spree_sample' # dummy data like products, taxons, etc
gem 'spree_auth_devise', '~> 4.3' # Devise integration (optional)
gem 'spree_gateway', '~> 3.9' # payment gateways eg. Stripe, Braintree (optional)
gem 'spree_i18n', '~> 5.0' # translation files (optional)
# only needed for MacOS and Ruby 3.0
gem 'sassc', github: 'sass/sassc-ruby', branch: 'master'
bin/rails g spree:install --user_class=Spree::User
bin/rails g spree:auth:install
bin/rails g spree_gateway:install
bin/rails g spree:backend:install
By default, the installation generator (
rails g spree:install) will run migrations as well as adding seed. This can be disabled using
bin/rails g spree:install --migrate=false --sample=false --seed=false
You can always perform any of these steps later by using these commands.
rails g spree:installis run inside an application, it will install Spree, mounting the
Spree::Core::Enginecomponent by inserting this line automatically into
mount Spree::Core::Engine, at: '/'
By default, all Spree routes will be available at the root of your domain. For example, if your domain is
/productsURL will be available at
You can customize this simply by changing the
config/routes.rbto be something else. For example, if you would like Spree to be mounted at
/shop, you can write this:
mount Spree::Core::Engine, at: `/shop`
The different parts of Spree (API, Admin) will be mounted there as well, eg.
Spree Auth Devise is the default authentication that comes with Spree but you can swap it for your own, please follow this guide
You now have a functional Spree application after running only a few commands!
To stop the webserver, hit Ctrl-C in the terminal window where it's running. In development mode, Spree does not generally require you to stop the server; changes you make in files will be automatically picked up by the server.
The next thing you'll probably want to do is to log into the admin interface. Use your browser window to navigate to http://localhost:4000/admin. You can log in with the username
[email protected]and password
Upon successful authentication, you should see the admin screen:
Feel free to explore some of the Admin Panel features that Spree has to offer and to verify that your installation is working properly.