Class: LesliBell::AnnouncementsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lesli_bell/announcements_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /announcements



39
40
41
42
43
44
45
46
47
# File 'app/controllers/lesli_bell/announcements_controller.rb', line 39

def create
  @announcement = Announcement.new(announcement_params)

  if @announcement.save
    redirect_to @announcement, notice: "Announcement was successfully created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject

DELETE /announcements/1



59
60
61
62
# File 'app/controllers/lesli_bell/announcements_controller.rb', line 59

def destroy
  @announcement.destroy
  redirect_to announcements_url, notice: "Announcement was successfully destroyed.", status: :see_other
end

#editObject

GET /announcements/1/edit



35
36
# File 'app/controllers/lesli_bell/announcements_controller.rb', line 35

def edit
end

#indexObject

GET /announcements



16
17
18
19
20
21
22
23
# File 'app/controllers/lesli_bell/announcements_controller.rb', line 16

def index
    respond_to do |format|
        format.html {  }
        format.json {
            respond_with_pagination(AnnouncementService.new(current_user, query).index)
        }
    end
end

#listObject

GET /announcements/list



6
7
8
9
10
11
12
13
# File 'app/controllers/lesli_bell/announcements_controller.rb', line 6

def list
    respond_to do |format|
        format.html {  }
        format.json {
            respond_with_pagination(AnnouncementService.new(current_user, query).list)
        }
    end
end

#newObject

GET /announcements/new



30
31
32
# File 'app/controllers/lesli_bell/announcements_controller.rb', line 30

def new
  @announcement = Announcement.new
end

#showObject

GET /announcements/1



26
27
# File 'app/controllers/lesli_bell/announcements_controller.rb', line 26

def show
end

#updateObject

PATCH/PUT /announcements/1



50
51
52
53
54
55
56
# File 'app/controllers/lesli_bell/announcements_controller.rb', line 50

def update
  if @announcement.update(announcement_params)
    redirect_to @announcement, notice: "Announcement was successfully updated.", status: :see_other
  else
    render :edit, status: :unprocessable_entity
  end
end