Giter Club home page Giter Club logo

interactor-rails's Introduction

Interactor Rails

Gem Build Coverage Maintainability

Interactor Rails provides Rails support for the Interactor gem.

Installation

Add this line to your application's Gemfile:

gem "interactor-rails", "~> 2.0"

Interactor Rails is compatible with Ruby 2.3, 2.4, or 2.5 on Rails 4.2, 5.0, 5.1, 5.2 or 6.0.

Usage

Interactor Rails ensures that app/interactors is included in your autoload paths, and provides generators for your convenience.

rails generate interactor authenticate_user

adds to app/interactors/authenticate_user.rb:

class AuthenticateUser
  include Interactor

  def call
    # TODO
  end
end

There is also a generator for organizers.

rails generate interactor:organizer place_order charge_card send_thank_you fulfill_order

adds to app/interactors/place_order.rb:

class PlaceOrder
  include Interactor::Organizer

  organize ChargeCard, SendThankYou, FulfillOrder
end

Contributions

Interactor Rails is open source and contributions from the community are encouraged! No contribution is too small.

See Interactor Rails' contribution guidelines for more information.

Thank You!

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.

interactor-rails's People

Contributors

andrewbredow avatar danielmorrison avatar emilford avatar ersatzryan avatar fauxparse avatar gaffneyc avatar gambala avatar georgekaraszi avatar laserlemon avatar olleolleolle avatar sferik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

interactor-rails's Issues

Specs incorrectly generated

When using the generator, specs are generated even if using the default Rails test lib instead of rspec.

I believe this is coming from: #11

Test::Unit not supported

The generator only generates spec files โ€” I hate rspec ๐Ÿ˜„ .

Any chance you could support plain old Test::Unit before I submit a PR?

I think this needs updating to be compatible with Rails 6

I'm trying to upgrade an app to rails 6 and I get this:

 bundle update rails
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies..........
Bundler could not find compatible versions for gem "rails":
  In Gemfile:
    rails (= 6.0.0.beta1)

    interactor-rails (~> 2.0) was resolved to 2.2.0, which depends on
      rails (>= 4.2, < 5.3)

Can't upgrade to interactors 3.0.0

I've tried to update a project so that it uses the new 3.0.0 version of the interactors gem, but it doesn't seem to work.

I'm not a gem development expert but I guess this might be the cause.

Here's what I see when I try to update:

Bundler could not find compatible versions for gem "interactor":
  In Gemfile:
    interactor-rails (~> 1.0) ruby depends on
      interactor (~> 1.0) ruby

    interactor (3.0.0)

Thanks!

Unable to run single(!) rails interactor at rails 6

Dear support,

wasn't able to get answer at https://stackoverflow.com/questions/62833926/unable-to-run-single-rails-interactor-at-rails-6

Unable to run single(!) rails interactor at rails 6. According to https://github.com/collectiveidea/interactor-rails execute: rails generate interactor authenticate_user to create interactor. Command bin/rspec works perfectly and produce output:

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) AuthenticateUser.call add some examples to (or delete) /Users/.../spec/interactors/authenticate_user_spec.rb
     # Not yet implemented
     # ./spec/interactors/authenticate_user_spec.rb:5

Command bin/rspec spec/interactors/authenticate_user_spec.rb to run single interactor produces error:

An error occurred while loading ./spec/interactors/authenticate_user_spec.rb.
Failure/Error:
  RSpec.describe AuthenticateUser, type: :interactor do
    describe '.call' do
      pending "add some examples to (or delete) #{__FILE__}"
    end
  end

NameError:
  uninitialized constant AuthenticateUser
# ./spec/interactors/authenticate_user_spec.rb:3:in `<top (required)>'
No examples found.


Finished in 0.00004 seconds (files took 0.25648 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

Sprint has been stopped: command "spring status"output: "Spring is not running"

Does anybody know how to run spec for single interactor? Could somebody help me to find problem? Thanks!

Sincerely yours,
Anna.

Rails logger support

Do you think it would be better to implement here or in interactor itself/both?

2.1.0 breaks with delayed_job, or any yaml

Silly YAML. Interactor used to work beautifully with delayed_job

Delayed::Job.enqueue SendWeeklyEmails.new

But now, due to a yaml bug (ruby/psych#100) it breaks trying to serialize it. Really it is psych's problem, but we should probably find a workaround.

similar to config.action_view.raise_on_missing_translations behavior?

Rails, when config.action_view.raise_on_missing_translations is active, will raise errors in case of missing translations.
However it's not the case for this gem:

interactor.errors.messages
=> {:login=>["translation missing: en.active_interaction.errors.models.confirm_phone.attributes.login.confirmation_token_expired"]}

Maybe gem should use config.action_view.raise_on_missing_translations var and use raise them too (because gem is rails only), or have own variable for the same purpose?

Rails 5.2.0 support

The new Rails 5.2 was released as of yesterday. Looks like not much other then gemspec restrictions would need to change.

uninitialized constant Admin::UsersController::CreateLoyalty

Hi,
I have:
/admin/users_controller.rb

class Admin::UsersController < AdminController
def update
    CreateLoyalty.call( user: @user, portals: params[ :portals ] )
end

/interactors/admin/create_loyalty.rb

  def call
    context.user.user_portals.destroy_all
    unless context.portals.blank?
      context.portals.each do | c |
        UserPortal.create user: context.user, portal_id: c
      end
    end
  end

Why I get this error?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.