Class: NewsCategoriesController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/news_categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

post /news_categories



7
8
9
10
11
12
13
14
# File 'app/controllers/news_categories_controller.rb', line 7

def create
  @entity = NewsCategory.new entity_parameters
  if @entity.save
    redirect_to admin_news_category_path(id: @entity.id)
  else
    render :new, status: :bad_request
  end
end

#destroyObject

delete /news_categories/:id



30
31
32
33
34
35
# File 'app/controllers/news_categories_controller.rb', line 30

def destroy
  if @entity.update deleted: true
    flash[:notice] = t('news_categories.destroy.success')
  end
  redirect_to admin_news_categories_path
end

#editObject

get /news_categories/:id/edit



17
18
# File 'app/controllers/news_categories_controller.rb', line 17

def edit
end

#updateObject

patch /news_categories/:id



21
22
23
24
25
26
27
# File 'app/controllers/news_categories_controller.rb', line 21

def update
  if @entity.update entity_parameters
    redirect_to admin_news_category_path(id: @entity.id), notice: t('news_categories.update.success')
  else
    render :edit, status: :bad_request
  end
end