Defect #6513

"Move" and "Copy" are not displayed when deployed in subdirectory

Added by Go MAEDA about 7 years ago. Updated about 7 years ago.

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

0%

Category:-
Target version:1.0.3
Resolution:Fixed Affected version:1.0.2

Description

"Move" and "Copy" link are not displayed when Redmine 1.0.2 deployed in subdirectory (example: script/server --path subdir).

related issue: #6195

Issue6195_subdir_problem.png (48.1 KB) Go MAEDA, 2010-09-28 03:45


Related issues

Duplicated by Redmine - Defect #6601: No 'move' or 'copy' options on the issue page Closed 2010-10-07
Duplicated by Redmine - Defect #6650: Missing "Add News" button Closed 2010-10-12
Duplicated by Redmine - Defect #6627: missing "add new file" in Files section Closed 2010-10-11

Associated revisions

Revision 4257
Added by Eric Davis about 7 years ago

Revert part of r4064.

Having link_to_if_authorized support urls has too many edge cases and isn't
working with sub-uris. #6195 #6513

History

#1 Updated by Felix Schäfer about 7 years ago

I can confirm that, I'll try to have a look later.

#2 Updated by Felix Schäfer about 7 years ago

  • Status changed from New to 7
  • Assignee set to Eric Davis
  • Target version set to 1.0.3

Eric: patch below, I'll let you take care of the tests though as it was your change ;-) Make sure to document the relative_url_root stuff in the environments if it's not the case already.

Here's a patch (read on though):

diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 6ba40eb..f4ad798 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -41,7 +41,7 @@ module ApplicationHelper
   def link_to_if_authorized(name, options = {}, html_options = nil, *parameters_for_method_reference)
     if options.is_a?(String)
       begin
-        route = ActionController::Routing::Routes.recognize_path(options.gsub(/\?.*/,''), :method => options[:method] || :get)
+        route = ActionController::Routing::Routes.recognize_path(options.match(/\A#{ActionController::Base.relative_url_root}(.*)\?.*\z/)[1], :method => options[:method] || :get)
         link_controller = route[:controller]
         link_action = route[:action]
       rescue ActionController::RoutingError # Parse failed, not a route

This will require you to make rails aware of the subdirectory though, I know passenger takes care of this, webrick doesn't. You can pass the subdirectory information either through an environment variable: RAILS_RELATIVE_URL_ROOT="/redmine" or through an entry in the config/environment.rb:

config.action_controller.relative_url_root = "/redmine"

#3 Updated by Fernando Hartmann about 7 years ago

This problem happens to me.

+1

#4 Updated by Felix Schäfer about 7 years ago

Eric, you broke it, you fix it ;-) Seriously though, it seems more people get hit by this, anything amiss for commit?

#5 Updated by Eric Davis about 7 years ago

Felix Schäfer wrote:

anything amiss for commit?

Time. I want to test it out, since that method is starting to get pretty nasty.

I'm thinking it might be a good idea to take another look at how Redmine is doing permissions and see if these things could be handled there (instead of running through the entire Routing system each time)...

#6 Updated by Felix Schäfer about 7 years ago

Eric Davis wrote:

Time. I want to test it out, since that method is starting to get pretty nasty.

I was thinking more in the lines of code (no pun intended).

I'm thinking it might be a good idea to take another look at how Redmine is doing permissions and see if these things could be handled there (instead of running through the entire Routing system each time)…

Nothing I'd be against, but I'd still want this fixed as soon as possible even if it's with a somewhat bloated solution rather than holding off until we have a good one (and IIRC you were the that made that change in the first place ;-) ). Now, we have 2 options until we find a better solution: go with this, or I'd be willing to find all places making problems so that we can revert the changes to that method.

#7 Updated by Eric Davis about 7 years ago

Felix Schäfer wrote:

Nothing I'd be against, but I'd still want this fixed as soon as possible even if it's with a somewhat bloated solution rather than holding off until we have a good one

True.

(and IIRC you were the that made that change in the first place ;-) ).

Hey, someone needs to keep you working. ;)

Now, we have 2 options until we find a better solution: go with this, or I'd be willing to find all places making problems so that we can revert the changes to that method.

I think reverting is a step back. This code is some of Redmine's older code that has been needed to be upgraded for years. I'll try to take a look at it this weekend and make a decision.

#8 Updated by Eric Davis about 7 years ago

  • Status changed from 7 to Resolved
  • Resolution set to Fixed

Decided to just revert the changes and go back to the older link_to_if_authorized. I don't have the time or desire to go through the entire permissions system to get it to support REST urls properly.

r4257 r4258

#9 Updated by Eric Davis about 7 years ago

  • Status changed from Resolved to Closed

Merged into 1.0-stable for release in 1.0.3

Also available in: Atom PDF