rails new store-backend
gem 'spree_backend', github: 'spree/spree'
gem 'devise'
rails g spree:install
rails g devise:install
rails g devise User
bundle exec rake db:migrate
has_and_belongs_to_many :spree_roles
def has_spree_role?(role)
self.spree_roles.all.include? role
end
- Generate custom user set up for spree
rails g spree:custom_user User
- Change Spree.user class to User on initializer spree.rb
Spree.user_class = "User"
- Add fields to custom user
bundle exec rake db:migrate
- Remove both all.css and all.js from vendor/assets/javascript|stylesheets/spree/frontend/
Rails.application.routes.draw do
root to: "spree/admin/orders#index"
mount Spree::Core::Engine, :at => '/'
devise_for :users do
get '/login', :to => "devise/sessions#new"
delete '/logout', :to => "devise/sessions#destroy"
end
end
# since we don't need signup on a backend install
def spree_signup_path
main_app.login_path
end
user = User.create(email: "[email protected]", password: "spree123")
user.spree_roles << Spree::Role.find_or_create_by(name: "admin")
Create this file in app/overrides/spree/layouts/admin/inject_login_bar.html.erb.deface
<!-- replace_contents "[data-hook='admin_login_navigation_bar']" -->
<ul id="login-nav" class="inline-menu">
<li><%= link_to('Edit', main_app.edit_user_registration_path) %></li>
<li><%= link_to('Logout', main_app.destroy_user_session_path, :method => :delete) %></li>
</ul>