0

I have created plugin for redmine that displays issues with some additional info. Plugin works ok. Now i want this information to be shown on project page under issues summary. ive read this article http://www.redmine.org/boards/3/topics/33949

and rednder_on approach looks very promising. ive added new plugin with hook for view_projects_show_right code looks like this

# lib/release_history_hook.rb

class ReleaseHistoryHook < Redmine::Hook::ViewListener
render_on :view_projects_show_right, :partial => 'bottlenecks/view_issues'
end

bottlenecks plugin tree structure is like this

/opt/redmine/plugins/bottlenecks/
├── app
│   ├── controllers
│   │   ├── bottlenecks_controller.rb
│   │   └── bottlenecks_controller.rb~
│   ├── helpers
│   │   ├── bottlenecks_helper.rb
│   │   └── bottlenecks_helper.rb~
│   ├── models
│   └── views
│   └── bottlenecks
│   ├── view_issues.html.erb
│   ├── view_issues.html.erb~
│   ├── view_issues.html_original.erb
│   ├── view_issues.html_original.erb~
│   └── view_users.html.erb
├── assets
│   ├── images
│   ├── javascripts
│   └── stylesheets
├── config
│   ├── locales
│   │   └── en.yml
│   └── routes.rb
├── db
│   └── migrate
├── init.rb
├── init.rb~
├── lib
│   └── tasks
├── README.rdoc
└── test
├── fixtures
├── functional
│   └── bottlenecks_controller_test.rb
├── integration
├── test_helper.rb
└── unit

21 directories, 16 files

Ive tried to specify full path,path with extensions ...all the combinations. When i run redmine and access project page its always gives me 404 error. I clearly misunderstand something very basic. I just cant find more information on that subject. What am i doing wrong? Also render_on seems to be deprecated. What can i use instead?

AlexS
  • 927
  • 4
  • 16
  • 29

1 Answers1

1

it seems to me that you named your partial incorectly without prefix "_". You should place file _view_issues.html.erb to YOUR_PLUGIN/app/views/bottlenecks/

Source to read more http://www.redmine.org/projects/redmine/wiki/Hooks

Examples:

how to call hook https://github.com/edavis10/redmine_contracts/blob/master/lib/redmine_contracts/hooks/view_issues_show_details_bottom_hook.rb

code of the hook https://github.com/edavis10/redmine_contracts/blob/master/app/views/issues/_show_deliverable.html.erb

gotva
  • 5,919
  • 2
  • 25
  • 35
  • Underscore? there is nothing about naming notation in the wiki page you provided.Besides it didn't worked. – AlexS Sep 26 '13 at 20:08
  • you render partial - it means (by convention) that the name should start from "_". Try to check path to the partial (according to your printed file tree it is incorrect). Another reason can be missed your hook's 'registration'. See [init file](https://github.com/edavis10/redmine_contracts/blob/master/init.rb#L110) from example (last lines). – gotva Sep 27 '13 at 06:53
  • My bad. I misspelled name of the plugin.Now i can see that it tries to render my view. But controller is not called. So all the variables are uninitialized. I have ActionView::Template::Error (undefined method `map' for nil:NilClass):error. – AlexS Sep 27 '13 at 09:19
  • Describe it with details. What controller, what views, in what moment you get exception. – gotva Sep 27 '13 at 09:27
  • init.rb for my plugin has a line menu :application_menu, :bottlenecks, { :controller => 'bottlenecks', :action => 'view_issues' }, :caption => 'Bottlenecks'. bottlenecks_controller.rb prepares data for the view to render. It works when i call it from application menu, but in this case of render_on it does not happen, so all variables that i use in view are not initialized. Should i rename controller files? Should i configure it somehow in routes.rb ? – AlexS Sep 27 '13 at 10:05
  • Hooks have `context` - this is hash with variables. What variables are defined in context depends on hook. In your case it is `:project` ([details](http://www.redmine.org/projects/redmine/wiki/Hooks_List)). So you can pass local variable into your partial - smth like this `render_on ..., :locals => {:project => context[:project]}` – gotva Sep 27 '13 at 10:13
  • This will require some additional work, but it solves my problem. Thank you for your time. – AlexS Sep 27 '13 at 12:54