Class: IshManager::IroWatchesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- IshManager::IroWatchesController
- Defined in:
- app/controllers/ish_manager/iro_watches_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
before_action :set_lists.
- #destroy ⇒ Object
- #index ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
before_action :set_lists
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! :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] :destroy, @w flag = @w.destroy if flag flash[:notice] = 'Success.' else flash[:alert] = @w.errors..join(", ") end redirect_to action: 'index' end |
#index ⇒ Object
30 31 32 33 |
# File 'app/controllers/ish_manager/iro_watches_controller.rb', line 30 def index :index, Iro::OptionWatch @watches = Iro::OptionWatch.order_by( ticker: :asc, direction: :asc, price: :desc) end |
#update ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/ish_manager/iro_watches_controller.rb', line 35 def update @option_watch = Iro::OptionWatch.find params[:id] :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 |