3

我收到以下 postgres 错误:

“运算符不存在:jsonb = 整数”

运算符不存在:jsonb = integer

我的应用程序托管在 Heroku 上,并且正在使用 Postgres 9.4 DB。下面是我的帐户控制器使用 ahoy_matey 分析 gem 的样子。

帐户控制器

class AccountsController < ApplicationController
  before_filter :authenticate_user!

  def index
    if current_user.business_id
      @business = Business.find(current_user.business_id)
      # analytics
      @monthly_business_views = ahoy_event_sum("Page Viewed", @business.id)
      @monthly_get_websites = ahoy_event_sum("Visited Website", @business.id)
      @monthly_get_directions = ahoy_event_sum("Directions Viewed", @business.id)
      @monthly_get_fb_shares = ahoy_event_sum("Shared via Facebook", @business.id)
      @monthly_get_tweets = ahoy_event_sum("Tweeted via Twitter", @business.id)
      @reviews = Review.where(:business_id => @business).all
    end
  end

  ...

  def ahoy_event_sum(event, business_id)
    Ahoy::Event.where(name:event, properties: business_id).count
  end

end

Ahoy 事件模型

module Ahoy
  class Event < ActiveRecord::Base
    self.table_name = "ahoy_events"

    belongs_to :visit
    belongs_to :user

    serialize :properties, JSON
  end
end

我有中级技能,如果这个问题有一个简单的解决方法,我深表歉意,请提供有关我将如何解决此问题的任何详细信息。谢谢!

4

0 回答 0