Skip to content

How to use alias_input with nested attributes #186

Closed Answered by sunny
paulomcnally asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @paulomcnally!

alias_input won’t help you there, so calling:

play ->(result) { result.client_id = result.campaign_booking.client_id },
        ...

Is the shortest syntax you can have here.

If you’re doing this same assignment over and over again, something you do very often you could always create a small actor that reassigns, e.g.:

play AssignClientIdFromCampaignBooking,
     ...

with:

class AssignClientIdFromCampaignBooking < Actor
  input :campaign_booking
  output :client_id

  def call
    self.client_id = campaign_booking.client_id
  end
end

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by paulomcnally
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants