Class: Spree::Admin::SuppliersController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/spree/admin/suppliers_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject



25
26
27
28
29
30
31
# File 'app/controllers/spree/admin/suppliers_controller.rb', line 25

def edit
  @object.address = Spree::Address.build_default unless @object.address.present?
  respond_with(@object) do |format|
    format.html { render :layout => !request.xhr? }
    format.js   { render :layout => false }
  end
end

#newObject



33
34
35
# File 'app/controllers/spree/admin/suppliers_controller.rb', line 33

def new
  @object.address = Spree::Address.build_default
end

#updateObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/spree/admin/suppliers_controller.rb', line 3

def update
  @object.address = Spree::Address.immutable_merge(@object.address, permitted_resource_params[:address_attributes])

  if @object.update_attributes(permitted_resource_params.except(:address_attributes))
    respond_with(@object) do |format|
      format.html do
        flash[:success] = flash_message_for(@object, :successfully_updated)
        redirect_to location_after_save
      end
      format.js { render layout: false }
    end
  else
    respond_with(@object) do |format|
      format.html do
        flash.now[:error] = @object.errors.full_messages.join(", ")
        render_after_update_error
      end
      format.js { render layout: false }
    end
  end
end