Project

General

Profile

Plugin assets not found

Added by Eduardo Mauro over 13 years ago

I have Redmine 0.96 installed and working perfectly under Windows. I installed 2 plugins and they are working as expected but all assets using by them are not retrieved (error 404). I tried to figure out what is going on to no avail. Here what is requested from the server:

http://XXXXX/plugin_assets/redmine_time_tracker/javascripts/time_tracker.js?1280410771

instead of

http://XXXXX/plugin_assets/redmine/redmine_time_tracker/javascripts/time_tracker.js?1280410771

How can I solve this?


Replies (11)

RE: Plugin assets not found - Added by Felix Schäfer over 13 years ago

Your suburi is misconfigured in redmine, can't remember the exact settings, but IIRC you have to muck around config/environment.rb or config/environments/production.rb and add the suburi in a setting there. Have a look at the guides/tutorials in the wiki, I'm pretty sure one covers this.

RE: Plugin assets not found - Added by Eduardo Mauro over 13 years ago

Setting:

config.action_controller.asset_host = "/redmine"

in production.rb solves the problem for plugin assets but now any normal asset (images, css, etc) of Redmine are not retrived since Redmine is appended twice in the beginning of the URL.

RE: Plugin assets not found - Added by Eduardo Mauro over 13 years ago

Redmine is configured correctly according to what is described in HowTo_Install_Redmine_in_a_sub-URI. As I said, Redmine is working perfectly. It just can't fetch plugin assets.

RE: Plugin assets not found - Added by Jean-Baptiste Barth over 13 years ago

Can you confirm the desired URL for your assets ?

The following path : /plugin_assets/<name_of_the_plugin>/<stylesheets|images|javascripts>/<file> is the correct path. If you run Redmine under a sub URI as suggested by Felix, the subfolder(s) should be placed before this cannonical path, but you'll never end with a /redmine/ between plugin_assets/ and the name of your plugin.

Please tell us why you think redmine generates the wrong path (or Rails or Engines..).

RE: Plugin assets not found - Added by Eduardo Mauro over 13 years ago

Let me try to explain the current situation:

  • I installed Redmine under Windows using the instructions from here.
  • Everything works.
  • I installed 2 plugins. Their assets were copied to folder redmine\public\plugin_assets
  • Using Firebug I noticed that plugin assets are not retrieved (error 404). Plugins work but assets are not retrieved.

Plugin assers are being retrieved using the following URL:

http://XXXXX/plugin_assets/redmine_time_tracker/javascripts/time_tracker.js?1280410771

But, I think the correct would be the following:

http://XXXXX/redmine/plugin_assets/redmine_time_tracker/javascripts/time_tracker.js?1280410771

since images, themes, stylesheets, etc from Redmine are being retrieved correctly. Example:

http://XXXXX/redmine/javascripts/application.js?1276974182

RE: Plugin assets not found - Added by Eduardo Mauro over 13 years ago

Has anyone a clue about what is going on?

RE: Plugin assets not found - Added by Felix Schäfer over 13 years ago

I'm sorry, I've stumbled upon #3935 in the mean time, it seems it's a bug in the rails engines (what makes the plugins possible).

RE: Plugin assets not found - Added by Jean-Baptiste Barth over 13 years ago

Eduardo Mauro wrote:

  • I installed 2 plugins. Their assets were copied to folder redmine\public\plugin_assets

I'm not sure to understand this : is it a requirement from your plugins ? Personnally when I install a plugin, I just leave assets in vendor/plugins/<plugin_name>/assets/ and it works perfectly. Engines adds the correct routes for me. Maybe I'm missing something ?

RE: Plugin assets not found - Added by Felix Schäfer over 13 years ago

Jean-Baptiste Barth wrote:

I'm not sure to understand this : is it a requirement from your plugins ? Personnally when I install a plugin, I just leave assets in vendor/plugins/<plugin_name>/assets/ and it works perfectly. Engines adds the correct routes for me. Maybe I'm missing something ?

This is not a requirement from his plugins but how rails engines works. Plugin developers put the assets in plugin_dir/assets/, those are then copied by rains engines to app_dir/public/plugin_assets/plugin_name/ when the rails app is started. That also means that assets from plugin have to be referenced by asset_tag 'some_asset', :plugin => 'plugin_name' for rails to give it the right path, sadly the :plugin option is added by rails engines, which does not take a sub-URI into account.

Take all that together, and you have plugin assets working correctly when the rails app is at the "root" of your vhost, but not when it's in a sub-URI.

RE: Plugin assets not found - Added by Jean-Baptiste Barth over 13 years ago

Felix Schäfer wrote:

This is not a requirement from his plugins but how rails engines works. Plugin developers put the assets in plugin_dir/assets/, those are then copied by rains engines to app_dir/public/plugin_assets/plugin_name/ when the rails app is started. That also means that assets from plugin have to be referenced by asset_tag 'some_asset', :plugin => 'plugin_name' for rails to give it the right path, sadly the :plugin option is added by rails engines, which does not take a sub-URI into account.

Yes I know, I though he did it by hand, which is not required. I just misread the answer.

Take all that together, and you have plugin assets working correctly when the rails app is at the "root" of your vhost, but not when it's in a sub-URI.

OK, got it now. Sorry.

    (1-11/11)