Module: ActiveRecord::Turntable::ActiveRecordExt::Relation
- Defined in:
- lib/active_record/turntable/active_record_ext/relation.rb
Instance Method Summary collapse
Instance Method Details
#_update_record(values, id, id_was, turntable_scope = nil) ⇒ Object
Note:
Override to add sharding scope on updating
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_record/turntable/active_record_ext/relation.rb', line 5 def _update_record(values, id, id_was, turntable_scope = nil) # :nodoc: substitutes, binds = substitute_values values scope = @klass.unscoped if @klass.finder_needs_type_condition? scope.unscope!(where: @klass.inheritance_column) end relation = scope.where(@klass.primary_key => (id_was || id)) relation = relation.merge(turntable_scope) if turntable_scope bvs = binds + relation.bound_attributes um = relation. arel. compile_update(substitutes, @klass.primary_key) @klass.connection.update( um, "SQL", bvs ) end |