Class: StockController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/rails/generators/rorchado/templates/controllers/stock_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /stocks POST /stocks.json



42
43
44
45
46
47
48
49
50
51
52
53
54
# 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

#destroyObject

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



74
75
76
77
78
79
80
81
82
# 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

#editObject

GET /stocks/1/edit



36
37
38
# File 'lib/rails/generators/rorchado/templates/controllers/stock_controller.rb', line 36

def edit
  @stock = Stock.find(params[:id])
end

#indexObject

GET /stocks GET /stocks.json



4
5
6
7
8
9
10
11
# 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

#newObject

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



26
27
28
29
30
31
32
33
# 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

#showObject

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



15
16
17
18
19
20
21
22
# 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

#updateObject

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



58
59
60
61
62
63
64
65
66
67
68
69
70
# 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