as @mu-is-too-short mentioned in his comment, to search in embedded docs you use
if params[:body].present?
result += Vehicle.where('specification.body' => param(:body)).to_a
end
please note that Vehicle.where(...)
returns a Criteria which is not the objects only the query to be evaluated.
also note that if you want to use specific operators like in
, <
, <=
you have to use the corresponding mongodb operator for example
Vehicle.where('specification.body' => {'$in' => param(:body)}) # matches .in
Vehicle.where('specification.body' => {'$lt' => param(:body)}) # matches <
Vehicle.where('specification.body' => {'$lte' => param(:body)}) # matches <=