Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

redirect returning wrong url when running in subdirectory #1394

Closed
dalupus opened this Issue May 29, 2011 · 2 comments

Comments

Projects
None yet
2 participants

dalupus commented May 29, 2011

Hi,

I have the following piece of code in my routes.rb file:

match 'findTicket' => redirect{|p,r| "/tickets/#{r.query_parameters[:id]}"}, :as => :find_ticket

Using rails 3.1.0.rc1 this generate paths of the form "/tickets/:id". This is not correct when the application is running in a subdirectory.

For example, using Apache and Passenger, with RackBaseURI set to '/APPNAME', the URLs generated by the redirect should be prefixed by '/APPNAME' -- ie '/APPNAME/tickets/:id'.

Thanks,
dal

Member

sikachu commented Jun 1, 2011

Unfortunately, redirect() is working somewhat like a dumb redirector. It will redirect you to your given location without lookup for the base URI or anything. You'll have to correct the target redirect path and adding the value of RackBaseURI by yourself.

@sikachu sikachu closed this Jun 1, 2011

dalupus commented Jun 1, 2011

my workaround for this issue for anyone interested is to stick a global in the environment.rb file.
MIKE_RELATIVE=""
if Rails.env.production?
MIKE_RELATIVE = "/APPNAME"
end

then in the routes simply pop the global in front of the link. Doing it this way allows for it to work on both prod and dev only adding the uri when needed.

@jake3030 jake3030 pushed a commit to jake3030/rails that referenced this issue Jun 28, 2011

@tekin @NZKoz tekin + NZKoz Ensure ActionMailer doesn't blow up when a two argument proc is set f…
…or the asset host

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1394 state:committed]
dab78e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment