Created
July 30, 2014 13:11
-
-
Save pewniak747/5a844051f033c488f986 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class InvoicesController < ApplicationController | |
| # ... | |
| def create | |
| form = InvoiceForm.new(params) | |
| result = CreateInvoice.new(current_user, form).call | |
| @invoice = result.invoice | |
| if result.success? | |
| redirect_to @invoice | |
| else | |
| render :edit, error: result.error | |
| end | |
| end | |
| # ... | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the great article and gists on how you use services.
I'm confused on how
result.invoiceis wired up. In other examples, you've shown aSuccessclass with adataattribute and anattr_reader. Assuming you're using that in this example, where does theinvoicemethod come from?Or am I just reading too much into a simple example? :)