Class: IshManager::InvoicesController
Instance Method Summary
collapse
#basic_auth, #home, #tinymce
Instance Method Details
#create ⇒ Object
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
|
#index ⇒ Object
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
|
#new ⇒ Object
11
12
13
|
# File 'app/controllers/ish_manager/invoices_controller.rb', line 11
def new
authorize! :new, @invoice
end
|
#update ⇒ Object
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
|