Class: IshManager::InvoicesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ish_manager/invoices_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#home

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/ish_manager/invoices_controller.rb', line 15

def create
  @invoice = Ish::Invoice.new params[:invoice].permit!
  authorize! :create, @invoice
  if @invoice.save
    flash[:notice] = "created invoice"
  else
    flash[:alert] = "Cannot create invoice: #{@invoice.errors.messages}"
  end
  redirect_to :action => 'index'
end

#indexObject



6
7
8
9
# File 'app/controllers/ish_manager/invoices_controller.rb', line 6

def index
  authorize! :index, Ish::Invoice
  @invoices = Ish::Invoice.all.includes( :payments )
end

#newObject



11
12
13
# File 'app/controllers/ish_manager/invoices_controller.rb', line 11

def new
  authorize! :new, @invoice
end

#updateObject



26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/ish_manager/invoices_controller.rb', line 26

def update
  @invoice = Ish::Invoice.find params[:id]
  authorize! :update, @invoice
  if @invoice.update_attributes params[:invoice].permit!
    flash[:notice] = 'Success'
    redirect_to :action => 'index'
  else
    flash[:alert] = "Cannot update invoice: #{@invoice.errors.messages}"
  end
  redirect_to :action => 'index'
end