Class: IshManager::IroAlertsController
Instance Method Summary
collapse
#basic_auth, #home, #tinymce
Instance Method Details
#create ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
|
# File 'app/controllers/ish_manager/iro_alerts_controller.rb', line 6
def create
@alert = Iro::Alert.new params[:iro_alert].permit!
authorize! :create, @alert
flag = @alert.save
if flag
flash[:notice] = 'Created iro alert.'
else
flash[:alert] = "Cannot create iro alert: #{@alert.errors.full_messages.join(', ')}."
end
redirect_to action: 'index'
end
|
#destroy ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/ish_manager/iro_alerts_controller.rb', line 18
def destroy
@w = Iro::Alert.find params[:id]
authorize! :destroy, @w
flag = @w.destroy
if flag
flash[:notice] = 'Success.'
else
flash[:alert] = @w.errors.full_messages.join(", ")
end
redirect_to action: 'index'
end
|
#index ⇒ Object
30
31
32
33
34
|
# File 'app/controllers/ish_manager/iro_alerts_controller.rb', line 30
def index
authorize! :index, Iro::Alert
@alerts = Iro::Alert.order_by( ticker: :asc, direction: :asc, price: :desc)
@option_get_chains = Iro::OptionGet.all_get_chains
end
|
#update ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/ish_manager/iro_alerts_controller.rb', line 36
def update
@alert = Iro::Alert.find params[:id]
authorize! :update, @alert
flag = @alert.update_attributes params[:iro_alert].permit!
if flag
flash[:notice] = 'Updated iro alert.'
else
flash[:alert] = "Cannot update iro alert: #{@alert.errors.full_messages.join(', ')}."
end
redirect_to action: 'index'
end
|