Brian Carpenter

Joined

2,330 Experience
8 Lessons Completed
2 Questions Solved

Activity

Posted in How to use Uppy with ActiveStorage Discussion

I built a stimulus controller for this but ran into some issues getting the uppy stylesheets to load. I spent a lot of time trying to figure it out. Putting details here so I don't lose them or perhaps they can be helpful for somebody else. This solution is using an, as of now, unmerged request to excid3/uppy-activestorage-upload so you may/may not want to use it as a dependency.

Found this video which figures out a working solution using an unmerged pull request from excid3/uppy-activestorage-upload by puglet5/uppy-activestorage-upload.

For me relevant parts are at 1:20:26

uppy_controller.js
let uppy = new Uppy({
autoProceed: false,
allowMultipleUploads: true,
debug: true,
logger: Uppy.debugLogger
})

1:23:21

package.json changed:

"dependencies": {
"@excid3/uppy-activestorage-upload": "https://github.com/excid3/uppy-activestorage-upload.git#08f4a315d252f72e9471ce29d236df7be40de0af",

to:
"@excid3/uppy-activestorage-upload": "https://github.com/puglet5/uppy-activestorage-upload.git#08f4a315d252f72e9471ce29d236df7be40de0af"

then:
yarn install

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.