-
Notifications
You must be signed in to change notification settings - Fork 13
Association Extension
Jack Collins edited this page Oct 17, 2022
·
4 revisions
The Subroutine::AssociationFields module provides an interface for loading ActiveRecord instances easily.
require "subroutine/association_fields"
class UserUpdateOp < ::Subroutine::Op
include ::Subroutine::AssociationFields
association :user
with_options groups: "update" do
string :first_name
string :last_name
end
protected
def perform
user.update_attributes(update_params)
end
endrequire "subroutine/association_fields"
class RecordTouchOp < ::Subroutine::Op
include ::Subroutine::AssociationFields
association :record, polymorphic: true
protected
def perform
record.touch
end
end