I wrote a plugin that captures the latest releases and displays them on the main page. Everything seems to work very well, but it only works the first time I restart the server to start it - after that it "caches" problems from that time on, and they donβt get new ones.
I read a little about this, and it seems to me that I should write a patch for questions in order to add additional features to my plugin. It's true? If so, what should I add to the after_save action? The same thing happens with the LatestPostsSetup model - if I change the values ββfor the maximum quantity and the side on which it should be displayed, the home page does not reflect it until I restart the server.
Sorry if this question seems pretty trivial, I'm new to ruby. Please find the helper code like 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
Now I have changed the view assistant for rendering html on the fly, and I donβt need to restart apache for new problems to be displayed, I donβt understand why this should work using the html template? Please find the following code:
# 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>
source share