Class: SuppliersController
Overview
A Supplier spupplies inventory for products. The object itself only has an address, it’s main function is to be the owner of purchase orders In other words the supplier is to the Purchase what the User is to an order.
Instance Method Summary
collapse
#clean_search, #require_admin, #sign_in
#current_basket, #current_basket_or_nil, #current_clerk, #error
Instance Method Details
#create ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'app/controllers/suppliers_controller.rb', line 31
def create
@supplier = Supplier.create(params_for_supplier)
if @supplier.save
redirect_to supplier_path(@supplier), :notice => t(:create_success, :model => :supplier)
else
render :edit
end
end
|
#destroy ⇒ Object
49
50
51
52
|
# File 'app/controllers/suppliers_controller.rb', line 49
def destroy
redirect_to suppliers_url
end
|
#edit ⇒ Object
28
29
|
# File 'app/controllers/suppliers_controller.rb', line 28
def edit
end
|
#index ⇒ Object
Uncomment for check abilities with CanCan authorize_resource
14
15
16
17
18
|
# File 'app/controllers/suppliers_controller.rb', line 14
def index
@q = Supplier.search(params[:q])
@supplier_scope = @q.result(:distinct => true)
@suppliers = @supplier_scope.paginate(:page => params[:page], :per_page => 20).to_a
end
|
#new ⇒ Object
23
24
25
26
|
# File 'app/controllers/suppliers_controller.rb', line 23
def new
@supplier = Supplier.new
render :edit
end
|
#show ⇒ Object
20
21
|
# File 'app/controllers/suppliers_controller.rb', line 20
def show
end
|
#update ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'app/controllers/suppliers_controller.rb', line 40
def update
@supplier.update_attributes params_for_supplier
if @supplier.save
redirect_to supplier_path(@supplier), :notice => t(:update_success, :model => :supplier)
else
render :action => :edit
end
end
|