Class: Admin::Packages::PackageGroupsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/packages/package_groups_controller.rb

Instance Method Summary collapse

Instance Method Details

#collectionsObject



44
45
46
47
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 44

def collections
  package_groups = [{ id: nil, name: '-' }] + HhPackage::PackageGroup.active
  render json: package_groups
end

#createObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 34

def create
  @package_group = HhPackage::PackageGroup.new package_group_params
  if @package_group.save
    redirect_to admin_packages_package_groups_path, notice: 'Add success'
  else
    flash[:error] = @package_group.errors.full_messages.to_sentence
    render 'edit'
  end
end

#destroyObject



25
26
27
28
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 25

def destroy
  @package_group.update active: 0
  redirect_to admin_packages_package_groups_path, notice: 'Data deleted'
end

#editObject



14
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 14

def edit; end

#indexObject



3
4
5
6
7
8
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 3

def index
  set_meta_tags title: 'Package Groups Overview'
  @grid = ::Admin::PackageGroupsGrid.new(params[:admin_packages_package_groups_grid]) do |scope|
    scope.page(params[:page]).per(50)
  end
end

#newObject



30
31
32
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 30

def new
  @package_group = HhPackage::PackageGroup.new
end

#showObject



10
11
12
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 10

def show
  @packages = define_package_group.packages
end

#updateObject



16
17
18
19
20
21
22
23
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 16

def update
  if @package_group.update package_group_params
    redirect_to admin_packages_package_groups_path, notice: 'Data updated'
  else
    flash[:error] = @package_group.errors.full_messages.to_sentence
    render 'edit'
  end
end