]> git.openstreetmap.org Git - rails.git/commitdiff
Remove conditions from delete_all
authorTom Hughes <tom@compton.nu>
Fri, 2 Jun 2017 14:55:03 +0000 (15:55 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 2 Jun 2017 15:33:48 +0000 (16:33 +0100)
Passing conditions directory to delete_all is deprecated
in rails 5.0 so use a separate where instead.

app/controllers/user_controller.rb
app/controllers/user_roles_controller.rb
app/models/changeset.rb
app/models/node.rb
app/models/relation.rb
app/models/trace.rb
app/models/way.rb

index a79121b03848029d585b578dcaf1f55cb1542f59..540753de51308ef8a8f1d7201efc2949710d8345 100644 (file)
@@ -437,7 +437,7 @@ class UserController < ApplicationController
     if @friend
       if request.post?
         if @user.is_friends_with?(@friend)
-          Friend.delete_all "user_id = #{@user.id} AND friend_user_id = #{@friend.id}"
+          Friend.where(:user_id => @user.id, :friend_user_id => @friend.id).delete_all
           flash[:notice] = t "user.remove_friend.success", :name => @friend.display_name
         else
           flash[:error] = t "user.remove_friend.not_a_friend", :name => @friend.display_name
index 1cfbaf977b0d5a487f2bba28bd198dc2cfa88c9b..9c0339c7a72c5f50825151df15a9a098512e201d 100644 (file)
@@ -15,7 +15,7 @@ class UserRolesController < ApplicationController
   end
 
   def revoke
-    UserRole.delete_all(:user_id => @this_user.id, :role => @role)
+    UserRole.where(:user_id => @this_user.id, :role => @role).delete_all
     redirect_to :controller => "user", :action => "view", :display_name => @this_user.display_name
   end
 
index 549600df6d26819bdce4a1aa04fa816ee8227e77..f41ad99551f96ed3c8b5bba53c285231ba30ddef 100644 (file)
@@ -149,7 +149,7 @@ class Changeset < ActiveRecord::Base
       save!
 
       tags = self.tags
-      ChangesetTag.delete_all(:changeset_id => id)
+      ChangesetTag.where(:changeset_id => id).delete_all
 
       tags.each do |k, v|
         tag = ChangesetTag.new
index 6346907f1ef88354ee098f1ee8c72c774898b1ad..fb9bdf68b0dd700b27c55b39fe4b4885cbced563 100644 (file)
@@ -243,7 +243,7 @@ class Node < ActiveRecord::Base
 
       # Create a NodeTag
       tags = self.tags
-      NodeTag.delete_all(:node_id => id)
+      NodeTag.where(:node_id => id).delete_all
       tags.each do |k, v|
         tag = NodeTag.new
         tag.node_id = id
index 899460dbbc2c9324c5186e9ce6f20b527098be5c..d2490dbaec0e872080fabec0b2d82a64b1628a32 100644 (file)
@@ -317,7 +317,7 @@ class Relation < ActiveRecord::Base
       # if there are left-over tags then they are new and will have to
       # be added.
       tags_changed |= !tags.empty?
-      RelationTag.delete_all(:relation_id => id)
+      RelationTag.where(:relation_id => id).delete_all
       self.tags.each do |k, v|
         tag = RelationTag.new
         tag.relation_id = id
@@ -347,7 +347,7 @@ class Relation < ActiveRecord::Base
       # members may be in a different order and i don't feel like implementing
       # a longest common subsequence algorithm to optimise this.
       members = self.members
-      RelationMember.delete_all(:relation_id => id)
+      RelationMember.where(:relation_id => id).delete_all
       members.each_with_index do |m, i|
         mem = RelationMember.new
         mem.relation_id = id
index 8179dad22cac99db918bbc69d4d059e6f10e9184..eed09dbe536b3b268067837eb6000fc57711d104 100644 (file)
@@ -261,7 +261,7 @@ class Trace < ActiveRecord::Base
     first = true
 
     # If there are any existing points for this trace then delete them
-    Tracepoint.delete_all(:gpx_id => id)
+    Tracepoint.where(:gpx_id => id).delete_all
 
     gpx.points do |point|
       if first
index 9877b8bb8ea2b8dcde7a26c3f93b599fb29f8904..9586094ff10951020aed5f27b2394bf201933303 100644 (file)
@@ -271,7 +271,7 @@ class Way < ActiveRecord::Base
       clone.save!
 
       tags = self.tags
-      WayTag.delete_all(:way_id => id)
+      WayTag.where(:way_id => id).delete_all
       tags.each do |k, v|
         tag = WayTag.new
         tag.way_id = id
@@ -281,7 +281,7 @@ class Way < ActiveRecord::Base
       end
 
       nds = self.nds
-      WayNode.delete_all(:way_id => id)
+      WayNode.where(:way_id => id).delete_all
       sequence = 1
       nds.each do |n|
         nd = WayNode.new