Project

General

Profile

Accessing variable from hook in view

Added by Johnny Vestergaard about 10 years ago

Hi,

I have a hook in a plugin, where i would like to append some extra information when viewing issues.

 class Hooks < Redmine::Hook::ViewListener
    def view_issues_form_details_bottom(context={ })
      @results = ExecutionJournal.find_by_test_case_id(context[:issue].id, :order => 'created_on desc')
      context[:controller].send(:render_to_string, {
          :partial => 'views/report_results',
          :locals => context
      })
    end
  end

In the report_results view i would like to use the data in @results to generate a list:

 <% @results.each do |x| %>
... here goes some html stuff...

But for obvious reasons, since @results in a instance variable of the hook class, i cannot access the results variable from my partial view.
When is the preferred way to access data generated in a hook from a view?