#137 ✓resolved
Daniel

Validation documentation error

Reported by Daniel | July 7th, 2009 @ 05:46 PM

Hello Ben,

It seems that there is a discrepancy between the below two documentation pages in that one creates a "before_validation" callback, while the other creates a "validate" callback. In any case, I'm not having success with either version. When using "before_validation", "attempted_record" is nil. When using "validate", my method does not get called at all.

http://rdoc.info/rdoc/binarylogic/authlogic/blob/aa4ee71622b151f3a2...
http://rdoc.info/rdoc/binarylogic/authlogic/blob/aa4ee71622b151f3a2...

In the below example, nothing gets printed. Changing "validate" to "before_validation" prints the $s, but then throws a "nil object" error when reaching "if attempted_record.invited?" ("The error occurred while evaluating nil.invited?").

class UserSession < Authlogic::Session::Base
  logout_on_timeout true
  consecutive_failed_logins_limit 12
  validate :ensure_not_invited


private


def ensure_not_invited

puts &quot;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$&quot;
if attempted_record.invited?
  puts &quot;********************************************&quot;
  self.errors.clear
  self.errors.add_to_base('invited_but_not_created')
end



end end

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Object based authentication solution that handles all of the non sense for you. It's as easy as ActiveRecord is with a database.

People watching this ticket

Pages