Sha256: 94ec213e1a1fd3c7e504710d0067eaa92915e72800e388616552a41cdf7d1242
Contents?: true
Size: 885 Bytes
Versions: 1
Compression:
Stored size: 885 Bytes
Contents
# frozen_string_literal: true module Cookbook # Cookbook::Use is basically a linking table with extra information. class Use < ApplicationRecord # Relationships belongs_to :use_in, polymorphic: true belongs_to :use_of, polymorphic: true # Scopes scope :recipe_uses, -> { where use_in_type: 'Recipe' } scope :ingredient_uses, -> { where use_of_type: 'Ingredient' } # Methods def quantity_with_unit [quantity, unit].compact.join(' ') end def quantity min = quantity_minimum&.format_quantity max = quantity_maximum&.format_quantity [min, max].compact.join('–') # ndash, not hyphen end if defined?(RailsAdmin) rails_admin do visible false edit do include_all_fields field :use_in do visible false end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cookbook-0.1.1 | app/models/cookbook/use.rb |