Class: SuppliersController
Instance Method Summary
collapse
current
Methods included from PathHelper
#finance_group_transactions_path
Instance Method Details
#create ⇒ Object
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/suppliers_controller.rb', line 31
def create
@supplier = Supplier.new(supplier_params)
@supplier.supplier_category ||= SupplierCategory.first
if @supplier.save
flash[:notice] = I18n.t('suppliers.create.notice')
redirect_to suppliers_path
else
render action: 'new'
end
end
|
#destroy ⇒ Object
52
53
54
55
56
57
58
59
60
|
# File 'app/controllers/suppliers_controller.rb', line 52
def destroy
@supplier = Supplier.find(params[:id])
@supplier.mark_as_deleted
flash[:notice] = I18n.t('suppliers.destroy.notice')
redirect_to suppliers_path
rescue StandardError => e
flash[:error] = I18n.t('errors.general_msg', msg: e.message)
redirect_to @supplier
end
|
#edit ⇒ Object
27
28
29
|
# File 'app/controllers/suppliers_controller.rb', line 27
def edit
@supplier = Supplier.find(params[:id])
end
|
#index ⇒ Object
5
6
7
8
|
# File 'app/controllers/suppliers_controller.rb', line 5
def index
@suppliers = Supplier.undeleted.order(:name)
@deliveries = Delivery.recent
end
|
#new ⇒ Object
new supplier if shared_supplier_id is given, the new supplier will filled whith its attributes
18
19
20
21
22
23
24
25
|
# File 'app/controllers/suppliers_controller.rb', line 18
def new
if params[:shared_supplier_id]
shared_supplier = SharedSupplier.find(params[:shared_supplier_id])
@supplier = shared_supplier.suppliers.new(shared_supplier.autofill_attributes)
else
@supplier = Supplier.new
end
end
|
#shared_suppliers ⇒ Object
gives a list with all available shared_suppliers
63
64
65
|
# File 'app/controllers/suppliers_controller.rb', line 63
def shared_suppliers
@shared_suppliers = SharedSupplier.all
end
|
#show ⇒ Object
10
11
12
13
14
|
# File 'app/controllers/suppliers_controller.rb', line 10
def show
@supplier = Supplier.find(params[:id])
@deliveries = @supplier.deliveries.recent
@orders = @supplier.orders.recent
end
|
#update ⇒ Object
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/suppliers_controller.rb', line 42
def update
@supplier = Supplier.find(params[:id])
if @supplier.update(supplier_params)
flash[:notice] = I18n.t('suppliers.update.notice')
redirect_to @supplier
else
render action: 'edit'
end
end
|