Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New/create actions #156

Open
van-mronov opened this issue Dec 27, 2016 · 3 comments
Open

New/create actions #156

van-mronov opened this issue Dec 27, 2016 · 3 comments

Comments

@van-mronov
Copy link

Hi, we're trying to migrate from 1.1 to 2.0.

Previously, we used following pattern for rendering new item form and create this item by form submit:

class FoosController
  def new
    form Foo::Create
  end

  def create
    run Foo::Create do
      return redirect_to_index, notice: "Added foo item."
    end

    render :new
  end
end

Action new didn't process operation, just create contract.

So, here is my question. How I can use new operations with pipes in such way? Should I create operation for new action with only Model(Foo, :new) and Contract::Build steps and another operation for create action with full set of steps (validation, persisting, etc)?

@apotonick
Copy link
Member

Hi @van-mronov! The way you suggest your New and Create operations is correct. Please note that there will be a guide soon that explains this, TRB2 is not "officially" out yet, hence the lack of docs.

How are you liking it so far? 🍻

@van-mronov
Copy link
Author

Hi, @apotonick! Thank you, waiting for docs)

I'm really excited about TRB2. It looks pretty simple and straightforward to use. I guess conception of steps and success/failure pipes are great features. This is how I think about business logic in my mind.

Can I help somehow/contribute? Let me know if you have any issue tracker.

@apotonick
Copy link
Member

Hey @van-mronov, we could need help with generators. They must be decoupled from Rails, using thor as a dependency, so we can reuse them for Hanami, etc.

Are you interested in helping? This would greatly improve TRB's accessability since people can quickly generate some concepts and play with TRB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants