Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6542: update_injection_points.diff

File update_injection_points.diff, 1.1 kB (added by ymendel, 2 years ago)
  • base.rb

    old new  
    17751775        result != false 
    17761776      end 
    17771777 
     1778      def attributes_for_update 
     1779        attributes_with_quotes(false) 
     1780      end 
     1781 
     1782      def sql_for_update 
     1783        "UPDATE #{self.class.table_name} " + 
     1784        "SET #{quoted_comma_pair_list(connection, attributes_for_update)} " + 
     1785        "WHERE #{self.class.primary_key} = #{quote_value(id)}" 
     1786      end 
     1787 
    17781788      # Updates the associated record with values matching those of the instance attributes. 
    17791789      # Returns the number of affected rows. 
    17801790      def update 
    1781         connection.update( 
    1782           "UPDATE #{self.class.table_name} " + 
    1783           "SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} " + 
    1784           "WHERE #{self.class.primary_key} = #{quote_value(id)}", 
    1785           "#{self.class.name} Update" 
    1786         ) 
     1791        connection.update(sql_for_update, "#{self.class.name} Update") 
    17871792      end 
    17881793 
    17891794      # Creates a record with values matching those of the instance attributes