2016-01-24 17:10:43 -06:00
|
|
|
class UsdaFood < ActiveRecord::Base
|
2016-01-28 14:19:51 -06:00
|
|
|
include TokenizedLike
|
|
|
|
|
2016-03-09 18:53:47 -06:00
|
|
|
has_many :usda_food_weights
|
|
|
|
|
2016-01-28 14:19:51 -06:00
|
|
|
def self.search(query)
|
|
|
|
tokens = query.to_s.split(' ')
|
|
|
|
|
|
|
|
if tokens.empty?
|
|
|
|
UsdaFood.none
|
|
|
|
else
|
2016-01-28 18:18:45 -06:00
|
|
|
UsdaFood.matches_tokens(:long_description, tokens)
|
2016-01-28 14:19:51 -06:00
|
|
|
end
|
|
|
|
end
|
2016-01-24 17:10:43 -06:00
|
|
|
|
2016-03-09 20:12:38 -06:00
|
|
|
def density_best_guess
|
|
|
|
usda_food_weights.each do |w|
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-24 17:10:43 -06:00
|
|
|
end
|