clean up profile generation (wip)
This commit is contained in:
@ -9,8 +9,8 @@ class Member < ApplicationRecord
|
||||
has_many :entities
|
||||
has_many :profiles
|
||||
|
||||
Profile.types.each do |kind|
|
||||
define_method :kind do
|
||||
Profile.kinds.each do |kind|
|
||||
define_method :"#{kind}_profile" do
|
||||
Profile.where( member_id: self.id).where(kind: kind).first
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
class Profile < ApplicationRecord
|
||||
belongs_to :member
|
||||
has_many :events
|
||||
|
||||
|
||||
validates :name , presence: true
|
||||
validates :kind , presence: true
|
||||
validates :bio , presence: true
|
||||
@ -9,7 +9,7 @@ class Profile < ApplicationRecord
|
||||
|
||||
mount_uploader :picture, PictureUploader
|
||||
|
||||
def self.types
|
||||
def self.kinds
|
||||
["member" , "artist" , "teacher"]
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user