Class: IshManager::IroWatchesController
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_watches_controller.rb', line 6
def create
@option_watch = Iro::OptionWatch.new params[:iro_watch].permit!
authorize! :create, @option_watch
flag = @option_watch.save
if flag
flash[:notice] = 'Created option watch.'
else
flash[:alert] = "Cannot create option watch: #{@option_watch.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_watches_controller.rb', line 18
def destroy
@w = Iro::OptionWatch.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_watches_controller.rb', line 30
def index
authorize! :index, Iro::OptionWatch
@watches = Iro::OptionWatch.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_watches_controller.rb', line 36
def update
@option_watch = Iro::OptionWatch.find params[:id]
authorize! :update, @option_watch
flag = @option_watch.update_attributes params[:iro_watch].permit!
if flag
flash[:notice] = 'Updated option watch.'
else
flash[:alert] = "Cannot update option watch: #{@option_watch.errors.full_messages.join(', ')}."
end
redirect_to action: 'index'
end
|