interactor-rails Documentation

repository·main·Indexed 19 days ago

https://github.com/collectiveidea/interactor-rails

Integration for the Interactor gem within Rails applications. Provides autoloading for interactor directories and Rails generators for creating interactors and organizers.

Tokens
553
Snippets
6
Records
6
Agent score
16%

What's inside interactor-rails

  1. Generate an Organizer

    main

    Use the interactor:organizer generator to create an organizer. An organizer is used to wrap multiple interactors into a single transaction-like sequence. You can pass multiple interactor names to the generator to pre-populate the organize list.

    rails generate interactor:organizer place_order charge_card send_thank_you fulfill_order
  2. Install interactor-rails

    main

    Add interactor-rails to your application's Gemfile to enable Rails support for the Interactor gem.

    Compatibility Note:

    • For Ruby 3.1+ and Rails 7.0+, use version ~> 2.0.
    • For older versions of Ruby and Rails, use version 2.2.1.
    gem "interactor-rails", "~> 2.0"
  3. Generate an Interactor Organizer

    main

    Use the interactor:organizer Rails generator to create a new organizer class. You can pass one or more interactor names as arguments to specify which interactors this organizer should include.

    Arguments:

    • interactors: An array of names (e.g., name1 name2) representing the interactors to be organized.
    rails generate interactor:organizer interactor1 interactor2