I''m not sure of this is what you mean but the valid? method runs
validations on a model without saving it:
http://rails.rubyonrails.com/classes/ActiveRecord/Validations.html
On Wed, 30 Mar 2005 23:17:27 -0500, H M
<airmalik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I am working on the authentication part of my application first and
> the login generator and has been helpful. My application requires the
> users to ''activate'' existing accounts by supplying their
email address
> and a password. The email address is matched against email addresses
> already in the database and if found, the password is updated and a
> flag is set to indicate that the account has been activated.
>
> My view has fields for email, password and password confirmation. The
> user model has validations for length of password etc.
>
> The view also has <%= error_messages_for ''user'' %>
to display validation errors.
>
> For the longest time, I couldn''t figure out why this line would
cause
> the undefined method `errors'' for nil:NilClass error. Turns out
the
> error object is returned by the .save method when it applies
> validations before saving the user object.
>
> Since I only save changes if I find a match for the email in my users
> table, if a match isn''t found, the user isn''t saved and
hence the
> validations aren''t and no error object is returned which causes
the
> error_messages_for line to throw an error.
>
> So the question is: How can I run validations against the parameters
> passed from the page without initializing the user object with the
> parameters and saving the object?
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>