peimelo/controlled_health_api

View on GitHub
app/models/food.rb

Summary

Maintainability
A
0 mins
Test Coverage
F
0%
class Food < ApplicationRecord
  validates :name,
            presence: true,
            uniqueness: {
              case_sensitive: false, scope: [:measure]
            }

  scope :ordered, lambda {
    select(:id, :name, :measure, :amount, :cho, :kcal)
      .order(:name)
  }
end