Rails 4.2 アプリで Ahoy gem を使用しています。properties
Ahoy Events は、多数のテキスト属性とクエリしたいデータを含む属性を持つイベントを保存します。たとえば、Rails コンソールから返された最後のイベントは次のとおりです。
>> Ahoy::Event.last
Ahoy::Event Load (3.8ms) SELECT "ahoy_events".* FROM "ahoy_events" ORDER BY "ahoy_events"."id" DESC LIMIT 1
=> #<Ahoy::Event id: "fffff17f-44e6-41d7-9c32-fa895338f54e", visit_id: "6b05b1ca-3863-46da-9c48-a3ab5fa4a9ee", user_id: 1, name: "$click", properties: {"tag"=>"a", "page"=>"/conversations/2", "text"=>"View", "href"=>"/conversations/2"}, time: "2015-08-23 13:25:51">
properties['text'] = 'View' であるすべてのイベントを取得するにはどうすればよいですか?
私が試してみましたAhoy::Event.where(:properties['text'] => 'View').count
これは次を返します: ```
Ahoy::Event.where(:properties['text'] => 'View').count NoMethodError:
to_sym' for nil:NilClass from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/sanitization.rb:59:in
/Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0 からの expand_hash_conditions_for_aggregates の未定義のメソッド ブロック/gems/activerecord-4.2.5.1/lib/active_record/sanitization.rb:58:ineach' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/sanitization.rb:58:in
expand_hash_conditions_for_aggregates から /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1 /lib/active_record/relation/query_methods.rb:957:build_where' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/relation/query_methods.rb:584:in
どこで!' から /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/relation/query_methods.rb:574:inwhere' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/querying.rb:10:in
where' from (irb):13 from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/console.rb:110:instart' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/console.rb:9:in
start' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:68:inconsole' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/commands_tasks.rb:39:in
run_command!' /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands.rb:17:require<top (required)>' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in
から /Users/dariusgoore/development/ からblackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:block in require' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in
/Users/dariusgoore/development/blackops/.bundle/gems/ruby の「load_dependency」内/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:inrequire' from /Users/dariusgoore/development/blackops/bin/rails:8:in
' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:inload' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in
block in load' from /Users/dariusgoore /development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:inload_dependency' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in
load' from /Users/dariusgoore/.rubies/ruby-2.2. 1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:require' from /Users/dariusgoore/.rubies/ruby-2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
require' ```
ハッシュ属性のクエリをオンラインで調べましたが、成功しませんでした。どんなガイダンスも大歓迎です。