Defect #3935

stylesheet_link_tag with plugin doesn't take into account relative_url_root

Added by Luca Pireddu about 13 years ago. Updated about 12 years ago.

Status:ClosedStart date:2009-09-28
Priority:NormalDue date:
Assignee:Eric Davis% Done:


Category:Plugin API
Target version:1.0.2
Resolution:Fixed Affected version:


When using the stylesheet_link_tag helper (and probably others) with :plugin to build URLs for plugin assets, this helper doesn't take into account the relative_url_root set through Redmine::Utils::relative_url_root

I think I've traced the problem to the method plugin_asset_path in module Engines::RailsExtensions::AssetHelpers, file vendor/plugins/engines/asset_helpers.rb

I guess that strictly speaking Engines is responsible for the bug and not Redmine. I'll leave it up to someone else to decide whether or not to resolve it in Redmine.

Related issues

Duplicated by Redmine - Defect #5021: stylesheet_link_tag does not honor Redmine running out of... Closed 2010-03-09
Duplicated by Redmine - Defect #3753: Plugin asset URLs not correctly generated for sub-URI dep... Closed 2009-08-18

Associated revisions

Revision 4094
Added by Eric Davis about 12 years ago

Use the relative_url_root when generating asset_paths. #3935

Contributed by Daniel S from Redmine.


#1 Updated by Jérémie Delaitre over 12 years ago

This duplicates #5021

#2 Updated by Daniel S about 12 years ago

--- vendor/plugins/engines/lib/engines/rails_extensions/asset_helpers.rb~    2010-08-02 17:40:47.000000000 +0200
+++ vendor/plugins/engines/lib/engines/rails_extensions/asset_helpers.rb    2010-08-02 17:40:47.000000000 +0200
@@ -109,7 +109,7 @@ module Engines::RailsExtensions::AssetHe
   # Returns the publicly-addressable relative URI for the given asset, type and plugin
   def self.plugin_asset_path(plugin_name, type, asset)
     raise "No plugin called '#{plugin_name}' - please use the full name of a loaded plugin." if Engines.plugins[plugin_name].nil?
-    "/#{Engines.plugins[plugin_name].public_asset_directory}/#{type}/#{asset}" 
+    "#{ActionController::Base.relative_url_root}/#{Engines.plugins[plugin_name].public_asset_directory}/#{type}/#{asset}" 


#3 Updated by Nick Bolton about 12 years ago

As a workaround, I used the following (more verbose) code (for example, in a hook):

class EventNotificationOverrideViewer < Redmine::Hook::ViewListener
  def view_layouts_base_html_head(context = { })
    javascript_include_tag "#{ActionController::Base.relative_url_root}/#{Engines.plugins['my_plugin'].public_asset_directory}/javascripts/somejs" 

#4 Updated by Go MAEDA about 12 years ago

Daniel S's patch works fine with Redmine 1.0.1 (deployed in a subdirectory) and Projects Tree View plugin (

I wish this issue would be fixed in 1.0.2.

#5 Updated by Jérémie Delaitre about 12 years ago

I just tried Daniel S's patch on a bitnami stack (redmine 1.0.1) and the redmine_time_tracker plugin ( (master branch)) and it works fine too.

#6 Updated by Eric Davis about 12 years ago

  • Status changed from New to Resolved
  • Target version set to 1.0.2
  • Resolution set to Fixed

I have a fork of Engines now where I've added this fix to the plugin and also another fix that was floating around on Redmine. Fixed in r4094 for Redmine.

#7 Updated by Eric Davis about 12 years ago

  • Status changed from Resolved to Closed

Merged into 1.0-stable for release in 1.0.2

Also available in: Atom PDF