hicknhack-software / redmine_time_tracker

A time tracker plugin for Redmine
Other
106 stars 32 forks source link

Open start-time-tracker link in header menu in new tab result in internal server error #155

Closed mstarke closed 10 years ago

mstarke commented 10 years ago

Clicking the link in the top right menu to start a time-tracker via "open in new tab" results in a new page with an internal server error

sn3ek commented 10 years ago

This problem occurs because the plugin requests for request.xhr? and this is not nil at this moment so it tries to execute redirect_to :back. But the request.env['HTTP_REFERER'] attribute is missing. Nevertheless, redirecting :back is a bad behavior. Sometimes it is useful, but for example in the #delete method of the time_trackers_controller it redirects back if it was a AJAX request. This could run into problems e.g., trying to delete the same object again.

As of the rails documentation it might be better to redirect to a specific location e.g., the time tracker overview page with the status code 303.

If you are using XHR requests other than GET or POST and redirecting after the request then some browsers will follow the redirect using the original request method. This may lead to undesirable behavior such as a double DELETE. To work around this you can return a 303 See Other status code which will be followed using a GET request.

Any clues?