Class: Admin::BroadcastMessagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/broadcast_messages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


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

def create
  @broadcast_message = BroadcastMessage.new(broadcast_message_params)

  if @broadcast_message.save
    redirect_to admin_broadcast_messages_path, notice: 'Broadcast Message was successfully created.'
  else
    render :index
  end
end

#destroyObject


30
31
32
33
34
35
36
37
# File 'app/controllers/admin/broadcast_messages_controller.rb', line 30

def destroy
  @broadcast_message.destroy

  respond_to do |format|
    format.html { redirect_back_or_default(default: { action: 'index' }) }
    format.js { render nothing: true }
  end
end

#editObject


9
10
# File 'app/controllers/admin/broadcast_messages_controller.rb', line 9

def edit
end

#indexObject


4
5
6
7
# File 'app/controllers/admin/broadcast_messages_controller.rb', line 4

def index
  @broadcast_messages = BroadcastMessage.reorder("ends_at DESC").page(params[:page])
  @broadcast_message  = BroadcastMessage.new
end

#previewObject


39
40
41
# File 'app/controllers/admin/broadcast_messages_controller.rb', line 39

def preview
  @message = broadcast_message_params[:message]
end

#updateObject


22
23
24
25
26
27
28
# File 'app/controllers/admin/broadcast_messages_controller.rb', line 22

def update
  if @broadcast_message.update(broadcast_message_params)
    redirect_to admin_broadcast_messages_path, notice: 'Broadcast Message was successfully updated.'
  else
    render :edit
  end
end