Class: System::Admin::AnnouncementsController

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

Instance Method Summary collapse

Instance Method Details

#createObject


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

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

#destroyObject


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

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

#editObject


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

def edit
end

#indexObject


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

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

#newObject


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

def new
end

#updateObject


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

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