Multiple stores using a single Spree application instance.
Uses request subdomain to swap database, view paths, Rails cache (preferences), mail settings, image paths and so much more.
-
Tweak
config/database.yml
to use Postgresql, and dummy master database. -
Add the following line to host
application.rb
config.middleware.use 'Apartment::Elevators::Subdomain'
- Create an initializer
config/apartment.rb
with the following:
Apartment.configure do |config|
config.prepend_environment = false
config.tenant_names = ['store1', 'store2']
end
- Bootstrap sample stores
bundle exec rake spree_shared:bootstrap['store1']
bundle exec rake spree_shared:bootstrap['store2']
- Setup local subdomains for sample stores, as spree_shared uses by default subdomain routing you need to confirm some local domains such as:
store1.spree.dev store2.spree.dev
This can be done using Pow or editing your local /etc/hosts file.
- Set namespace for cache engine in
development.rb
and/orproduction.rb
config.cache_store = :memory_store, { :namespace => lambda { ENV['RAILS_CACHE_ID'] } }
Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.
$ bundle exec rake test_app
$ bundle exec rspec spec
Copyright (c) 2011 [name of extension creator], released under the New BSD License