Interactor Rails provides Rails support for the Interactor gem.
Add this line to your application's Gemfile:
gem "interactor-rails", "~> 2.0"Interactor Rails is tested against Ruby 3.1 and newer on Rails 7.0 or newer. For older versions of Ruby and Rails use version 2.2.1.
Interactor Rails ensures that app/interactors is included in your autoload
paths, and provides generators for your convenience.
rails generate interactor authenticate_useradds to app/interactors/authenticate_user.rb:
class AuthenticateUser
include Interactor
def call
# TODO
end
endThere is also a generator for organizers.
rails generate interactor:organizer place_order charge_card send_thank_you fulfill_orderadds to app/interactors/place_order.rb:
class PlaceOrder
include Interactor::Organizer
organize ChargeCard, SendThankYou, FulfillOrder
endInteractor Rails is open source and contributions from the community are encouraged! No contribution is too small.
See Interactor Rails' contribution guidelines for more information.
A very special thank you to Attila Domokos for his fantastic work on LightService. Interactor is inspired heavily by the concepts put to code by Attila.