Commit b8a98e893ad8e3071813e18c0dda5d6841cfaefb
1 parent
1182476c
Exists in
master
and in
27 other branches
rails3: fix uploaded_file migration
Showing
1 changed file
with
3 additions
and
2 deletions
Show diff stats
db/migrate/20140221142304_move_title_virtual_field_to_name_in_uploaded_file.rb
1 | 1 | class MoveTitleVirtualFieldToNameInUploadedFile < ActiveRecord::Migration |
2 | 2 | def self.up |
3 | 3 | UploadedFile.find_each do |uploaded_file| |
4 | - uploaded_file.name = uploaded_file.setting.delete :title | |
5 | - uploaded_file.send :update_without_callbacks | |
4 | + uploaded_file.name = uploaded_file.setting.delete(:title) | |
5 | + UploadedFile.update_all({:setting => uploaded_file.setting.to_yaml, :name => uploaded_file.name}, | |
6 | + "id = #{uploaded_file.id}") | |
6 | 7 | end |
7 | 8 | end |
8 | 9 | ... | ... |