Class: Pressroom::CategoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/pressroom/categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
# File 'app/controllers/pressroom/categories_controller.rb', line 17

def create
  @category = Category.new(category_params)

  if @category.save
    redirect_to categories_path, notice: t("pressroom.categories.created")
  else
    render :new, status: 422
  end
end

#destroyObject



35
36
37
38
# File 'app/controllers/pressroom/categories_controller.rb', line 35

def destroy
  @category.destroy!
  redirect_to categories_path, notice: t("pressroom.categories.destroyed")
end

#editObject



15
# File 'app/controllers/pressroom/categories_controller.rb', line 15

def edit; end

#indexObject



7
8
9
# File 'app/controllers/pressroom/categories_controller.rb', line 7

def index
  @categories = pressroom_scoped(Category).order(:name)
end

#newObject



11
12
13
# File 'app/controllers/pressroom/categories_controller.rb', line 11

def new
  @category = Category.new
end

#updateObject



27
28
29
30
31
32
33
# File 'app/controllers/pressroom/categories_controller.rb', line 27

def update
  if @category.update(category_params)
    redirect_to categories_path, notice: t("pressroom.categories.updated")
  else
    render :edit, status: 422
  end
end