I wrote a plugin that grabs latest issues and displays them on the home page. All seems to work pretty well, but it only works the first time I restart the server to run it - after that it 'caches' the issues from that time, and no new ones get fetched.
I've been reading a bit about it, and it seems that I should write a patch for issues to add extra functionality in my plugin. Is that true? If so, what should I add to after_save action? The same happens for the LatestPostsSetup model - if I change the values for max count and side on which it should be displayed, home page doesn't reflect it until I restart the server.
Sorry if this questions seems fairly trivial, I'm new to ruby. Please find the view helper code below:
module LatestPosts
    class ViewHookListener < Redmine::Hook::ViewListener
        require  'plugins/latest_posts/app/models/latest_posts_setup.rb'
        setup = LatestPostsSetup.find_by_id(1)
        if setup == nil
          count = LatestPostsSetup::DEFAULT_COUNT
          side  = LatestPostsSetup::DEFAULT_SIDE
        else
          count = setup.max_count
          side  = setup.side
        end
        issues  = Issue.find(:all, :limit => count, :order => "created_on DESC")
        if side == 'left'
           render_side = :view_welcome_index_left
        else
           render_side = :view_welcome_index_right
        end
        render_on render_side, :locals => {:issues => issues}, :partial => "latest_issues/issues"
    end end
EDIT
I have now changed the view helper to render the html on the fly, and I don't have to restart apache for the new issues to be displayed, I don't understand why would that work over using a html template? Please find the code below:
# lib/latest_posts_hook_listener.rb
module LatestPosts
    class ViewHookListener < Redmine::Hook::ViewListener
        def view_welcome_index_left(context={})
            setup = load_setup()
            if setup[:side] == "left"
                load_issues(setup[:count])
            end
        end
        def view_welcome_index_right(context={})
            setup = load_setup()
            if setup[:side] == "right"
                load_issues(setup[:count])
            end
        end
        def load_setup()
            require  'plugins/latest_posts/app/models/latest_posts_setup.rb'
            setup = LatestPostsSetup.find_by_id(1)
            if setup == nil
                count = LatestPostsSetup::DEFAULT_COUNT
                side  = LatestPostsSetup::DEFAULT_SIDE
            else
                count = setup.max_count
                side  = setup.side
            end
            {:count => count, :side => side}
        end
        def load_issues(count)
            html = '<div class="box" id="statuses">'
            html += '<h3 class="icon22 icon22-users">Latest Issues</h3><ul>'
            issues  = Issue.find(:all, :limit => count, :order => "created_on DESC")
            issues.each do |issue|
                html += <<EOHTML
                  <li>
                      #{link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue } (#{ format_date(issue.created_on) })
                   </li>
EOHTML
            end
            html += '</ul></div>'
            return html
        end
    end
end
 
    