Class: Spree::Admin::MultiStore::StoresController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/multi_store/stores_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/spree/admin/multi_store/stores_controller.rb', line 10

def create
  @store = Spree::Store.new(permitted_store_params)
  @store.mail_from_address = current_store.mail_from_address

  if @store.save
    # Move/copy all existing users (staff) to the new store
    current_store.role_users.each do |role_user|
      @store.add_user(role_user.user, role_user.role)
    end

    flash[:success] = flash_message_for(@store, :successfully_created)
    redirect_to spree.admin_getting_started_url(host: @store.url), allow_other_host: true
  else
    render :new, status: :unprocessable_content, layout: 'spree/admin_wizard'
  end
end

#newObject



5
6
7
8
# File 'app/controllers/spree/admin/multi_store/stores_controller.rb', line 5

def new
  @store = Spree::Store.new(default_country_iso: 'US')
  render :new, layout: 'spree/admin_wizard'
end