Class: Backend::TagboxController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/backend/tagbox_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#breadcrumb, #current_admin, #default_app_locale, #translate_notice

Methods included from Udongo::Cryptography

#crypt

Instance Method Details

#createObject



10
11
12
13
# File 'app/controllers/backend/tagbox_controller.rb', line 10

def create
  create_tag if tag_creatable?
  render json: { tag: params[:tag], valid: item_tagged?(find_tag) }
end

#destroyObject



15
16
17
18
19
# File 'app/controllers/backend/tagbox_controller.rb', line 15

def destroy
  tag = find_tag
  find_model.tagged_items.where(tag_id: tag.id).destroy_all if tag.present?
  render json: { success: true }
end

#indexObject



2
3
4
5
6
7
8
# File 'app/controllers/backend/tagbox_controller.rb', line 2

def index
  tags = Tag.by_locale(params[:locale]).order(:name).pluck(:name).map do |name|
    { label: name, value: name }
  end

  render json: tags
end