Quick validation question

Hi, just a quick one. How can I access session values in validation?
Here’s what I’m trying to do…

validates_numericality_of :points, :less_than_or_equal_to =>

And this is the message I get
undefined local variable or method `session’ for #Class:0x5181a8c

Any help would be appreciated. Thanks.

Unless I’m mistaken, session information is not directly available to
a model. You could hack together some validation in the controller
(not recommended), try sending the session info to the model via a
function, or better yet, find some other place to store this info.


On Mar 29, 3:54 pm, Dan S. [email protected]

Kyle’s right – you’re out past thin ice here. ‘session’ is a
controller issue that’s not really related to your domain (models).
It’s much too fleeting.

What model is validating its ‘points’? How is it related to user? I
think if you start working down that road you’ll find a solution
that’s workable (ie., validate directly or indirectly through user).

On Mar 29, 4:54 pm, Dan S. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs