Skip to content

Commit

Permalink
Merge pull request #8149 from senny/backport_7842_to_rails_3_2_stable
Browse files Browse the repository at this point in the history
backport: handle trailing slash with engines
  • Loading branch information
rafaelfranca committed Nov 8, 2012
2 parents 70f384e + d12e753 commit 5222a33
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions actionpack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_dispatch/routing/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/dispatch/prefix_generation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5222a33

Please sign in to comment.