Class: Comable::Admin::StockLocationsController

Inherits:
ApplicationController show all
Includes:
PermittedAttributes
Defined in:
app/controllers/comable/admin/stock_locations_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_ability, #respond_to_export_with

Instance Method Details

#createObject



30
31
32
33
34
35
36
37
# File 'app/controllers/comable/admin/stock_locations_controller.rb', line 30

def create
  if @stock_location.save
    redirect_to comable.admin_stock_location_path(@stock_location), notice: Comable.t('successful')
  else
    flash.now[:alert] = Comable.t('failure')
    render :new
  end
end

#destroyObject



51
52
53
54
# File 'app/controllers/comable/admin/stock_locations_controller.rb', line 51

def destroy
  @stock_location.destroy
  redirect_to comable.admin_stock_locations_path, notice: Comable.t('successful')
end

#editObject



39
40
# File 'app/controllers/comable/admin/stock_locations_controller.rb', line 39

def edit
end

#indexObject



12
13
14
15
16
17
18
19
20
# File 'app/controllers/comable/admin/stock_locations_controller.rb', line 12

def index
  @q = Comable::StockLocation.ransack(params[:q])
  @stock_locations = @q.result.page(params[:page]).accessible_by(current_ability)

  respond_to do |format|
    format.html
    format.json { render json: @stock_locations }
  end
end

#newObject



26
27
28
# File 'app/controllers/comable/admin/stock_locations_controller.rb', line 26

def new
  @stock_location.build_address unless @stock_location.address
end

#showObject



22
23
24
# File 'app/controllers/comable/admin/stock_locations_controller.rb', line 22

def show
  render :edit
end

#updateObject



42
43
44
45
46
47
48
49
# File 'app/controllers/comable/admin/stock_locations_controller.rb', line 42

def update
  if @stock_location.update_attributes(stock_location_params)
    redirect_to comable.admin_stock_location_path(@stock_location), notice: Comable.t('successful')
  else
    flash.now[:alert] = Comable.t('failure')
    render :edit
  end
end