Project

General

Profile

Actions

Defect #12590

closed

Plugin routes.rb files are not getting included on Windows

Added by Stefan Mueller over 11 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Category:
Plugin API
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Cant reproduce
Affected version:

Description

Don't know if this is a new defect, the only defect I found similar has been #11609.
Routes.rb of plugins do not get processed, as a loop in routes.rb of Redmine does not read include them.

In short: Ruby 1.9.3, RubyGems 1.8.24, Rails 3.2.8, development and production, Windows 2012 Standard Server
See rake about and gem list attached for more Information.

I narrowed the issue down to a problem with the routes.rb file of Redmine.
On the bottom of the file there is some logic that does a Dir.glob(File.join(...)) and processes the directories within a loop.
Unfortunately only one iteration is done in this loop, thus only <REDMINE_ROOT>\plugins\.\routes.rb is being examined by File.exists.

I rewrote the loop now all plugins are loading correctly, and the controllers are getting mapped.

  plugin_root = File.join(Rails.root, "plugins")

  Dir.foreach(File.join(plugin_root) do |plugin_dir|
    next if plugin_dir == '.' or plugin_dir == '..'

    file = File.join(plugin_root, plugin_dir, "config/routes.rb")    

    if File.exists?(file)    
      begin
        Rails.logger.info 'Loading plugin routes from ' + file
        instance_eval File.read(file)
      rescue Exception => e
        puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}." 
        exit 1
      end
    end
  end


Files

rack.about.TXT (1.17 KB) rack.about.TXT rack about Stefan Mueller, 2012-12-14 00:38
gems.txt (1.04 KB) gems.txt gem list Stefan Mueller, 2012-12-14 00:38
about.TXT (413 Bytes) about.TXT ruby/scripts about Stefan Mueller, 2012-12-14 00:38

Related issues

Related to Redmine - Patch #12790: ActionController::RoutingError. No route matches for any installed plugins in Redmine 2.1.5.stableClosed

Actions
Related to Redmine - Defect #11609: Override redmine routes.rb in a plugin in redmine 2.xClosedJean-Baptiste Barth

Actions
Actions

Also available in: Atom PDF