Class: Virgo::Admin::CategoriesController
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
|
# File 'app/controllers/virgo/admin/categories_controller.rb', line 27
def create
@category = Category.new(category_params.merge(created_by: current_user))
respond_to do |fmt|
if @category.save
fmt.json {
@post = Post.find_by(id: post_id_param)
@post.categories << @category unless (@post.nil? || @post.categories.include?(@category))
render json: {
status: :success,
html: render_content('success_modal', layout: false),
categories_form_partial: render_content(partial: '/virgo/admin/posts/categories_form')}
}
fmt.html {
flash[:notice] = "Category added successfully"
redirect_to admin_categories_path
}
else
fmt.json {
render json: {status: :err, html: render_content('modal_form', layout: false)}
}
fmt.html {
render 'new'
}
end
end
end
|
#destroy ⇒ Object
68
69
70
71
72
73
74
|
# File 'app/controllers/virgo/admin/categories_controller.rb', line 68
def destroy
@category.destroy
flash[:notice] = "Category deleted"
redirect_to admin_categories_path
end
|
#edit ⇒ Object
56
57
|
# File 'app/controllers/virgo/admin/categories_controller.rb', line 56
def edit
end
|
#index ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'app/controllers/virgo/admin/categories_controller.rb', line 8
def index
if sort_param.nil?
flash.keep
redirect_to admin_categories_path(sort: 'navbar_weight') and return
end
@categories = Category.visible.order(sort_order).with_post_count.page(page_param)
end
|
21
22
23
24
25
|
# File 'app/controllers/virgo/admin/categories_controller.rb', line 21
def modal_form
@category = Category.new
render json: {status: :success, html: render_content('modal_form', layout: false)}
end
|
#new ⇒ Object
17
18
19
|
# File 'app/controllers/virgo/admin/categories_controller.rb', line 17
def new
@category = Category.new
end
|
#update ⇒ Object
59
60
61
62
63
64
65
66
|
# File 'app/controllers/virgo/admin/categories_controller.rb', line 59
def update
if @category.update(category_params)
flash[:notice] = "Category updated successfully"
redirect_to admin_categories_path
else
render 'edit'
end
end
|