Skip to content

Instantly share code, notes, and snippets.

@pewniak747
Created July 30, 2014 13:11
Show Gist options
  • Save pewniak747/5a844051f033c488f986 to your computer and use it in GitHub Desktop.
Save pewniak747/5a844051f033c488f986 to your computer and use it in GitHub Desktop.
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
@mm53bar
Copy link

mm53bar commented Oct 31, 2014

Thanks for the great article and gists on how you use services.

I'm confused on how result.invoice is wired up. In other examples, you've shown a Success class with a data attribute and an attr_reader. Assuming you're using that in this example, where does the invoice method come from?

Or am I just reading too much into a simple example? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment