g00dL00Ks / ruby

New GoodLooks site built on ruby!
0 stars 0 forks source link

Validation for service type #11

Open g00dL00Ks opened 8 years ago

g00dL00Ks commented 8 years ago

In app>models>user.rb I have validation code to make sure that the user is selecting one service. but there are a few issues. can you take a look:

Validation that the user selects an expertise

the logic works but two problems:

1 - the alert message doesn't come up

2- all existing users can't access their account b/c they are missing data.

we could need to clear the database before implementing

CODE FOR VALIDATION

validate :at_least_one_expertise

def at_least_one_expertise

unless [:trainer, :dietician, :nutritionist, :health_coach, :career_coach, :life_coach, :stylist].include?(true)

errors[:base] << ("Please choose at least one area of expertise.")

end

end