Class: Alchemy::Admin::TagsController
Constant Summary
ResourcesController::COMMON_SEARCH_FILTER_EXCLUDES
Instance Method Summary
collapse
#resource_filters, #resource_filters_for_select, #resource_handler, #resource_has_deprecated_filters, #resource_has_filters, #show
#contains_relations?, #edit_resource_path, #new_resource_path, #render_attribute, #resource_attribute_field_options, #resource_has_tags, #resource_instance_variable, #resource_model, #resource_name, #resource_path, #resource_relations_names, #resource_scope, #resource_url_proxy, #resource_window_size, #resources_instance_variable, #resources_path
#leave
Methods included from Modules
included, #module_definition_for, register_module
#current_ability
#configuration, #multi_language?, #multi_site?, #prefix_locale?
Instance Method Details
#autocomplete ⇒ Object
52
53
54
55
|
# File 'app/controllers/alchemy/admin/tags_controller.rb', line 52
def autocomplete
items = tags_from_term(params[:term])
render json: json_for_autocomplete(items, :name).to_json
end
|
#create ⇒ Object
22
23
24
25
|
# File 'app/controllers/alchemy/admin/tags_controller.rb', line 22
def create
@tag = Tag.create(tag_params)
render_errors_or_redirect @tag, admin_tags_path, Alchemy.t("New Tag Created")
end
|
#destroy ⇒ Object
44
45
46
47
48
49
50
|
# File 'app/controllers/alchemy/admin/tags_controller.rb', line 44
def destroy
if request.delete?
@tag.destroy
flash[:notice] = Alchemy.t(:successfully_deleted_tag)
end
do_redirect_to admin_tags_path
end
|
#edit ⇒ Object
27
28
29
|
# File 'app/controllers/alchemy/admin/tags_controller.rb', line 27
def edit
@tags = Tag.order("name ASC").to_a - [@tag]
end
|
#index ⇒ Object
8
9
10
11
12
13
14
15
16
|
# File 'app/controllers/alchemy/admin/tags_controller.rb', line 8
def index
@query = Tag.ransack(search_filter_params[:q])
@query.sorts = default_sort_order if @query.sorts.empty?
@tags = @query
.result
.page(params[:page] || 1)
.per(items_per_page)
.order("name ASC")
end
|
#new ⇒ Object
18
19
20
|
# File 'app/controllers/alchemy/admin/tags_controller.rb', line 18
def new
@tag = Tag.new
end
|
#update ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/alchemy/admin/tags_controller.rb', line 31
def update
if tag_params[:merge_to]
@new_tag = Tag.find(tag_params[:merge_to])
Tag.replace(@tag, @new_tag)
operation_text = Alchemy.t("Replaced Tag") % {old_tag: @tag.name, new_tag: @new_tag.name}
@tag.destroy
else
@tag.update(tag_params)
operation_text = Alchemy.t(:successfully_updated_tag)
end
render_errors_or_redirect @tag, admin_tags_path, operation_text
end
|