404 error on script in plugin_assets

Added by Brian Sullivan about 10 years ago

I'm running Redmine on Windows using the Bitnami installer. It works great for the most part, but I was having a problem with a time tracker plugin. Looking at the HTTP traffic, I found that the request for the script the plugin uses was getting a 404 (Not Found). I verified that the script was present in "(redmine root)\public\plugin_assets\redmine_time_tracker\javascripts" and that the plugin_assets directory had the same permissions that all the other directories in "public" had.

I suppose I could edit the view to emit the script inline (it's just one function), but I'd rather figure out why the script can't be found in case I want to install other plugins that have much larger scripts.

Thanks in advance!

Replies (7)

RE: 404 error on script in plugin_assets - Added by Brian Sullivan about 10 years ago

Update: Looks like it's not just scripts, either. The stylesheets that should be coming down from plugin_assets are getting 404s too.

RE: 404 error on script in plugin_assets - Added by Brian Sullivan about 10 years ago

Update Again: The url that's being requested is "http://mydomain.com:8888/plugin_assets/redmine_time_tracker/..." when it should be "http://mydomain.com:8888/*redmine*/plugin_assets/redmine_time_tracker/...". Is there somewhere I can set the path that it should be using to get to plugin_assets?

RE: 404 error on script in plugin_assets - Added by Felix Schäfer about 10 years ago

Try adding ActionController::AbstractRequest.relative_url_root = "/redmine" at the end of $REDMINE/config/environment.rb and make sure to restart redmine for the change to take effect (the syntax might be a little off, try googling for relative_url_root if it doesn't work).

RE: 404 error on script in plugin_assets - Added by Brian Sullivan about 10 years ago

Thanks, Felix! Unfortunately, it's still requesting "domain.com/plugin_assets/...". Any other ideas?

RE: 404 error on script in plugin_assets - Added by Felix Schäfer about 10 years ago

You could grep through the code of the plugin to see if it uses programmatic or absolute paths, that might be the problem too. Other than that, not really any other ideas, no.

RE: 404 error on script in plugin_assets - Added by Brian Sullivan about 10 years ago

Found a fix that worked for me. For whatever reason, the stylesheet_link_tag method was generating urls that didn't have the "redmine" segment when called from within the plugin code. Everywhere else, the generated urls were correct. So, after researching AssetTagHelper a little bit, I came up with the following code that I put into my environment.rb:

ActionController::Base.asset_host = Proc.new { |source|
     if source.starts_with?('/plugin_assets')
       "http://domain.com:8888/redmine" 
     else
       "http://domain.com:8888" 
     end
   }

I feel like I shouldn't have to do this, but maybe it's the Bitnami setup that's getting me into this situation. In any case, the generated urls are now all correct, and the plugin works like a charm.

If you see any problems that I might cause myself down the road with this solution, please let me know. I'm not very experienced with Rails, and may not be fully aware of the implications of this change. Thanks!

RE: 404 error on script in plugin_assets - Added by Jérémie Delaitre almost 10 years ago

I'm the author of this plugin, thanks for using it!
However, the bug seems to be in redmine/rails, not in the plugin. See #3935 and #5021.

(1-7/7)