私はレールとモンゴイドにかなり慣れていないので、クエリから文字列を抽出することに問題があります。
クラス Filteroption があります
class Fieldoption
include Mongoid::Documentfield :name, :type => String field :option_id, :type => Integer
終わり
そして、このエントリで
+------------------------------------+---------------------- --------------+-----------------------+ | | _id | 名前 | オプション ID | +------------------------------------+---------------------- --------------+-----------------------+ | | 4c6de6a11d41c86698000002 | リクエスト URI | 1 | | | 4c6de6a11d41c86698000003 | ホスト名 | 4 |
option_id 4 で名前を照会すると
foobar = Fieldoption.only(:name).where(:option_id => '4')
foobar.name は「ホスト名」である必要があります。代わりに私は得る
foobar.name
=> "フィールドオプション"
私は何を間違っていますか?
ご協力いただきありがとうございます。