Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow reseting of request variants #18052

Merged
merged 1 commit into from Dec 16, 2014

Conversation

timoschilling
Copy link
Contributor

The current implementation of variants= don't allow a resetting to nil, wich is the default value.

This results in the following code smell:

case request.user_agent
when /iPhone/
  request.variants = :phone
when /iPad/
  request.variants = :ipad
end

With the ability to reset variants to nil, it could be:

request.variants = case request.user_agent
when /iPhone/
  :phone
when /iPad/
  :ipad
end

The current implementation of `variants=` don't allow a resetting to nil, wich is the default value.

This results in the following code smell:
```ruby
case request.user_agent
when /iPhone/
  request.variants = :phone
when /iPad/
  request.variants = :ipad
end
```

With the ability to reset variants to nil, it could be:
```ruby
request.variants = case request.user_agent
when /iPhone/
  :phone
when /iPad/
  :ipad
end
```
rafaelfranca added a commit that referenced this pull request Dec 16, 2014
@rafaelfranca rafaelfranca merged commit 3bdd110 into rails:master Dec 16, 2014
@timoschilling timoschilling deleted the reset_variants branch December 16, 2014 17:39
rafaelfranca added a commit that referenced this pull request Dec 17, 2014
rafaelfranca added a commit that referenced this pull request Dec 17, 2014
@rafaelfranca
Copy link
Member

@timoschilling backported to 4-2-stable, 4-2-0 and 4-1-stable

rafaelfranca added a commit that referenced this pull request Dec 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants