Use safe dynamic finders of simply stored for suppliers sections

This commit is contained in:
2012-12-07 13:25:51 +01:00
parent 180b6deb4d
commit fa68893510
5 changed files with 206 additions and 16 deletions
+1 -7
View File
@@ -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?