- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在 Rails 4.2 应用程序中使用 Ahoy gem。 Ahoy Events 存储具有多个文本属性和 properties
的事件包含我要查询的数据的属性。例如,这是我通过 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">
我如何检索属性['text'] = 'View'的所有事件
我试过了Ahoy::Event.where(:properties['text'] => 'View').count
返回:```
Ahoy::Event.where(:properties['text'] => 'View').count NoMethodError: undefined method
to_sym' for nil:NilClass
block in expand_hash_conditions_for_aggregates' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/sanitization.rb:58:in
from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/sanitization.rb:59:ineach'
expand_hash_conditions_for_aggregates' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/relation/query_methods.rb:957:in
from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/sanitization.rb:58:inbuild_where'
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:574:in
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:inwhere'
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:in
from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activerecord-4.2.5.1/lib/active_record/querying.rb:10:instart'
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:in
from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands/console.rb:9:inconsole'
run_command!' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/railties-4.2.5.1/lib/rails/commands.rb:17:in
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<top (required)>'
require' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in
from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:inblock in require'
load_dependency' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in
from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:inrequire'
' from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:in
from /Users/dariusgoore/development/blackops/bin/rails:8:inload'
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: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_dependency'
load' from /Users/dariusgoore/.rubies/ruby-2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
from /Users/dariusgoore/development/blackops/.bundle/gems/ruby/2.2.0/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:268:inrequire'
require' ```
from /Users/dariusgoore/.rubies/ruby-2.2.1/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in
我在网上查找过查询哈希属性,但没有成功。非常感谢任何指导。
最佳答案
使用 Ahoy::Event.where("properties ->> 'text' = 'View'")
使用有效的 JSONB 查询语法更快。
关于ruby-on-rails - 查询 Ahoy Gem 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35753631/
我正在使用 Ahoy gem 获取访问信息。但我注意到在生产中,我经常遇到以下错误: No route matches [GET] "/ahoy/visits" 但是回溯没有显示任何我认识的文件。这是
我安装了 Ahoy 来对我的 Rails 应用程序进行一些用户分析。我正在运行 Rails 4.1.10 并使用 Postgres 9.3.10 我已将 gem 添加到我的 gemfile 中: ge
我想跟踪点击我的链接的访问。 我需要知道每个链接的浏览器、操作系统...的百分比。 这是否意味着我应该在 link.rb 中添加它? class Link }, succ
您好,我有一个 Rails 应用程序,它是一个使用 devise、ahoy 和 Merit 的封闭社区。 我们有一个名为资源的脚手架。每个资源都有一个链接 用户模型 class User
我正在使用 Ahoy gem 来跟踪我的 Rails 应用程序上的文章访问量。 Ahoy默认保存了很多访问数据,例如landing_page url。有没有办法获取并保存到访问表额外的帖子数据,例如帖
我最近开始使用 code rails,我需要弄清楚这个问题。 %td = Ahoy::Event.where(name: "viewed_brochure").where_properties(
我正在使用 Ahoy gem 来记录 Rails 4 应用程序中的用户操作。事件被记录并存储在 Ahoy::Event 表中。每个事件都有一个 properties哈希属性存储为文本。在本例中,我尝试
我在 Rails 4.2 应用程序中使用 Ahoy gem。 Ahoy Events 存储具有多个文本属性和 properties 的事件包含我要查询的数据的属性。例如,这是我通过 Rails 控制台
我正在使用 Ahoy ( https://github.com/ankane/ahoy.js ) 用于分析的 gem。我想计算每日活跃用户。我当前的 SQL 查询基于 GroupDate文档。给定表
我是一名优秀的程序员,十分优秀!