Class: Admin::Packages::PackageGroupsController
- Inherits:
-
BaseController
- Object
- BaseController
- Admin::Packages::PackageGroupsController
- Defined in:
- app/controllers/admin/packages/package_groups_controller.rb
Instance Method Summary collapse
- #collections ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#collections ⇒ Object
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 |
#create ⇒ Object
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..to_sentence render 'edit' end end |
#destroy ⇒ Object
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 |
#edit ⇒ Object
14 |
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 14 def edit; end |
#index ⇒ Object
3 4 5 6 7 8 |
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 3 def index title: 'Package Groups Overview' @grid = ::Admin::PackageGroupsGrid.new(params[:admin_packages_package_groups_grid]) do |scope| scope.page(params[:page]).per(50) end end |
#new ⇒ Object
30 31 32 |
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 30 def new @package_group = HhPackage::PackageGroup.new end |
#show ⇒ Object
10 11 12 |
# File 'app/controllers/admin/packages/package_groups_controller.rb', line 10 def show @packages = define_package_group.packages end |
#update ⇒ Object
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..to_sentence render 'edit' end end |