Refactor orders index
This commit is contained in:
parent
27fe8a4d42
commit
1b48882c0e
3 changed files with 3 additions and 1 deletions
|
@ -22,6 +22,7 @@ class OrdersController < ApplicationController
|
|||
else
|
||||
sort = "ends DESC"
|
||||
end
|
||||
@suppliers = Supplier.having_articles.order('suppliers.name')
|
||||
@orders = Order.closed.includes(:supplier).reorder(sort).page(params[:page]).per(@per_page)
|
||||
end
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class Supplier < ActiveRecord::Base
|
|||
validate :uniqueness_of_name
|
||||
|
||||
scope :undeleted, -> { where(deleted_at: nil) }
|
||||
scope :having_articles, -> { where(id: Article.undeleted.select(:supplier_id).distinct) }
|
||||
|
||||
# sync all articles with the external database
|
||||
# returns an array with articles(and prices), which should be updated (to use in a form)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
= t '.new_order'
|
||||
%span.caret
|
||||
%ul.dropdown-menu
|
||||
- Supplier.where(id: Article.undeleted.select(:supplier_id).distinct).order('suppliers.name ASC').each do |supplier|
|
||||
- for supplier in @suppliers
|
||||
%li= link_to supplier.name, new_order_path(supplier_id: supplier.id), tabindex: -1
|
||||
|
||||
.well
|
||||
|
|
Loading…
Reference in a new issue