Sha256: a744b1f2b316f263d851209f1afb405b879adfe352ebccde0ee5d5039194f2d0

Contents?: true

Size: 1.43 KB

Versions: 5

Compression:

Stored size: 1.43 KB

Contents

class IshManager::StockWatchesController < IshManager::ApplicationController

  def create
    @stock_watch = Warbler::StockWatch.new permitted_params
    authorize! :create, @stock_watch
    flag = @stock_watch.save
    if flag
      flash[:notice] = 'Created stock watch.'
    else
      flash[:alert] = "Cannot create stock watch: #{@stock_watch.errors.messages}"
    end
    redirect_to :action => 'index'
  end

  def destroy
    @w = Warbler::StockWatch.find params[:id]
    authorize! :destroy, @w
    flag = @w.destroy
    if flag
      flash[:notice] = 'Success.'
    else
      flash[:alert] = @w.errors.messages
    end
    redirect_to action: 'index'
  end

  def index
    authorize! :index, Warbler::StockWatch
    @profiles = Ish::UserProfile.all
    @stock_watches = Warbler::StockWatch.order_by( ticker: :asc, direction: :asc, price: :desc
      ).includes( :profile )
    @stock_watch = Warbler::StockWatch.new
    # render 'index', :layout => 'ish_manager/application_no_materialize'
  end

  def update
    @stock_watch = Warbler::StockWatch.find params[:id]
    authorize! :update, @stock_watch
    flag = @stock_watch.update_attributes permitted_params
    if flag
      flash[:notice] = 'Updated stock watch.'
    else
      flash[:alert] = "Cannot update stock watch: #{@stock_watch.errors.messages}"
    end
    redirect_to :action => 'index'
  end

  private

  def permitted_params
    params[:warbler_stock_watch].permit!
  end

end



Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ish_manager-0.1.8.268 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.266 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.265 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.264 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.263 app/controllers/ish_manager/stock_watches_controller.rb