Hello all,
I'm pretty new to rails and mongoid and I have a problem with extracting a string out of a query.
I have a class Filteroption
class Fieldoption
include Mongoid::Documentfield :name, :type => String field :option_id, :type => Integer
end
and with this entries
+--------------------------+------------------------------------+-----------+ | _id | name | option_id | +--------------------------+------------------------------------+-----------+ | 4c6de6a11d41c86698000002 | Request URI | 1 | | 4c6de6a11d41c86698000003 | Hostname | 4 |
When I query for the name with the option_id 4
foobar = Fieldoption.only(:name).where(:option_id => '4')
foobar.name should be "Hostname". Instead I get
foobar.name
=> "Fieldoption"
What am I doing wrong ?
Thanks for your help.