Brian Carpenter

Joined

2,320 Experience
8 Lessons Completed
2 Questions Solved

Activity

Posted in Tracking Metrics with Ahoy and Blazer Discussion

Anyone using Ahoy on rails 7? Server side is working fine but getting errors on client side that "ahoy is not defined"

gem file

gem "ahoy_matey"

models/ahoy/event.rb

class Ahoy::Event < ApplicationRecord
  include Ahoy::QueryMethods

  self.table_name = "ahoy_events"

  belongs_to :visit
  belongs_to :user, optional: true
end

models/ahoy/event.rb

class Ahoy::Visit < ApplicationRecord
  self.table_name = "ahoy_visits"

  has_many :events, class_name: "Ahoy::Event"
  belongs_to :user, optional: true
end

console output

player.js:23 Uncaught ReferenceError: ahoy is not defined
    at togglePlay (player.js:23:7)
    at HTMLAnchorElement.<anonymous> (player.js:14:9)

player.js

ahoy.track("Played Audio", audio_detail)

config/initializers/ahoy.rb

class Ahoy::Store < Ahoy::DatabaseStore

  Ahoy.api = true

  Ahoy.geocode = false
end

Typing ahoy.track("test") directly in console also return the same error.

Any help/thoughts?

Found this link on how to reference a blob for use with another model.

https://github.com/rails/rails/issues/31674

I'd like to access a file object that already exists in active storage and re-attach it to another model. Something like
@newmodel.image.attach(file_object_already_in_active_storage)

Is this possible?

Variations of rails_blob_path and url_for methods produce invalid signature errors.

Posted in Go Rails' Stripe lesson and strong params

+1

Very helpful, thanks.

I have a situation where I'm generating N post requests for given table in a vuejs app, but sending them to the rails controller one by one. I'd like to batch them all up in the app as a JSON object, then send one request over and let rails parse it out.

Would this be as simple as writing a custom controller action?

Wondering if rails has a framework/method for handling batch requests or if there's some standard approaches I should be using.

Thanks.

logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2022 GoRails, LLC. All rights reserved.