I have been following the Redmine Plugin Tutorial and read the page on Hooks, but I still can't get my plugins partials to render, using the render_on
keyword or otherwise.
Here's where I'm putting my partials:
app
└── views
├── issues
│ └── _issue_mail_settings_form.html.erb
└── projects
└── _mail_settings_form.html.erb
Here is my class with the render_on
keyword, which is in the lib
directory:
class MailSettingIssueHooks < Redmine::Hook::ViewListener
render_on :view_issues_form_details_bottom,
:partial => "issues/issue_mail_settings_form"
end
In init.rb I just require 'mail_setting_issue_hooks'
.
If I load Redmine up like this, I can't view the page for any issues - I just get a 404 error. Console output for the request is here, though it doesn't look useful.
If I define a method named view_issues_form_details_bottom
in MailSettingIssueHooks
and it returns a string, that renders correctly.
How does the render_on
keyword decide where to look for partials, and how can I get it working?
When Redmine loads plugins, it adds the default views directory of each - app/views
- to the global Rails view path. The catch is it does not use the actual directory on disk - it assumes a plugin is located plugins/<name>
, where <name>
is the argument you use to Redmine::Plugin.register
.
This means that if your init.rb
looks like:
Redmine::Plugin.register :cool_stuff do
...
But your plugin's directory is actually redmine_cool_stuff
, the code will load and execute but the views will not be found.
Solution: Make sure the argument to Plugin.register
is the same as the name of your directory in the redmine plugins
directory.