# SharedFood
共享食物数据模块,后续可以扩展成所有对食物数据的依赖,并适当的服务化相关的业务 (通过http 或者 grpc) 提供服务。
## 安装
gem 'shared_food', git: 'git@git.boohee.cn:ruby/shared_food.git' branch: 'v0.0.1'
## 配置
1. 在 database.yml 中增加 ifood 相关数据库配置
“` ## ifood ifood_development:
<<: *default database: ifood_dev
ifood_test:
<<: *default database: ifood_test
ifood_qa:
<<: *default host: boohee-qa database: ifood_qa
ifood_production:
<<: *default database: ifood_pd
“`
2. 如果要更改 image_host 路径,在 config/environments/<env>.rb 中增加如下配置代码 SharedFood.config do |conf| conf.ifood_image_host = 'f1.boohee.com' conf.food_image_host = 's.boohee.cn' conf.up_image_host = 'up.boohee.cn' end
## 使用
直接使用 food 相关 model,如 Food, FoodUnit, FoodLight, FoodIngredient 等 如果使用全文检索 Food#search_with_fields(keyword, page = 1, per_page = 20) 返回 foods 和 total_pages