Class: Bookkeeper::PurchasesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/bookkeeper/purchases_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/bookkeeper/purchases_controller.rb', line 36

def create
  @purchase = Purchase.new(params[:purchase])

  respond_to do |format|
    if @purchase.save
      format.html { redirect_to purchases_path, notice: I18n.t('.bookkeeper.controllers.purchases.created') }
      format.json { render json: @purchase, status: :created, location: @purchase }
    else
      format.html { render action: "new" }
      format.json { render json: @purchase.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject



64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/bookkeeper/purchases_controller.rb', line 64

def destroy
  @purchase = Purchase.find(params[:id])
  @purchase.destroy
  flash[:notice] = I18n.t('.bookkeeper.controllers.purchases.destroyed')

  respond_to do |format|
    format.html { redirect_to purchases_url }
    format.json { head :no_content }
  end
end

#editObject



32
33
34
# File 'app/controllers/bookkeeper/purchases_controller.rb', line 32

def edit
  @purchase = Purchase.find(params[:id])
end

#indexObject



5
6
7
8
9
10
11
12
# File 'app/controllers/bookkeeper/purchases_controller.rb', line 5

def index
  @purchases = Purchase.all

  respond_to do |format|
    format.html
    format.json { render json: @purchases }
  end
end

#newObject



23
24
25
26
27
28
29
30
# File 'app/controllers/bookkeeper/purchases_controller.rb', line 23

def new
  @purchase = Purchase.new

  respond_to do |format|
    format.html
    format.json { render json: @purchase }
  end
end

#showObject



14
15
16
17
18
19
20
21
# File 'app/controllers/bookkeeper/purchases_controller.rb', line 14

def show
  @purchase = Purchase.find(params[:id])

  respond_to do |format|
    format.html
    format.json { render json: @purchase }
  end
end

#updateObject



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/bookkeeper/purchases_controller.rb', line 50

def update
  @purchase = Purchase.find(params[:id])

  respond_to do |format|
    if @purchase.update_attributes(params[:purchase])
      format.html { redirect_to purchases_path, notice: I18n.t('.bookkeeper.controllers.purchases.updated') }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @purchase.errors, status: :unprocessable_entity }
    end
  end
end