Class: Iro::AlertsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/iro/alerts_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#home, #schwab_sync

Instance Method Details

#createObject



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

def create
  @alert = Iro::Alert.new params[:alert].permit!
  authorize! :create, @alert
  if @alert.save
    redirect_to action: :index, notice: 'Alert was successfully created.'
  else
    render :new
  end
end

#destroyObject



16
17
18
19
20
21
# File 'app/controllers/iro/alerts_controller.rb', line 16

def destroy
  @alert = Iro::Alert.find(params[:id])
  authorize! :destroy, @alert
  @alert.destroy
  redirect_to action: :index, notice: 'Alert was successfully destroyed.'
end

#indexObject



23
24
25
26
# File 'app/controllers/iro/alerts_controller.rb', line 23

def index
  @alerts = Iro::Alert.all
  authorize! :index, Iro::Alert
end

#updateObject



28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/iro/alerts_controller.rb', line 28

def update
  @alert = Iro::Alert.find(params[:id])
  authorize! :update, @alert
  if @alert.update params[:alert].permit!
    flash_notice 'ok'
  else
    flash_alert @alert
  end
  redirect_to action: :index, notice: 'Alert was successfully updated.'
end