Class: Admin::CategoriesController
Instance Attribute Summary
#current_user
Instance Method Summary
collapse
#redirect, underscore
#policy, #verify_policy, #verify_policy_with_proc
inc_number_of_requests, original_title
#render_error
#authenticate!, #deauthenticate!, #logged_in?
Instance Method Details
#create ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/admin/categories_controller.rb', line 17
def create
@category = Category.create(category_params)
if @category.valid?
flash[:notice] = "New category created"
redirect_to admin_pages_url(@locale)
else
render action: :new
end
end
|
#destroy ⇒ Object
38
39
40
41
42
|
# File 'app/controllers/admin/categories_controller.rb', line 38
def destroy
@category.destroy
flash[:notice] = "Category was deleted"
redirect_to admin_pages_url(@locale)
end
|
#edit ⇒ Object
27
|
# File 'app/controllers/admin/categories_controller.rb', line 27
def edit; end
|
#index ⇒ Object
5
6
7
|
# File 'app/controllers/admin/categories_controller.rb', line 5
def index
@categories = Category.all
end
|
#new ⇒ Object
13
14
15
|
# File 'app/controllers/admin/categories_controller.rb', line 13
def new
@category = Category.new
end
|
#show ⇒ Object
9
10
11
|
# File 'app/controllers/admin/categories_controller.rb', line 9
def show
redirect_to edit_admin_category_url(@category)
end
|
#update ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'app/controllers/admin/categories_controller.rb', line 29
def update
if @category.update(category_params)
flash[:notice] = "Category was updated"
redirect_to admin_pages_url(@locale)
else
render action: :edit
end
end
|