small display fixes

This commit is contained in:
Dan Elbert 2016-01-30 21:51:32 -06:00
parent edfd6f12d6
commit 9cc9fb2c2f
2 changed files with 4 additions and 9 deletions

View File

@ -14,15 +14,9 @@ class RecipeIngredient < ActiveRecord::Base
end end
def display_name def display_name
if quantity.present? && units.present? str = [quantity, units, name].delete_if { |i| i.blank? }.join(' ')
"#{quantity} #{units} #{name}" str << ", #{preparation}" if preparation.present?
elsif quantity.present? str
"#{quantity} #{name}"
elsif units.present?
"#{units} #{name}"
else
name
end
end end
def scale(factor, auto_unit = false) def scale(factor, auto_unit = false)

View File

@ -2,6 +2,7 @@ namespace :usda do
desc 'Empties usda_foods table, imports all data, and then updates any linked ingredients' desc 'Empties usda_foods table, imports all data, and then updates any linked ingredients'
task import: :environment do task import: :environment do
require 'usda_importer'
importer = UsdaImporter.new(Rails.root.join('vendor', 'data', 'usda')) importer = UsdaImporter.new(Rails.root.join('vendor', 'data', 'usda'))
importer.import importer.import
end end