Fix ahoy no implicit conversion of Hash into String

Someone got some trouble "no implicit conversion of Hash into String" after upgraded properties field from json to jsonb type in Ahoy. Or you can follow this issue#86 or issue#120.

There is a easy way to fix it. Just add following content in ahoy related class:

# config/initializers/ahoy.rb

class Ahoy::Store < Ahoy::Stores::ActiveRecordStore
  def track_event(name, properties, options, &block)
    event =
      event_model.new do |e|
        e.id = options[:id]
        e.visit_id = ahoy.visit_id
        e.user = user if e.respond_to?(:user=)
        e.name = name
        e.properties = properties.to_json # the keypoint
        e.time = options[:time]
      end

    yield(event) if block_given?

    begin
      event.save!
    rescue *unique_exception_classes
      # do nothing
    end
  end
end

The key point is the track_event, just override it and convert the type for properties assignment.