Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

resource(s) functions should not modify options argument #7777

Closed
betesh opened this Issue · 2 comments

3 participants

@betesh

In actionpack-3.2.8/lib/action_dispatch/routing/mapper.rb, line 1337:

options.keys.each do |k|
  (options[:constraints] ||= {})[k] = options.delete(k) if options[k].is_a?(Regexp)
end

This should be preceded by:

options = options.clone

Otherwise, the following code will have unexpected behavior:

Rails.application.routes.draw do
  resources :articles, :posts, options, :except => [:index], :constraints => { :format => /js/ }
end

The constraints element will be deleted in the first call to resources and the posts controller will allow other formats.

@schneems
Collaborator

That seems like unexpected behavior. Would you mind putting in a pull request together to add that dup call in?

@senny senny referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@senny senny referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@senny senny referenced this issue from a commit in senny/rails
@senny senny resource and resources do no longer modify passed options
this is a patch for #7777.
b30ce03
@rafaelfranca
Owner

Closed by #7789

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.