docbrown/app/models/profile.rb
Michael Kohl 2555de8a5f
Add profile model (#9648)
* Create profiles table

* Add store_attribute gem

* Add profile model

* Add default value to data column

* Add and update factories

* Add cascading delete

* Make field non-nullable

* Add specs

* Fix cascading delete for profiles
2020-08-11 10:15:22 +07:00

14 lines
348 B
Ruby

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