Class: System::Admin::Instance::AnnouncementsController

Inherits:
Controller
  • Object
show all
Defined in:
app/controllers/system/admin/instance/announcements_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


14
15
16
17
18
19
20
21
# File 'app/controllers/system/admin/instance/announcements_controller.rb', line 14

def create
  if @announcement.save
    redirect_to admin_instance_announcements_path,
                success: t('.success', title: @announcement.title)
  else
    render 'new'
  end
end

#destroyObject


35
36
37
38
39
40
41
42
43
# File 'app/controllers/system/admin/instance/announcements_controller.rb', line 35

def destroy
  if @announcement.destroy
    redirect_to admin_instance_announcements_path,
                success: t('.success', title: @announcement.title)
  else
    redirect_to admin_instance_announcements_path,
                danger: t('.failure', error: @announcement.errors.full_messages.to_sentence)
  end
end

#editObject


23
24
# File 'app/controllers/system/admin/instance/announcements_controller.rb', line 23

def edit
end

#indexObject


7
8
9
# File 'app/controllers/system/admin/instance/announcements_controller.rb', line 7

def index
  @announcements = @announcements.includes(:creator).page(page_param)
end

#newObject


11
12
# File 'app/controllers/system/admin/instance/announcements_controller.rb', line 11

def new
end

#updateObject


26
27
28
29
30
31
32
33
# File 'app/controllers/system/admin/instance/announcements_controller.rb', line 26

def update
  if @announcement.update_attributes(announcement_params)
    redirect_to admin_instance_announcements_path,
                success: t('.success', title: @announcement.title)
  else
    render 'edit'
  end
end