You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using this gem in a Rails project, I wrote the following:
classEnqueueMessagingJobincludeInteractorincludeInteractor::Contractsexpectsdorequired(:conversation).schemadorequired(:type).filled(included_in?: %w[emailsms])# ...endenddefcall# My code hereendend
but this fails with the following message:
message: "undefined method `key?' for #<Conversation:0x0000556d16a5d948>"
...
A dirty workaround is to create a second context attribute storing the model's attributes and use that one instead:
Another interactor running before the next one:
classCreateConversationincludeInteractorincludeInteractor::Contractspromisesdorequired(:conversation).filledrequired(:conversation_hash).filled# <=== We promise to provide thisenddefcallcontext.conversation=create_conversationcontext.conversation_hash=create_conversation.attributes# <=== Get a Hash of the modelendend
classEnqueueMessagingJobincludeInteractorincludeInteractor::Contractsexpectsdorequired(:conversation_hash).schemado# <=== Now it respond to `key?`required(:type).filled(included_in?: %w[emailsms])# ...endenddefcall# My code hereendend
And this works.
It would be great to call attributes on the given context item when it is a class which respond_to?(:attributes).
What do you think about that?
The text was updated successfully, but these errors were encountered:
Using this gem in a Rails project, I wrote the following:
but this fails with the following message:
A dirty workaround is to create a second context attribute storing the model's attributes and use that one instead:
Another interactor running before the next one:
And this works.
It would be great to call
attributes
on the given context item when it is a class whichrespond_to?(:attributes)
.What do you think about that?
The text was updated successfully, but these errors were encountered: