Search code examples
javascriptruby-on-railsredmineredmine-plugins

Redmine plugins scripting


I'm new to javascript, Redmine and RoR. So far I have read and understood the plugin development tutorial. But when I try to do things on my own they won't work...

If I use this:

<% content_for :header_tags do %>
<%= javascript_include_tag 'script', :plugin => 'my_plugin' %>
<% end %>

it will generate the correct link code on page source but there will be no scripts loaded to redmine_root/public/plugin_assets. Is that supposed to happen?

I would like to make this hello world example work.

But as far as I can understand, it will never work on the whole Redmine app if the scripts don't get loaded to redmine_root/public/plugin_assets.

If someone can help me out with understand why the scripts are not loading and how to properly use scripts under Redmine I would be very grateful.


Solution

    1. Is code sample copy-paste from your project code? Or You typed it manually with misprints? % and = signs are missed in some places, must be <%= ... %> or <% ... %>
    2. What the content of redmine_root/public/plugin_assets folder? It must have plugin folder named same as your plugin, then images, javascripts and stylesheets folders, like here:

      redmine_root
        ...
        plugins
          your_plugin # your plugin name
          other_plugins
        ...
        public
          ...
          plugin_assets
            your_plugin # your plugin name, must match with your plugin name in redmine_root/plugins
              javascripts
                your_script.js
              images
              stylesheets
             other_plugins    
      

    In this case javascript_include_tag will works correctly with standart parameters (script and plugin names).