Class: Elabs::Admin::TagsController

Inherits:
AdminApplicationController show all
Defined in:
app/controllers/elabs/admin/tags_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

#destroyObject

DELETE /tags/1 DELETE /tags/1.json



35
36
37
38
39
40
41
# File 'app/controllers/elabs/admin/tags_controller.rb', line 35

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

#editObject

GET /tags/1/edit



17
# File 'app/controllers/elabs/admin/tags_controller.rb', line 17

def edit; end

#indexObject

GET /tags GET /tags.json



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

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

#updateObject

PATCH/PUT /tags/1 PATCH/PUT /tags/1.json



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

def update
  respond_to do |format|
    if @tag.update(tag_params)
      format.html { redirect_to admin_tags_url, notice: _('Tag was successfully updated.') }
      format.json { render :_tag, status: :ok, location: admin_tags_url, locals: { tag: @tag } }
    else
      format.html { render :edit, tag: @tag }
      format.json { render json: @tag.errors, status: :unprocessable_entity }
    end
  end
end