EDIT:
I have many answers with different approaches to solve the problem, thank you very much!
Unfortunately, none of them have worked so far.
To easily understand and reproduce the crash, I created a small Rails repository on GitHub using Rspec Suite.
One of the specifications passes (where the presenter is initialized in the view). One of the specifications does not work (where the initiator is initialized in the controller).
How to make them pass?
ORIGINAL QUESTION BELOW:
This is my host:
class UserPresenter
def initialize(user, vc)
@user = user
@vc = vc
end
def linkify()
vc.link_to("foo") do
yield
end
end
end
This is my controller:
I initialize my presenter in the controller, passing the context of the controller view with the presented model.
class UserController
def show
@user = User.find(
@presenter = UserPresenter.new(@user, view_context)
end
end
In my Slim template, I call my Host to place the content in the link:
=@presenter.linkify do
p "123"
: linkify.
, , , p 123.
: @presenter = UserPresenter.new(@user, self), .
linkify ?