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
[AI-1] Context attributes assigned in interactor not accessible as element within interactor #200
Comments
dark-panda
added
bug
Something isn't working
unverified
This issue has not been verified
labels
Feb 19, 2020
aaronmallen
added
verified
This issue has been verified.
jira
and removed
unverified
This issue has not been verified
labels
Feb 20, 2020
[AI-1] |
aaronmallen
changed the title
Context attributes assigned in interactor not accessible as element within interactor
[AI-32] Context attributes assigned in interactor not accessible as element within interactor
Feb 20, 2020
aaronmallen
changed the title
[AI-32] Context attributes assigned in interactor not accessible as element within interactor
[AI-1] Context attributes assigned in interactor not accessible as element within interactor
Feb 27, 2020
Same issue occurs in the the organizer context. All the attributes defined in contexts are not exposed. class TestInteractor < ActiveInteractor::Base
def perform
context.foo = "hello"
context.bar = 'world'
end
end
class TestInteractor::Context < ActiveInteractor::Context::Base
attribute :foo
attribute :baz, default: -> { '!' }
end
class TestOrganizer < ActiveInteractor::Organizer::Base
organize :test_interactor
end
p TestOrganizer.perform
#<TestOrganizer::Context bar="world"> |
@dark-panda @mohameddiaa27 As a temporary workaround you can do something like this: class TestInteractor < ActiveInteractor::Base
before_perform :user_exists?
def perform
context.user = User.create_with(
first_name: context.first_name,
last_name: context.last_name
).find_or_create_by(email: context.email)
end
private
def user_exists?
return unless User.where(email: context.email).exists?
context.errors.add(:user, " already exists")
context.fail!
end
end |
3 tasks
@dark-panda would you mind providing a code review on #236 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: