Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

backport: handle trailing slash with engines #8149

Merged
merged 1 commit into from

2 participants

@senny
Owner

this is a backport of #8115 to fix #7842

The problem was already fixed in master, the solution used for 3-2-stable is different.

@senny
Owner

@rafaelfranca as discussed.

@rafaelfranca
Owner

Now we need the CHANGELOG entry

@senny
Owner

my bad. Thanks for the double-check. Created the entry.

@rafaelfranca rafaelfranca merged commit 5222a33 into rails:3-2-stable
@rafaelfranca
Owner

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 8, 2012
  1. @senny

    backport, handle trailing slash with engines

    senny authored
    this is a backport of #8115 to fix #7842
This page is out of date. Refresh to see the latest.
View
5 actionpack/CHANGELOG.md
@@ -1,5 +1,10 @@
## Rails 3.2.10 (unreleased) ##
+* prevent double slashes in engine urls when `Rails.application.default_url_options[:trailing_slash] = true` is set
+ Fix #7842
+
+ *Yves Senn*
+
* Fix input name when `:multiple => true` and `:index` are set.
Before:
View
2  actionpack/lib/action_dispatch/routing/mapper.rb
@@ -451,7 +451,7 @@ def define_generate_prefix(app, name)
# we must actually delete prefix segment keys to avoid passing them to next url_for
_route.segment_keys.each { |k| options.delete(k) }
prefix = _routes.url_helpers.send("#{name}_path", prefix_options)
- prefix = '' if prefix == '/'
+ prefix = prefix.gsub(%r{/\z}, '')
prefix
end
end
View
5 actionpack/test/dispatch/prefix_generation_test.rb
@@ -248,6 +248,11 @@ def setup
assert_equal "/something/", app_object.root_path
end
+ test "[OBJECT] generating application's route includes default_url_options[:trailing_slash]" do
+ RailsApplication.routes.default_url_options[:trailing_slash] = true
+ assert_equal "/awesome/blog/posts", engine_object.posts_path
+ end
+
test "[OBJECT] generating engine's route with url_for" do
path = engine_object.url_for(:controller => "inside_engine_generating",
:action => "show",
Something went wrong with that request. Please try again.