Sha256: 55052def654ed21b6bd37e866f6615d6f5479c2e958d1d08415414707d44a7e6

Contents?: true

Size: 1.36 KB

Versions: 56

Compression:

Stored size: 1.36 KB

Contents

class IshManager::StockWatchesController < IshManager::ApplicationController

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

  def create
    @stock_watch = Ish::StockWatch.new params[:ish_stock_watch].permit!
    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 update
    @stock_watch = Ish::StockWatch.find params[:id]
    authorize! :update, @stock_watch
    flag = @stock_watch.update_attributes params[:ish_stock_watch].permit!
    if flag
      flash[:notice] = 'Updated stock watch.'
    else
      flash[:alert] = "Cannot update stock watch: #{@stock_watch.errors.messages}"
    end
    redirect_to :action => 'index'
  end

  def destroy
    @w = Ish::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

end



Version data entries

56 entries across 56 versions & 1 rubygems

Version Path
ish_manager-0.1.8.258 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.257 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.256 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.255 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.254 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.253 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.252 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.251 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.250 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.249 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.248 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.247 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.246 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.245 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.244 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.243 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.242 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.241 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.239 app/controllers/ish_manager/stock_watches_controller.rb
ish_manager-0.1.8.238 app/controllers/ish_manager/stock_watches_controller.rb