Skip to content

force_ssl seems to drop optional path segments when redirecting to https #7528

brandonweiss opened this Issue Sep 5, 2012 · 6 comments

7 participants


I have a route:

constraints subdomain: "images" do
  match "/:id(/:geometry)" => "images#show"

And a controller:

class ImagesController < ActionController::Base

  force_ssl if Rails.env.production?

  def show
    # ...


If I go to:
I get redirected to:

Ruby on Rails member

Which Rails version are you testing against? Make sure you test with latest 3.2 version available. Thanks.


Yep, this was 3.2.8.

kennyj commented Sep 6, 2012

I can reproduce this.
And I guess force_ssl is not related to the cause of problem, because when calling only redirect_to() (without force_ssl), this issue also can be reproduced.

It seems that a return value of Journey::Formatter#generate is not correct when using optional path segments.

@tenderlove tenderlove was assigned Oct 27, 2012
JonRowe commented Mar 29, 2013

Is this still an active issue? Has anyone tried to reproduce on 3.2.13? Do you have a test @brandonweiss?


No idea, I just worked around the issue at the time. I don't actively use Rails any more (switched to Sinatra or Grape) so I'm passing on writing the test. It's kind of obscure; I'd probably just close it and wait for someone to reopen it if they encounter the issue.

Ruby on Rails member

Sounds like a plan.

@pixeltrix pixeltrix reopened this Apr 25, 2013
@pixeltrix pixeltrix was assigned Apr 25, 2013
@pixeltrix pixeltrix added a commit that closed this issue Apr 25, 2013
@pixeltrix pixeltrix Use `request.fullpath` to build redirect url in `force_ssl`
The `force_ssl` command now builds the redirect url from `request.fullpath`.
This ensures that the format is maintained and it doesn't redirect to a route
that has the same parameters but is defined earlier in `routes.rb`. Also any
optional segments are maintained.

Fixes #7528.
Fixes #9061.
Fixes #10305.
@pixeltrix pixeltrix closed this in 8227bf7 Apr 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.