User/Person models merge
This commit is contained in:
parent
66b84e3660
commit
23bf55b66c
80 changed files with 1064 additions and 1221 deletions
28
db/migrate/20140610165551_migrate_data_person_to_user.rb
Normal file
28
db/migrate/20140610165551_migrate_data_person_to_user.rb
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
class MigrateDataPersonToUser < ActiveRecord::Migration
|
||||
class TempPerson < ActiveRecord::Base
|
||||
self.table_name = 'people'
|
||||
end
|
||||
|
||||
class TempUser < ActiveRecord::Base
|
||||
self.table_name = 'users'
|
||||
end
|
||||
|
||||
def change
|
||||
TempPerson.all.each do |p|
|
||||
user = TempUser.find(p.user_id)
|
||||
if p.public_name.empty?
|
||||
user.name = p.email
|
||||
else
|
||||
user.name = p.public_name
|
||||
end
|
||||
user.biography = p.biography
|
||||
user.nickname = p.irc_nickname
|
||||
user.affiliation = p.company
|
||||
user.avatar_file_name = p.avatar_file_name
|
||||
user.avatar_content_type = p.avatar_content_type
|
||||
user.avatar_file_size = p.avatar_file_size
|
||||
user.avatar_updated_at = p.avatar_updated_at
|
||||
user.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue