查询记录的数组值

时间:2014-10-28 06:44:14

标签: ruby-on-rails-4

我有一个记录,其中一个值存储为这样的数组;

#<Health id: 12, district: 43, county: 89, sub_county: 480, name_of_institution: "May Medical Center", money_received: #<BigDecimal:b6ca9318,'0.6E6',9(18)>, date_received: "2013-10-23", use_of_money: "Money used o construct operation theater.", grade_of_health_center: 4, opening_time: "2000-01-01 07:00:00", closing_time: "2000-01-01 18:30:00", **service_offered: ["2", "3", "4", ""]**, other_service_offered: "HIV treatement", male_patients: 54, female_patients: 78, brick_and_wattle: 9, mad_and_wattle: 2, other_structures: 9, source_of_power: [""], other_source_of_power: "Generator", toilet_facilities: true, alternative_disposal: "", separate_toilets: true, running_water: true, alternative_water: "", state_of_water: "Functional", duration_non_functional: "", placenta_pit: true, placental_disposal: "", waste_pit: true, waste_disposal: "", storage_expired_drugs: false, expired_drugs_storage: "They are burnt to ash", pregnant_mother: 15, number_of_beds: 5, delivery_beds: 1, ambulance: true, status_of_ambulance: "Functional", keep_records: true, number_of_staff: 14, medical_staff: 6, resident_medical_staff: 3, created_at: "2014-10-23 17:00:48", updated_at: "2014-10-23 21:23:36"> 

如何检查值service_offered: ["2", "3", "4", ""]是否存在&#39; 2&#39;

我试过这个;

Health.where("grade_of_health_center = '2'").includes(service_offered: "4").count

我想检索包含值为2

的service_offered数组的记录

0 个答案:

没有答案