rack/rack — Issue #291: NoMethodError when deleting cookies from Rails with Rack 1.3
Author: emassip
Created: 2011-12-19 10:28:48+00:00
State: open

I don't know if this can be considered as a Rails issue or a Rack one, but as it worked in previous versions of Rack, that's where it'll be reported.

Right now with Rack 1.3 we can not use Rails's `cookies[:my_cookie_key]` anymore:

```
NoMethodError in AccountController#logout

private method `gsub' called for :autologin:Symbol
RAILS_ROOT: /usr/share/redmine

Application Trace | Framework Trace | Full Trace
/usr/lib/ruby/vendor_ruby/rack/backports/uri/common.rb:24:in `encode_www_form_component'
/usr/lib/ruby/vendor_ruby/rack/utils.rb:23:in `escape'
/usr/lib/ruby/vendor_ruby/rack/utils.rb:201:in `set_cookie_header!'
/usr/lib/ruby/vendor_ruby/rack/utils.rb:238:in `delete_cookie_header!'
/usr/lib/ruby/vendor_ruby/rack/response.rb:63:in `delete_cookie'
/usr/lib/ruby/vendor_ruby/action_controller/cookies.rb:94:in `delete'
```

Rack 1.1.1 Utils#escape:

```
def escape(s)
s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
'%'+$1.unpack('H2'*bytesize($1)).join('%').upcase
}.tr(' ', '+')
end
```

Rack 1.3.1 Utils#escape:

```
def escape(s)
URI.encode_www_form_component(s)
end
```

Please note that the `to_s ` has been crushed.

Using `cookies['my_cookie_key']` works but is not Rails way.

I don't understand why I can't find any related issues reported, I must be missing something??