I have a user signup form that has the usual fields (name, email, password, etc...) and also a \"team_invite_code\" field and a \"role\" popup menu.
Before creating
Your validate method child_and_team_code_exists
should be a private or protected method, otherwise in your case it becomes an instance method
validate :child_and_team_code_exists
private
def child_and_team_code_exists
errors.add(:team_code, t("user_form.team_code_not_present")) unless
self.is_child? && Team.scoped_by_code("params[:team_code]").exists?
end