Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Disable validations for associated belongs_to record by default

  • Loading branch information...
commit 71bf756ea21f338771b53d02951d6654bd295649 1 parent 7f140bb
Pratik lifo authored
2  activerecord/lib/active_record/associations.rb
View
@@ -940,7 +940,7 @@ def belongs_to(association_id, options = {})
)
end
- add_single_associated_save_callbacks(reflection.name) unless options[:validate] == false
+ add_single_associated_save_callbacks(reflection.name) if options[:validate] == true
configure_dependency_for_belongs_to(reflection)
end
4 activerecord/test/models/developer.rb
View
@@ -56,8 +56,8 @@ def log=(message)
end
class AuditLog < ActiveRecord::Base
- belongs_to :developer
- belongs_to :unvalidated_developer, :class_name => 'Developer', :validate => false
+ belongs_to :developer, :validate => true
+ belongs_to :unvalidated_developer, :class_name => 'Developer'
end
DeveloperSalary = Struct.new(:amount)
Please sign in to comment.
Something went wrong with that request. Please try again.