Class: Virgo::Admin::TagsController
Instance Method Summary
collapse
#authorize_admin_user, #search, #set_is_admin_view
#sitemap
#render_content, #with_format
#action?, #admin?, #admin_access?, #admin_view?, #alerts, #base_errors, #category_id_param, #category_timestamp, #column_timestamp, #compact_html, #controller?, #decode_html_entities, #expanded_post_url, #is_admin_view?, #page_url, #post_time_format, #post_timestamp, #production?, #redis_timestamp_key_for, #site, #site_key, #superuser?, #tab_param, #tabbed_param, #word_count
Instance Method Details
#create ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'app/controllers/virgo/admin/tags_controller.rb', line 27
def create
@tag = Tag.new(tag_params.merge(created_by: current_user))
respond_to do |fmt|
if @tag.save
fmt.json {
@post = Post.find_by(id: post_id_param)
@post.tags << @tag unless (@post.nil? || @post.tags.include?(@tag))
flash.now[:success] = "Tag successfully added! If you would like to add more tags you can do so below. Otherwise, close this pop-up."
render json: {
status: :success,
tag: @tag,
html: render_content('modal_form', layout: false, locals: {tag: Tag.new})
}
}
fmt.html {
flash[:notice] = "Tag added successfully"
redirect_to admin_tags_path
}
else
fmt.json {
render json: {status: :err, html: render_content('modal_form', layout: false)}
}
fmt.html {
render 'new'
}
end
end
end
|
#destroy ⇒ Object
72
73
74
75
76
77
78
|
# File 'app/controllers/virgo/admin/tags_controller.rb', line 72
def destroy
@tag.destroy
flash[:notice] = "Tag deleted"
redirect_to admin_tags_path
end
|
#edit ⇒ Object
60
61
|
# File 'app/controllers/virgo/admin/tags_controller.rb', line 60
def edit
end
|
#index ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'app/controllers/virgo/admin/tags_controller.rb', line 8
def index
if sort_param.blank? && filter_params.all_blank?
flash.keep
redirect_to admin_tags_path(sort: 'name') and return
end
@tags = Tag.search(filter_params).with_post_count.order(sort_order).page(page_param)
end
|
21
22
23
24
25
|
# File 'app/controllers/virgo/admin/tags_controller.rb', line 21
def modal_form
@tag = Tag.new
render json: {status: :success, html: render_content('modal_form', layout: false)}
end
|
#new ⇒ Object
17
18
19
|
# File 'app/controllers/virgo/admin/tags_controller.rb', line 17
def new
@tag = Tag.new
end
|
#update ⇒ Object
63
64
65
66
67
68
69
70
|
# File 'app/controllers/virgo/admin/tags_controller.rb', line 63
def update
if @tag.update(tag_params)
flash[:notice] = "Tag updated successfully"
redirect_to admin_tags_path
else
render 'edit'
end
end
|