-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecation warning in Rails 6.0 #134
Comments
I'm not sure I'm following the need to modify stripe_event. What's the harm in adding some explicit |
@rmm5t It breaks code reloading in development. |
I also can't get things to work with explicit Have you been able to use |
Hey @marckohlbrugge, you can make it work by using this: https://edgeguides.rubyonrails.org/autoloading_and_reloading_constants.html#autoloading-when-the-application-boots. |
Awesome this works, simply wrap your code in the initializer as shown in the Rails guide (which doesn't give too much detail)
Wonder id this would work or break in older Rails versions and if it should be A) added to the example in the Readme or B) add an extra note for Rails 6+ |
The guide says:
Is |
I just tested this out locally, and no, |
Are there news on that issue?
I am doing something like this: StripeEvent.configure do |events|
events.all StripeEvents::BillingEventLogger.new(Rails.logger)
events.subscribe 'customer.created', StripeEvents::CustomerCreated.new
end and in my I've this: module StripeEvents
class CustomerCreated
def call(event)
puts "👍🏻 Customer #{event.data.object.id} has been created"
# Event handling
end
end
end |
For us (using docker), this is still very much an issue in local development. Either we have to
# /initializers/stripe.rb
Rails.application.reloader.to_prepare do
StripeEvent.configure do |events|
events.all BillingEventLogger.new(Rails.logger)
events.subscribe 'customer.created', CustomerCreated.new
end
end
What's worse? Having a way to replace the instantiated event classes instead of appending a new instance during the reloads to support code reloading is critical for us. |
Long time since I looked at this issue but just dug a little deeper...
stripe_event/lib/stripe_event.rb Line 23 in 8c48a88
stripe_event/lib/stripe_event.rb Line 72 in 8c48a88
So what we could do:
I don't think adding unsubscribe for specific instances makes much sense since
Subscribe now:
With
I don't have the time right now to open a PR and I haven't noticed any double processing or similar issues in my deployment, but if someone would like to take a stab at it, I'm happy to help |
The README has the following example:
This leads to a deprecation warning in Rails 6.0 and will stop working in a future version of Rails
It would be nice if we could do something like this instead:
I'm not sure about passing
Rails.logger
that way, but you get the idea. We're passing a string instead which StripeEvent later constantizes.What do you think?
The text was updated successfully, but these errors were encountered: