class StockController

Public Instance Methods

create() click to toggle source

POST /stocks POST /stocks.json

# File lib/rails/generators/rorchado/templates/controllers/stock_controller.rb, line 42
def create
  @stock = Stock.new(params[:stock])

  respond_to do |format|
    if @stock.save
      format.html { redirect_to @stock, :notice => 'Stock was successfully created.' }
      format.json { render :json => @stock, :status => :created, :location => @stock }
    else
      format.html { render :action => "new" }
      format.json { render :json => @stock.errors, :status => :unprocessable_entity }
    end
  end
end
destroy() click to toggle source

DELETE /stocks/1 DELETE /stocks/1.json

# File lib/rails/generators/rorchado/templates/controllers/stock_controller.rb, line 74
def destroy
  @stock = Stock.find(params[:id])
  @stock.destroy

  respond_to do |format|
    format.html { redirect_to stocks_url }
    format.json { head :no_content }
  end
end
edit() click to toggle source

GET /stocks/1/edit

# File lib/rails/generators/rorchado/templates/controllers/stock_controller.rb, line 36
def edit
  @stock = Stock.find(params[:id])
end
index() click to toggle source

GET /stocks GET /stocks.json

# File lib/rails/generators/rorchado/templates/controllers/stock_controller.rb, line 4
def index
  @stocks = Stock.all

  respond_to do |format|
    format.html # index.html.erb
    format.json { render :json => @stocks }
  end
end
new() click to toggle source

GET /stocks/new GET /stocks/new.json

# File lib/rails/generators/rorchado/templates/controllers/stock_controller.rb, line 26
def new
  @stock = Stock.new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render :json => @stock }
  end
end
show() click to toggle source

GET /stocks/1 GET /stocks/1.json

# File lib/rails/generators/rorchado/templates/controllers/stock_controller.rb, line 15
def show
  @stock = Stock.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.json { render :json => @stock }
  end
end
update() click to toggle source

PUT /stocks/1 PUT /stocks/1.json

# File lib/rails/generators/rorchado/templates/controllers/stock_controller.rb, line 58
def update
  @stock = Stock.find(params[:id])

  respond_to do |format|
    if @stock.update_attributes(params[:stock])
      format.html { redirect_to @stock, :notice => 'Stock was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render :action => "edit" }
      format.json { render :json => @stock.errors, :status => :unprocessable_entity }
    end
  end
end