TLDR:
Change the inputs to include an index and optional type ie amount
=> amount(1i)
Add a setter method in the model and handle a hash input:
class Transaction < ApplicationRecord
# …
def amount=(value)
if value.is_a? Hash
# do stuff with value[1] etc
end
super(value)
end
# …
end
Profit