* 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
14 lines
355 B
Ruby
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
|