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

Already on GitHub? Sign in to your account

drop variable assignment in validations #9945

Merged
merged 1 commit into from Mar 27, 2013

Conversation

Projects
None yet
2 participants
Member

vipulnsward commented Mar 27, 2013

Remove extra variable assignment in validations

@carlosantoniodasilva carlosantoniodasilva and 1 other commented on an outdated diff Mar 27, 2013

activerecord/lib/active_record/validations.rb
@@ -74,8 +74,7 @@ def valid?(context = nil)
protected
def perform_validations(options={}) # :nodoc:
- perform_validation = options[:validate] != false
- perform_validation ? valid?(options[:context]) : true
+ (options[:validate] != false) ? valid?(options[:context]) : true
@carlosantoniodasilva

carlosantoniodasilva Mar 27, 2013

Owner

You can rewrite it as:

options[:validate] == false || valid?(options[:context])

Wdyt?

@vipulnsward

vipulnsward Mar 27, 2013

Member

makes more sense, changing.

@vipulnsward vipulnsward commented on the diff Mar 27, 2013

activerecord/lib/active_record/validations.rb
@@ -74,8 +74,7 @@ def valid?(context = nil)
protected
def perform_validations(options={}) # :nodoc:
- perform_validation = options[:validate] != false
- perform_validation ? valid?(options[:context]) : true
+ options[:validate] == false || valid?(options[:context])

carlosantoniodasilva added a commit that referenced this pull request Mar 27, 2013

@carlosantoniodasilva carlosantoniodasilva merged commit 81b7ebf into rails:master Mar 27, 2013

Thanks.

@vipulnsward vipulnsward deleted the vipulnsward:drop_var_in_validations branch Feb 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment