@spree/docs 0.1.106 → 0.1.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/developer/core-concepts/architecture.md +1 -1
- package/dist/developer/core-concepts/markets.md +0 -1
- package/dist/developer/core-concepts/staff-roles.md +0 -1
- package/dist/developer/core-concepts/stores.md +2 -4
- package/dist/developer/core-concepts/translations.md +0 -1
- package/dist/developer/multi-tenant/core-concepts.md +1 -1
- package/dist/developer/multi-tenant/quickstart.md +109 -11
- package/dist/developer/upgrades/4.2-to-4.3.md +1 -1
- package/dist/developer/upgrades/5.3-to-5.4.md +0 -14
- package/dist/developer/upgrades/5.4-to-5.5.md +1 -1
- package/package.json +1 -1
- package/dist/developer/multi-store/quickstart.md +0 -78
- package/dist/developer/multi-store/setup.md +0 -38
- package/dist/developer/multi-tenant/installation.md +0 -118
|
@@ -119,7 +119,7 @@ Events from both APIs can trigger [Webhooks](webhooks.md) to notify external sys
|
|
|
119
119
|
|
|
120
120
|
## Multi-Store Architecture
|
|
121
121
|
|
|
122
|
-
Spree supports [multiple
|
|
122
|
+
Spree supports running [multiple storefronts](../multi-tenant/quickstart.md) from a single installation. Each Store can have:
|
|
123
123
|
|
|
124
124
|
- Its own domain and branding
|
|
125
125
|
- Different currencies and locales
|
|
@@ -290,7 +290,6 @@ spree api delete /markets/market_xxx
|
|
|
290
290
|
## Related Documentation
|
|
291
291
|
|
|
292
292
|
- [Markets (Store SDK)](../sdk/store/markets.md) — Listing, resolving, and reading markets from the Store SDK
|
|
293
|
-
- [Stores](stores.md) — Multi-store setup and configuration
|
|
294
293
|
- [Pricing](pricing.md) — Price Lists, Price Rules, and the Pricing Context
|
|
295
294
|
- [Addresses](addresses.md) — Countries, States, and Zones
|
|
296
295
|
- [Localization](../../api-reference/store-api/localization.md) — Locale, currency, and country headers in API requests
|
|
@@ -168,6 +168,5 @@ See the [Customize Permissions guide](../customization/permissions.md) for detai
|
|
|
168
168
|
- [Custom API Authentication](../how-to/custom-api-authentication.md) — implement a custom identity-provider strategy (the full guide)
|
|
169
169
|
- [Admin API Authentication](../../api-reference/admin-api/authentication.md) — keys, JWTs, scopes, and the refresh-cookie flow
|
|
170
170
|
- [Customers](customers.md) — Customer accounts and authentication
|
|
171
|
-
- [Stores](stores.md) — Multi-store setup
|
|
172
171
|
- [Permissions](../customization/permissions.md) — Roles and authorization
|
|
173
172
|
- [Events](events.md) — Subscribe to invitation events
|
|
@@ -73,12 +73,10 @@ Each store owns its own resources. Products, orders, channels, markets, and taxo
|
|
|
73
73
|
|
|
74
74
|
## Running Multiple Storefronts
|
|
75
75
|
|
|
76
|
-
If you need one Spree backend to serve **multiple distinct merchant brands** — different domains, different catalogs
|
|
76
|
+
If you need one Spree backend to serve **multiple distinct merchant brands** — different domains, different catalogs — there are two patterns:
|
|
77
77
|
|
|
78
78
|
- **Multiple channels under one store** (recommended for most cases) — model each storefront as a Sales Channel. Products are scoped per-channel via publications, orders carry the channel that originated them, and routing/pricing can differ per channel. This is the supported pattern in core Spree 5.5+.
|
|
79
|
-
- **Multiple stores in one app** —
|
|
80
|
-
|
|
81
|
-
For most multi-brand operations, the channel pattern is simpler and more flexible. Reach for [spree_multi_store](../multi-store/quickstart.md) only when stores need genuinely independent catalogs, branding, and admin teams.
|
|
79
|
+
- **Multiple isolated stores (tenants) in one app** — full data isolation, only recommended if you're building a SaaS platform or a multi-tenant application. Each store can have different staff members, payment methods, shipping methods, and branding. This is supported by the [Spree Multi Tenant](../multi-tenant/quickstart.md) extension, which is a separate gem from core Spree.
|
|
82
80
|
|
|
83
81
|
## Related Documentation
|
|
84
82
|
|
|
@@ -131,5 +131,4 @@ Once installed, all translation files are available automatically — no need to
|
|
|
131
131
|
- [Markets](markets.md) — Locale and currency configuration per geographic region
|
|
132
132
|
- [Localization](../../api-reference/store-api/localization.md) — Locale, currency, and country headers in API requests
|
|
133
133
|
- [Slugs](slugs.md) — Localized slugs and URL identifiers
|
|
134
|
-
- [Stores](stores.md) — Multi-store setup
|
|
135
134
|
- [Products](products.md) — Product translations
|
|
@@ -32,7 +32,7 @@ bin/rails g model Spree::NewModel tenant:references name:string --parent SpreeMu
|
|
|
32
32
|
|
|
33
33
|
## Tenant selector
|
|
34
34
|
|
|
35
|
-
By default the current tenant is selected based on the subdomain or `Spree::CustomDomain`.
|
|
35
|
+
By default the current tenant is selected based on the subdomain or `Spree::CustomDomain`.
|
|
36
36
|
|
|
37
37
|
First it finds the current store, and later sets the current tenant based on the store's `tenant_id`.
|
|
38
38
|
|
|
@@ -1,20 +1,118 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
sidebarTitle:
|
|
2
|
+
title: Spree Multi Tenant Installation
|
|
3
|
+
sidebarTitle: Installation
|
|
4
|
+
description: Install and configure Spree Multi-Tenant to run a SaaS ecommerce platform, including prerequisites, gem setup, license keys, and tenant provisioning.
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
> **WARNING:** This installation instructions assume you have a clean Spree Starter installation and you've purchased the [Spree Enterprise Edition license](https://spreecommerce.org/pricing).
|
|
8
|
+
>
|
|
9
|
+
> For migrating existing application from single-tenant to multi-tenant, please contact us at [support@spreecommerce.org](mailto:support@spreecommerce.org).
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## Prerequisites
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
* You need to be on Spree 5.1+, we recommend using [spree_starter](https://github.com/spree/spree_starter) as a base for your application
|
|
14
|
+
* You need to have 2 environment variables set:
|
|
15
|
+
* `KEYGEN_ACCOUNT_ID`
|
|
16
|
+
* `KEYGEN_LICENSE_KEY`
|
|
17
|
+
* We support both PostgreSQL and MySQL databases
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
> **INFO:** Environment variables will be provided to you after purchasing the [Spree Enterprise Edition license](https://spreecommerce.org/pricing).
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
* Multi-Tenant allows you to create a SaaS application with multiple tenants, each of them with their own Spree instance
|
|
21
|
+
> **WARNING:** You will need to add these environment variables to your CI/CD pipeline and production environments.
|
|
17
22
|
|
|
18
|
-
##
|
|
23
|
+
## Customer User Class
|
|
19
24
|
|
|
20
|
-
|
|
25
|
+
Please follow [Authentication](../customization/authentication.md) documentation to create a new user class.
|
|
26
|
+
|
|
27
|
+
Now we will need to make slight adjustments to the generated user class so it can work in a multi-tenant environment.
|
|
28
|
+
|
|
29
|
+
If you're using Devise, you will need to remove `:validatable` module. This module is responsible for validating the user's email uniqueness. We need to change it to validate it in the scope of the tenant.
|
|
30
|
+
|
|
31
|
+
Spree Multi-Tenant gem injects `SpreeMultiTenant::CustomerUserConcern` that handles that instead.
|
|
32
|
+
|
|
33
|
+
## Admin User Class
|
|
34
|
+
|
|
35
|
+
For our multi-tenant setup we will need a separate Admin user class. Our standard User class will be only used for customer accounts which will be isolated by tenant.
|
|
36
|
+
Admin user classes will be shared across tenants allowing them to manage multiple tenants from a single admin panel.
|
|
37
|
+
|
|
38
|
+
Let's create a new model with Devise (unless you already have one):
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
```bash Spree CLI (Docker)
|
|
42
|
+
spree rails g devise Spree::AdminUser
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```bash Without Spree CLI
|
|
46
|
+
bin/rails g devise Spree::AdminUser
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Replace the generated Devise code with the following:
|
|
51
|
+
|
|
52
|
+
```ruby
|
|
53
|
+
class Spree::AdminUser < Spree::Base
|
|
54
|
+
# Include default devise modules. Others available are:
|
|
55
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
|
56
|
+
devise :database_authenticatable, :registerable,
|
|
57
|
+
:recoverable, :rememberable, :validatable
|
|
58
|
+
|
|
59
|
+
# Spree modules
|
|
60
|
+
include Spree::UserMethods
|
|
61
|
+
end
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If you already have a custom Admin user class, you can add the following code to it:
|
|
65
|
+
|
|
66
|
+
```ruby
|
|
67
|
+
# Spree modules
|
|
68
|
+
include Spree::UserMethods
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
This will make sure that the Admin user class works well with Spree ecosystem.
|
|
72
|
+
|
|
73
|
+
Register new model in `config/initializers/spree.rb`:
|
|
74
|
+
|
|
75
|
+
```ruby
|
|
76
|
+
Spree.admin_user_class = "Spree::AdminUser"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Installing gems
|
|
80
|
+
|
|
81
|
+
1. Add the following code to your `Gemfile`:
|
|
82
|
+
|
|
83
|
+
```ruby
|
|
84
|
+
source "https://license:#{ENV['KEYGEN_LICENSE_KEY']}@rubygems.pkg.keygen.sh/#{ENV['KEYGEN_ACCOUNT_ID']}" do
|
|
85
|
+
gem 'spree_enterprise'
|
|
86
|
+
gem 'spree_multi_tenant'
|
|
87
|
+
end
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
2. Install gems:
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
```bash Spree CLI (Docker)
|
|
95
|
+
spree bundle install
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```bash Without Spree CLI
|
|
99
|
+
bundle install
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
3. Run generators:
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
```bash Spree CLI (Docker)
|
|
109
|
+
spree generate spree_enterprise:install && spree generate spree_multi_tenant:install
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
```bash Without Spree CLI
|
|
113
|
+
bin/rails g spree_enterprise:install && bin/rails g spree_multi_tenant:install
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
> **INFO:** This will copy and run migrations for `spree_enterprise` and `spree_multi_tenant` gems.
|
|
@@ -28,7 +28,7 @@ These gems were merged into Spree Core in version 4.3. All of their functionalit
|
|
|
28
28
|
|
|
29
29
|
### Optional Remove SpreeMultiDomain
|
|
30
30
|
|
|
31
|
-
If you used that gem in the past you need to remove it.
|
|
31
|
+
If you used that gem in the past you need to remove it.
|
|
32
32
|
|
|
33
33
|
1. Remove `spree_multi_domain` from your `Gemfile`
|
|
34
34
|
|
|
@@ -252,20 +252,6 @@ Also, add `jsonapi-rspec` gem to your `Gemfile`:
|
|
|
252
252
|
|
|
253
253
|
And run `bundle install`
|
|
254
254
|
|
|
255
|
-
### (Optional) Install Spree Multi Store
|
|
256
|
-
|
|
257
|
-
[Multi-store](../multi-store/quickstart.md) features like multiple store management & custom domains were moved to a separate gem [spree_multi_store](../multi-store/quickstart.md).
|
|
258
|
-
|
|
259
|
-
If you rely on these features please run:
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
bundle add spree_multi_store
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
> **INFO:** Spree Multi-Store is licensed under the [AGPL v3 License](https://opensource.org/licenses/AGPL-3.0).
|
|
266
|
-
>
|
|
267
|
-
> If you would like to use it in a commercial application, please [contact us](https://spreecommerce.org/get-started/) to obtain a commercial license.
|
|
268
|
-
|
|
269
255
|
### (Optional) Install Legacy Product Properties extension
|
|
270
256
|
|
|
271
257
|
Product Properties have been extracted from Spree core to a separate gem `spree_legacy_product_properties`. Product Properties were already deprecated in favor of [Metafields](../core-concepts/metafields.md) and disabled by default since Spree 5.1.
|
|
@@ -122,7 +122,7 @@ This is a no-op on the default Database provider (there is no external index to
|
|
|
122
122
|
|
|
123
123
|
#### Multi-store catalogs
|
|
124
124
|
|
|
125
|
-
If you have products attached to multiple stores via the legacy `spree_products_stores` join, the `populate_publications` task picks **one** "home" store per product and creates publications on every store's default channel. The `spree_products_stores` table is **kept** as legacy compat surface
|
|
125
|
+
If you have products attached to multiple stores via the legacy `spree_products_stores` join, the `populate_publications` task picks **one** "home" store per product and creates publications on every store's default channel. The `spree_products_stores` table is **kept** as legacy compat surface.
|
|
126
126
|
|
|
127
127
|
For single-store deployments this is invisible; you can move on without touching `spree_products_stores` again.
|
|
128
128
|
|
package/package.json
CHANGED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Multi-Store Spree Commerce Quickstart
|
|
3
|
-
sidebarTitle: Quickstart
|
|
4
|
-
description: Enable multiple storefronts on a single Spree app with the spree_multi_store gem, including per-store products, payment methods, taxonomies, and promotions.
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
To enable multiple stores, you will need to add the [spree_multi_store](quickstart.md) gem to your project via:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
```bash Spree CLI (Docker)
|
|
11
|
-
spree bundle add spree_multi_store
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
```bash Without Spree CLI
|
|
15
|
-
bundle add spree_multi_store
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
> **INFO:** Spree Multi-Store is licensed under the [AGPL v3 License](https://opensource.org/licenses/AGPL-3.0).
|
|
20
|
-
>
|
|
21
|
-
> If you would like to use it in a commercial application, please [contact us](https://spreecommerce.org/get-started/) to obtain a commercial license.
|
|
22
|
-
|
|
23
|
-

|
|
24
|
-
|
|
25
|
-
## Store resources
|
|
26
|
-
|
|
27
|
-
Each Store can have its own resources. For example, a Store can have its own Products, Taxonomies, Promotions, etc.
|
|
28
|
-
|
|
29
|
-
| Resource | Relationship |
|
|
30
|
-
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
31
|
-
| [**Order**](/core-concepts/orders) | One Order belongs to one Store |
|
|
32
|
-
| [**Product**](/core-concepts/products) | One Product can be associated with many Store(s), you can pick and choose in which Store(s) each Product will be available |
|
|
33
|
-
| [**Payment Method**](/core-concepts/payments) | One Payment Method can be associated with many Store(s), you can select in which Stores given Payment Method will be available on Checkout |
|
|
34
|
-
| [**Taxonomy**](/core-concepts/products#taxons-and-taxonomies) | One Taxonomy belongs to one Store |
|
|
35
|
-
| [**Promotion**](/core-concepts/promotions) | One Promotion can be associated with multiple Stores |
|
|
36
|
-
| **Store Credit** | One Store Credit belongs to and can be used in one Store
|
|
37
|
-
|
|
38
|
-
## Current Store
|
|
39
|
-
|
|
40
|
-
Spree will try to determine the current store based on the current URL. If the URL does not match any of the stores in the database, Spree will fall back to the default store.
|
|
41
|
-
|
|
42
|
-
All Spree controllers or any other controllers that include [Spree::Core::ControllerHelpers::Store](https://github.com/spree/spree/blob/main/core/lib/spree/core/controller_helpers/store.rb) have access to the `current_store` method which returns the `Store` matching the current URL.
|
|
43
|
-
|
|
44
|
-
All parts of Spree (API, Admin Panel) have this implemented.
|
|
45
|
-
|
|
46
|
-
> **INFO:** Under the hood `current_store` calls [Spree::Stores::FindCurrent.new(url: url).execute](https://github.com/spree/spree/blob/main/core/app/finders/spree/stores/find_current.rb).
|
|
47
|
-
>
|
|
48
|
-
> This logic can be easily overwritten by setting
|
|
49
|
-
>
|
|
50
|
-
> ```ruby
|
|
51
|
-
Spree::Dependencies.current_store_finder = 'MyStoreFinderClass'
|
|
52
|
-
```
|
|
53
|
-
>
|
|
54
|
-
> in `config/initializers/spree.rb` file
|
|
55
|
-
|
|
56
|
-
## Default Store
|
|
57
|
-
|
|
58
|
-
If the system cannot find any Store that matches the current URL it will fall back to the Default Store.
|
|
59
|
-
|
|
60
|
-
You can set the default Store via Rails console:
|
|
61
|
-
|
|
62
|
-
```ruby
|
|
63
|
-
Spree::Store.find(2).update(default: true)
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
To get the default store in your code or rails console type:
|
|
67
|
-
|
|
68
|
-
```ruby
|
|
69
|
-
Spree::Store.default
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Custom Domains
|
|
73
|
-
|
|
74
|
-
Spree supports managing custom domains for Stores. In the Admin Panel, you can manage custom domains for each Store in the **Settings -> Domains** page.
|
|
75
|
-
|
|
76
|
-
## Setup multi-store application
|
|
77
|
-
|
|
78
|
-
[Follow the setup guide](setup.md) to get started.
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Multi-Store Setup
|
|
3
|
-
sidebarTitle: Setup
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
## Root domain
|
|
7
|
-
|
|
8
|
-
You need to set a wildcard `root_domain` on the store to enable multi-store setup
|
|
9
|
-
|
|
10
|
-
```ruby
|
|
11
|
-
Spree.root_domain = ENV.fetch('SPREE_ROOT_DOMAIN', 'lvh.me')
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
This will be used to generate the store URLs, eg. `store1.lvh.me`, `store2.lvh.me`, etc.
|
|
15
|
-
|
|
16
|
-
`store1` part is the unique store `code` identifier, which is auto-generated based on the store name. You can change it in the admin panel in **Settings -> Domains**.
|
|
17
|
-
|
|
18
|
-
> **INFO:** If you later change the `root_domain`, you will need to run:
|
|
19
|
-
>
|
|
20
|
-
> ```ruby
|
|
21
|
-
Spree::Store.all.each(&:save)
|
|
22
|
-
```
|
|
23
|
-
>
|
|
24
|
-
> to update the store URLs.
|
|
25
|
-
|
|
26
|
-
## Creating new stores
|
|
27
|
-
|
|
28
|
-
After you restart your application, you will see a new option in the admin panel, under new item menu:
|
|
29
|
-
|
|
30
|
-

|
|
31
|
-
|
|
32
|
-
You can also create a new store from the rails console:
|
|
33
|
-
|
|
34
|
-
```ruby
|
|
35
|
-
Spree::Store.create!(name: 'New Store')
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
This will create a new store with the given name, code and URL.
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Spree Multi Tenant Installation
|
|
3
|
-
sidebarTitle: Installation
|
|
4
|
-
description: Install and configure Spree Multi-Tenant to run a SaaS ecommerce platform, including prerequisites, gem setup, license keys, and tenant provisioning.
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
> **WARNING:** This installation instructions assume you have a clean Spree Starter installation and you've purchased the [Spree Enterprise Edition license](https://spreecommerce.org/pricing).
|
|
8
|
-
>
|
|
9
|
-
> For migrating existing application from single-tenant to multi-tenant, please contact us at [support@spreecommerce.org](mailto:support@spreecommerce.org).
|
|
10
|
-
|
|
11
|
-
## Prerequisites
|
|
12
|
-
|
|
13
|
-
* You need to be on Spree 5.1+, we recommend using [spree_starter](https://github.com/spree/spree_starter) as a base for your application
|
|
14
|
-
* You need to have 2 environment variables set:
|
|
15
|
-
* `KEYGEN_ACCOUNT_ID`
|
|
16
|
-
* `KEYGEN_LICENSE_KEY`
|
|
17
|
-
* We support both PostgreSQL and MySQL databases
|
|
18
|
-
|
|
19
|
-
> **INFO:** Environment variables will be provided to you after purchasing the [Spree Enterprise Edition license](https://spreecommerce.org/pricing).
|
|
20
|
-
|
|
21
|
-
> **WARNING:** You will need to add these environment variables to your CI/CD pipeline and production environments.
|
|
22
|
-
|
|
23
|
-
## Customer User Class
|
|
24
|
-
|
|
25
|
-
Please follow [Authentication](/docs/developer/customization/authentication) documentation to create a new user class.
|
|
26
|
-
|
|
27
|
-
Now we will need to make slight adjustments to the generated user class so it can work in a multi-tenant environment.
|
|
28
|
-
|
|
29
|
-
If you're using Devise, you will need to remove `:validatable` module. This module is responsible for validating the user's email uniqueness. We need to change it to validate it in the scope of the tenant.
|
|
30
|
-
|
|
31
|
-
Spree Multi-Tenant gem injects `SpreeMultiTenant::CustomerUserConcern` that handles that instead.
|
|
32
|
-
|
|
33
|
-
## Admin User Class
|
|
34
|
-
|
|
35
|
-
For our multi-tenant setup we will need a separate Admin user class. Our standard User class will be only used for customer accounts which will be isolated by tenant.
|
|
36
|
-
Admin user classes will be shared across tenants allowing them to manage multiple tenants from a single admin panel.
|
|
37
|
-
|
|
38
|
-
Let's create a new model with Devise (unless you already have one):
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```bash Spree CLI (Docker)
|
|
42
|
-
spree rails g devise Spree::AdminUser
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
```bash Without Spree CLI
|
|
46
|
-
bin/rails g devise Spree::AdminUser
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
Replace the generated Devise code with the following:
|
|
51
|
-
|
|
52
|
-
```ruby
|
|
53
|
-
class Spree::AdminUser < Spree::Base
|
|
54
|
-
# Include default devise modules. Others available are:
|
|
55
|
-
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
|
56
|
-
devise :database_authenticatable, :registerable,
|
|
57
|
-
:recoverable, :rememberable, :validatable
|
|
58
|
-
|
|
59
|
-
# Spree modules
|
|
60
|
-
include Spree::UserMethods
|
|
61
|
-
end
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
If you already have a custom Admin user class, you can add the following code to it:
|
|
65
|
-
|
|
66
|
-
```ruby
|
|
67
|
-
# Spree modules
|
|
68
|
-
include Spree::UserMethods
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
This will make sure that the Admin user class works well with Spree ecosystem.
|
|
72
|
-
|
|
73
|
-
Register new model in `config/initializers/spree.rb`:
|
|
74
|
-
|
|
75
|
-
```ruby
|
|
76
|
-
Spree.admin_user_class = "Spree::AdminUser"
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Installing gems
|
|
80
|
-
|
|
81
|
-
1. Add the following code to your `Gemfile`:
|
|
82
|
-
|
|
83
|
-
```ruby
|
|
84
|
-
source "https://license:#{ENV['KEYGEN_LICENSE_KEY']}@rubygems.pkg.keygen.sh/#{ENV['KEYGEN_ACCOUNT_ID']}" do
|
|
85
|
-
gem 'spree_enterprise'
|
|
86
|
-
gem 'spree_multi_tenant'
|
|
87
|
-
end
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
2. Install gems:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
```bash Spree CLI (Docker)
|
|
95
|
-
spree bundle install
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
```bash Without Spree CLI
|
|
99
|
-
bundle install
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
3. Run generators:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```bash Spree CLI (Docker)
|
|
109
|
-
spree generate spree_enterprise:install && spree generate spree_multi_tenant:install
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
```bash Without Spree CLI
|
|
113
|
-
bin/rails g spree_enterprise:install && bin/rails g spree_multi_tenant:install
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
> **INFO:** This will copy and run migrations for `spree_enterprise` and `spree_multi_tenant` gems.
|