Class: SuppliersController

Inherits:
AdminController show all
Defined in:
app/controllers/suppliers_controller.rb

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

Methods inherited from AdminController

#clean_search, #require_admin, #sign_in

Methods inherited from OfficeController

#current_basket, #current_basket_or_nil, #current_clerk, #error

Instance Method Details

#createObject



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

#destroyObject



49
50
51
52
# File 'app/controllers/suppliers_controller.rb', line 49

def destroy
  #    @supplier.deleted_at = Time.now
  redirect_to suppliers_url
end

#editObject



28
29
# File 'app/controllers/suppliers_controller.rb', line 28

def edit
end

#indexObject

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

#newObject



23
24
25
26
# File 'app/controllers/suppliers_controller.rb', line 23

def new
  @supplier = Supplier.new
  render :edit
end

#showObject



20
21
# File 'app/controllers/suppliers_controller.rb', line 20

def show
end

#updateObject



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