Cancelado

Need a Rails example done on how to succesfully use the [login to view URL] method from within a Decorator

I need a very small Rails example done on how to succesfully use the [url removed, login to view] method from within a Presenter initialized from a controller, and used in a HAML view.

The Presenter must be a subclass of a Draper Decorator ([url removed, login to view]):

So to sum up:

In the controller:

def index

@presenter = SomePresenter::new(view_context)

end

In the Presenter:

class SomePresenter < ApplicationDecorator

def initialize(view_context)

super(view_context)

end

def some_method

[url removed, login to view]("a_key") do

"hej"

end

end

end

And in the HAML view:

%h1 = @presenter.some_method

---

This gives me this error: "You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating [url removed, login to view]"

I need to be able to call cache and return the content to HAML from SomePresenter.

See also my Stack Overflow question on this: [url removed, login to view]

Note that monkey patching either Draper or Rails is not an option to solve this. It must be solved completely by the Presenter class, and must use a presenter initialized in a controller, inheriting from Draper, and used in a HAML view.

The solution to this does not need to be private only to me. I just need the solution. A public git project that shows how to do this, and works, is fine and will be paid.

I have created a git repository to start from that shows my problem and what I want to do:

https://github.com/houen/presenter_caching

Habilidades: Ruby on Rails

Veja mais: draper decorator nil object, return ruby on rails, need a decorator, i need a decorator, how to you, example of a note, error ruby on rails, rails github, haml ruby, github ruby on rails, github how to, presenter, patching, nil, monkey, how to t, h, example, cache, cache c

Acerca do Empregador:
( 0 comentários ) Copenhagen, Denmark

ID do Projeto: #2507541