Class: Elabs::Admin::LicensesController

Inherits:
AdminApplicationController show all
Defined in:
app/controllers/elabs/admin/licenses_controller.rb

Constant Summary collapse

DEFAULT_ORDER_FIELD =
'name'.freeze

Constants inherited from AdminApplicationController

AdminApplicationController::MAX_ITEMS_PER_PAGE

Instance Method Summary collapse

Instance Method Details

#createObject

POST /licenses POST /licenses.json



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/elabs/admin/licenses_controller.rb', line 26

def create
  @license = License.new(license_params)

  respond_to do |format|
    if @license.save
      format.html { redirect_to admin_licenses_url, notice: _('License was successfully created.') }
      format.json { render '_license', status: :created, location: @license, locals: { license: @license } }
    else
      format.html { render :new }
      format.json { render json: @license.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /licenses/1 DELETE /licenses/1.json



56
57
58
59
60
61
62
# File 'app/controllers/elabs/admin/licenses_controller.rb', line 56

def destroy
  @license.destroy
  respond_to do |format|
    format.html { redirect_to admin_licenses_url, notice: _('License was successfully destroyed.') }
    format.json { head :no_content }
  end
end

#editObject

GET /licenses/1/edit



22
# File 'app/controllers/elabs/admin/licenses_controller.rb', line 22

def edit; end

#indexObject

GET /licenses GET /licenses.json



10
11
12
13
14
# File 'app/controllers/elabs/admin/licenses_controller.rb', line 10

def index
  order     = params['order_by'] || self.class::DEFAULT_ORDER_FIELD
  direction = params['direction'] || 'desc'
  @licenses = License.order(order => direction).all
end

#newObject

GET /licenses/new



17
18
19
# File 'app/controllers/elabs/admin/licenses_controller.rb', line 17

def new
  @license = License.new
end

#updateObject

PATCH/PUT /licenses/1 PATCH/PUT /licenses/1.json



42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/elabs/admin/licenses_controller.rb', line 42

def update
  respond_to do |format|
    if @license.update(license_params)
      format.html { redirect_to admin_licenses_url, notice: _('License was successfully updated.') }
      format.json { render '_license', status: :ok, location: @license, locals: { license: @license } }
    else
      format.html { render :edit }
      format.json { render json: @license.errors, status: :unprocessable_entity }
    end
  end
end