Class: Backend::TagsController

Inherits:
BaseController
  • Object
show all
Includes:
Concerns::PaginationController
Defined in:
app/controllers/backend/tags_controller.rb

Instance Method Summary collapse

Methods included from Concerns::PaginationController

#page_number, #paginate, #per_page

Methods inherited from BaseController

#breadcrumb, #current_admin, #default_app_locale, #translate_notice

Methods included from Udongo::Cryptography

#crypt

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/backend/tags_controller.rb', line 20

def create
  @tag = Tag.new(allowed_params)

  if @tag.save
    redirect_to backend_tags_path, notice: translate_notice(:added, :tag)
  else
    render :new
  end
end

#destroyObject



30
31
32
33
# File 'app/controllers/backend/tags_controller.rb', line 30

def destroy
  @tag.destroy
  redirect_to backend_tags_path, notice: translate_notice(:deleted, :tag)
end

#indexObject



7
8
9
10
# File 'app/controllers/backend/tags_controller.rb', line 7

def index
  @search = Tag.ransack params[:q]
  @tags = @search.result(distinct: true).order(:name).page(page_number).per_page(15)
end

#newObject



16
17
18
# File 'app/controllers/backend/tags_controller.rb', line 16

def new
  @tag = Tag.new
end

#showObject



12
13
14
# File 'app/controllers/backend/tags_controller.rb', line 12

def show
  redirect_to edit_backend_tag_path(@tag)
end

#updateObject



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

def update
  if @tag.update_attributes allowed_params
    redirect_to backend_tags_path, notice: translate_notice(:edited, :tag)
  else
    render :edit
  end
end