docbrown/app/models/profile.rb
Michael Kohl eff28766fc
[deploy] Migrate profile data (#9750)
* Add temporary Rake task for creating profile fields

* Fix problems after splitting branch

* Add profile migration Rake task

* Add unique index to profiles

* Add migration code to users

* Be smarter about updating profiles

* Update spec

* Update Bullet config

* Fix typo

* Change temporary rake task to data update script

* Re-add profile factory and update spec

* Change private declaration to make CodeClimate happy

* Update comment

* Drop validation in favor of DB default

* Update spec
2020-08-20 11:17:57 +07:00

14 lines
355 B
Ruby

class Profile < ApplicationRecord
belongs_to :user
validates :user_id, uniqueness: true
# This method generates typed accessors for all active profile fields
def self.refresh_store_accessors!
ProfileField.active.find_each do |field|
store_attribute :data, field.attribute_name, field.type
end
end
refresh_store_accessors!
end