Use safe dynamic finders of simply stored for suppliers sections
This commit is contained in:
@@ -14,13 +14,7 @@ class Section
|
||||
validates :title, presence: true
|
||||
validates :supplier_id, presence: true
|
||||
|
||||
# Probably faster to directly retreive the document and return nil
|
||||
# if the supplier does not match
|
||||
def self.find_by_supplier_and_id(supplier, id)
|
||||
section = find(id)
|
||||
return nil unless section.supplier_id == supplier.id
|
||||
section
|
||||
end
|
||||
view :by_supplier_id_and_id, key: [:supplier_id, :_id]
|
||||
|
||||
def occupied_tables
|
||||
return @occupied_tables if @occupied_tables.present?
|
||||
|
||||
Reference in New Issue
Block a user