Class: Admin::LocationsController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/c/admin/locations_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
# File 'app/controllers/c/admin/locations_controller.rb', line 13

def create
  @location = C::Location.new(location_params)
  if @location.save
    redirect_to locations_path, notice: 'Location created'
  else
    render :new
  end
end

#destroyObject



33
34
35
36
37
38
39
# File 'app/controllers/c/admin/locations_controller.rb', line 33

def destroy
  @location.destroy
  respond_to do |format|
    format.js
    format.html { redirect_to locations_path }
  end
end

#indexObject



9
10
11
# File 'app/controllers/c/admin/locations_controller.rb', line 9

def index
  @locations = filter_and_paginate(@locations, 'created_at desc')
end

#sortObject



41
42
43
44
45
46
47
# File 'app/controllers/c/admin/locations_controller.rb', line 41

def sort
  @locations = C::Location.all
  @locations.update_order(params[:location])
  respond_to do |format|
    format.js { head :ok, content_type: 'text/html' }
  end
end

#updateObject



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

def update
  if params[:commit] == 'upload'
    @location.assign_attributes(new_image_params)
    render :edit
  elsif @location.update(location_params)
    redirect_to locations_path, notice: 'Location updated'
  else
    render :edit
  end
end