Created
November 2, 2009 15:55
-
-
Save kjwierenga/224241 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Entry.transaction do | |
Playlist.all.each do |playlist| | |
if positions_max = playlist.entries.maximum(:position) | |
ActiveRecord::Base.connection.execute(" | |
UPDATE entries SET position = #{positions_max + 1} - position | |
WHERE playlist_id = #{playlist.id}") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment