Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@EminenceHC
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save EminenceHC/ed9e07e591554c60d411 to your computer and use it in GitHub Desktop.
Save EminenceHC/ed9e07e591554c60d411 to your computer and use it in GitHub Desktop.
add invalid date to errors
def create
@referral = Referral.new(referral_params)
begin
params[:referral][:dob] = Date.strptime(params[:referral][:dob], '%m/%d/%Y')
rescue
@referral.errors.add(:dob, 'Invalid Date')
end
if @referral.save
redirect_to confirmation_page_referrals_path, notice: "Thank you for submitting this referral to Eminence Healthcare."
else
render :new
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment