So lets say I have an array containing a hash like this:
[{"head"=> {"title"=>"$20,000 Prize-Winning Chili",
"categories"=>[{"cat" => "Tex-mex"}]
Its much bigger than this (its a full recipe) – but this should be enough to demonstrate my question.
in my model Recipe.rb I have:
def title
self["head"]["title"] rescue nil
end
which will give me recipe.title in my views…however, in my controller, I want to be able to do things like:
@recipes = Recipe.where(title: "xyz")
But title isn’t a field in the collection – so it returns nothing to me… any ideas here? I’m super new to mongo – as in I started with it yesterday.
Thanks!
Use this: