Class: Spree::Admin::ExactorSettingsController

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

Overview

Exactor settings controller

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @setting = Spree::ExactorSetting.new(params[:exactor_setting])
  @setting.country =Spree::Country.find(@setting.country_id)
  @setting.save
  if (@setting.errors.empty?)
    flash.notice = flash_message_for(@setting, :exactor_settings_created)
  end
  render :action => "show"
end

#showObject



4
5
6
7
8
9
10
11
12
# File 'app/controllers/spree/admin/exactor_settings_controller.rb', line 4

def show
  @setting = Spree::ExactorSetting.get_settings()
  if @setting.nil?
    ship_from_country =  Spree::Country.find(Spree::Config[:default_country_id]) rescue Spree::Country.first
    @setting = Spree::ExactorSetting.new({:country => ship_from_country}, :without_protection => true)
    @setting.country_id = ship_from_country.id;
  end
  respond_with(@setting)
end

#updateObject



14
15
16
17
18
19
20
21
# File 'app/controllers/spree/admin/exactor_settings_controller.rb', line 14

def update
  @setting = Spree::ExactorSetting.find(params[:id])
  @setting.update_attributes(params[:exactor_setting])
  if (@setting.errors.empty?)
    flash.notice = flash_message_for(@setting, :exactor_settings_updated)
  end
  render :action => "show"
end