-
Notifications
You must be signed in to change notification settings - Fork 1
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
Error with your new Payment Method translations #7
Comments
Hm, after updating, did you install the new migrations (rails g spree_mobility:install) and migrate them? |
yes I did :-) Here is the full backtrace:
I was wondering if it could be linked to the spree mollie gateway that I use which also includes a payment method decorator... |
Not likely because I namespaced our decorator under SpreeMobility. Are you on Spree slack maybe? Could try to quickly debug this |
Oh wait I think I know what might be going on. |
@mrbrdo : ok, switched to your branch and now, I have a different error, related to... spree mollie gateway ^^
|
Seems like a different issue, like translations assoc is not inherited from Spree::PaymentMethod. Can you give me the output of this: p Spree::PaymentMethod.reflect_on_all_associations.map(&:name)
p Spree::PaymentMethod.object_id
klass = Spree::Gateway::MollieGateway
p klass.object_id
p klass.superclass
p klass.reflect_on_all_associations.map(&:name)
p klass.ancestors Also you could try making sure |
Sure, here are the results:
And... spree_mobility wasn't above spree mollie gateway. I moved it, but it didn't solve the problem. And yes, you are right, Spree::Gateway::MollieGateway is inheriting from payment method: |
The issue seems to be that the MollieGateway class is loaded before SpreeMobility adds translations to PaymentMethod, and it seems in this case the class doesn't inherit the association. Rails.application.config.to_prepare do
::Spree::Gateway::MollieGateway.prepend SpreeMobility::CoreExt::Spree::PaymentMethodDecorator
Prepended PaymentMethodDecorator
end I will try to look further into this though. |
Thanks a lot, this is, indeed, working, and now I can translate Mollie Payment method :-) Rails.application.config.to_prepare do
::Spree::Gateway::MollieGateway.prepend SpreeMobility::CoreExt::Spree::PaymentMethodDecorator
# Prepended PaymentMethodDecorator
end I had to comment "prepended PaymentMethodDecorator" though, otherwise I had an error booting the server "uninitialized constant PaymentMethodDecorator" Thanks for the quick fix! |
@Kulgar can you try removing this initializer and updating to the latest main branch of spree_mobility? I just pushed some code which should fix this, it works in console but please try it in the backend (add/update the translations for this payment method and see if it works on frontend). |
@mrbrdo it seems to work :-) Thx! How did you fix this? I'm curious. |
At the point when applying the decorator to PaymentMethod, the subclass (descendant) of MollieGateway is already loaded, so for all such descendants I manually apply the translates call etc. Although it would be better if the decorator was loaded before any descendants were loaded, I will see if there's a way to do that instead. |
@Kulgar I think I found the actually correct way to fix this. The only issue was where Could you please test this one last time with latest main branch and confirm it works (and does not work if gem order is changed in Gemfile)? Then I can release this as next version. Thanks |
@Kulgar let me know please :) |
@mrbrdo Sorry, I had some kind of an outage at home. |
@mrbrdo : another problem, in dev it works fine but in production I get the following error when accessing store translations:
I checked in the rails console and, mobility_attributes works fine for all translated classes except for "Spree::Store" and "Spree::Variant". Weird... as I have no error in development. So, I'm guessing, this is due to your latest fix you asked me to test :-) |
@Kulgar interesting. And this happens in production no matter the order of gems in the Gemfile? |
@mrbrdo yep |
Hello,
I have this weird error when trying to access payment methods in admin:
And I also get it when I'm on the payment page during checkout...
I tried to find a solution, but no luck yet.
Any idea? :-)
The text was updated successfully, but these errors were encountered: