Ticket #6485: polymorphic_sti_associations_plus_has_many_through_1.2.3.diff
| File polymorphic_sti_associations_plus_has_many_through_1.2.3.diff, 5.5 kB (added by chriseppstein, 1 year ago) |
|---|
-
a/vendor/rails/activerecord/lib/active_record/associations.rb
old new 704 704 705 705 if association.updated? 706 706 self["#{reflection.primary_key_name}"] = association.id 707 self["#{reflection.options[:foreign_type]}"] = association.class. base_class.name.to_s707 self["#{reflection.options[:foreign_type]}"] = association.class.name.to_s 708 708 end 709 709 end 710 710 EOF -
a/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb
old new 100 100 def set_belongs_to_association_for(record) 101 101 if @reflection.options[:as] 102 102 record["#{@reflection.options[:as]}_id"] = @owner.id unless @owner.new_record? 103 record["#{@reflection.options[:as]}_type"] = @owner.class. base_class.name.to_s103 record["#{@reflection.options[:as]}_type"] = @owner.class.name.to_s 104 104 else 105 105 record[@reflection.primary_key_name] = @owner.id unless @owner.new_record? 106 106 end -
a/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb
old new 187 187 when @reflection.options[:as] 188 188 @finder_sql = 189 189 "#{@reflection.klass.table_name}.#{@reflection.options[:as]}_id = #{@owner.quoted_id} AND " + 190 "#{@reflection.klass.table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote _value(@owner.class.base_class.name.to_s)}"190 "#{@reflection.klass.table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote @owner.class.name.to_s}" 191 191 @finder_sql << " AND (#{conditions})" if conditions 192 192 193 193 else -
a/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb
old new 130 130 def construct_owner_attributes(reflection) 131 131 if as = reflection.options[:as] 132 132 { "#{as}_id" => @owner.id, 133 "#{as}_type" => @owner.class. base_class.name.to_s }133 "#{as}_type" => @owner.class.name.to_s } 134 134 else 135 135 { reflection.primary_key_name => @owner.id } 136 136 end … … 140 140 def construct_join_attributes(associate) 141 141 returning construct_owner_attributes(@reflection.through_reflection).merge(@reflection.source_reflection.primary_key_name => associate.id) do |join_attributes| 142 142 if @reflection.options[:source_type] 143 join_attributes.merge!(@reflection.source_reflection.options[:foreign_type] => associate.class. base_class.name.to_s)143 join_attributes.merge!(@reflection.source_reflection.options[:foreign_type] => associate.class.name.to_s) 144 144 end 145 145 end 146 146 end … … 150 150 if as = reflection.options[:as] 151 151 { "#{as}_id" => @owner.quoted_id, 152 152 "#{as}_type" => reflection.klass.quote_value( 153 @owner.class. base_class.name.to_s,153 @owner.class.name.to_s, 154 154 reflection.klass.columns_hash["#{as}_type"]) } 155 155 else 156 156 { reflection.primary_key_name => @owner.quoted_id } -
a/vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb
old new 69 69 when @reflection.options[:as] 70 70 @finder_sql = 71 71 "#{@reflection.klass.table_name}.#{@reflection.options[:as]}_id = #{@owner.quoted_id} AND " + 72 "#{@reflection.klass.table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote _value(@owner.class.base_class.name.to_s)}"72 "#{@reflection.klass.table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote @owner.class.name.to_s}" 73 73 else 74 74 @finder_sql = "#{@reflection.table_name}.#{@reflection.primary_key_name} = #{@owner.quoted_id}" 75 75 end