-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathinvoice_items_controller.rb
More file actions
50 lines (41 loc) · 1.12 KB
/
invoice_items_controller.rb
File metadata and controls
50 lines (41 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class InvoiceItemsController < ApplicationController
load_and_authorize_resource :except => [:create]
def index
@title = "Invoice Line Presets"
end
def new
@title = "Create a new Invoice Line Preset"
end
def create
@title = "Create a new Invoice Line Preset"
@invoice_item = InvoiceItem.new(ii_params)
authorize! :create, @invoice_item
if @invoice_item.save
flash[:notice] = 'Invoice item was successfully created.'
redirect_to :action => 'index'
else
render :action => 'new'
end
end
def edit
@title = "Edit Invoice Line Preset"
end
def update
@title = "Edit Invoice Line Preset"
if @invoice_item.update(ii_params)
flash[:notice] = 'Invoice item was successfully updated.'
redirect_to :action => 'index'
else
render :action => 'edit'
end
end
def destroy
@invoice_item.destroy
flash[:notice] = 'Invoice item was successfully deleted.'
redirect_to :action => 'index'
end
private
def ii_params
params.require(:invoice_item).permit(:memo, :category, :price, :corporate, :line_no)
end
end