Jason Fb wrote in post #1154202:
> validates :password, if: lambda { self.registration_state ==
> "registered" }

This is an interesting idea. In my case, user attributes change after 
creation only if the user updates his profile, or when he clicks on the 
"forgot my password" link and I have to create a new password for him.

I could therefore create a flag password_validation_required, which is 
true by default, but can be switched off on demand (because my 
application knows the cases, where validation is not necessary).

The question is: Would you consider a good idea to automatically switch 
on password validation inside the lambda expression? I.e.

lambda {
  t=self.password_validation_required
  self.password_validation_required=true
  t
}

or can this potentially lead to problems later on?

Finally, a syntax question: You are writing

  lambda {  .... }

I would have written

  -> { ... }

Are both notations exactly the same?

> Also, read this book:

Thank you for the recommendation!

Ronald

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/ff8bb87a8d14fcb6cd7b9c586e3a8928%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to