Closed zarapustra closed 7 years ago
Hi @zarapustra
Thanks for the question. Rectify::ControllerHelpers
is only supposed to be included in your controllers to provide them with some nicer ways to deal with presenters. There's a section in the readme here: https://github.com/andypike/rectify#presenters
Normally a Command is just for encapsulating the business logic and doesn't normally contain the presenter or form (but if you prefer that way, it can be done).
Looking at your example, try removing include Rectify::ControllerHelpers
from the Command and adding it to your controller. Then inside the action where you call the Command you should be able to do something like:
class PostsController < ApplicationController
include Rectify::ControllerHelpers
def create
Post::Command::Create.call(params) do
on(:ok) { |presenter| present(presenter) }
on(:error) { |errors| render(:new) }
end
end
end
I think that will work 😄
Andy
Hello, i am trying to implement Rectify gem in my new rails app. So when i include Rectify::ControllerHelpers into Command, i got error
Without this line, Command works great except those 'expose' and 'presenter' methods.
Gemfile
Command