Class: Backend::TagboxController
Instance Method Summary
collapse
#breadcrumb, #current_admin, #default_app_locale, #translate_notice
#crypt
Instance Method Details
#create ⇒ Object
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
|
#destroy ⇒ Object
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
|
#index ⇒ Object
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
|