I have a user sign-up form with a registration code field (:reg_code). I have a list of valid registration codes (in a yml file, but doesn't have to be if that makes things easier). I need to check if the user enters in a valid code in the reg code field. I'm a rails/ruby newbie and have NO CLUE how to load & parse the file to check the reg codes.
My class: (the important parts, anyway)
class Foo < ActiveRecord::Base
...more class goodness here...
before_create :validate_reg_code
def validate_reg_code
errors.add(:reg_code, "Sorry, this registration code is invalid.") if reg_code
end
end
I have no clue after the 'if reg code' portion. Please help!