Validation question

Hello all,

I have a controller with a couple of actions and one model.
The model is as so:

validates_presence_of :name, :email, :name
validates_presence_of :password, :password_confirmation

The first action is create and is called by the administrator.

With this action I do not want to validate the password as this is created automatically.

The second action allows the user change their password.
With this action I do not want to validate the email, as there is no need.

However the problem lies in the fact that the Administrator can also change the name and email.
Therefore I am unable to use the :on => create or :on => update, as password validation is required on update for the user,
while email and name validation is required on update and create by the administrator. Quite the pickle! Is there a way of
restricting validation to a controller/action? Therefore I can avoid calling certain validations at certain actions?



This is how I did it. Sounds similar to what you need.


class Customer < ActiveRecord::Base
    attr_accessor :current_password
    validates_presence_of :current_password, :on => :update, :if =>

    def change_password(attributes)
      @password_change = true
      self.attributes = attributes


        def validate_on_update
            if password_change?
                errors.add(:current_password, "is incorrect") unless
encrypt(current_password) == crypted_password

        def password_change?


class AccountController < ApplicationController
    def change_password
        @customer = @current_customer
            if @customer.change_password(params[:customer])
                flash[:notice] = "Your password has been changed"

I think that's exactly what I was looking for, thank you very much...


I tried that, it doesn't work as there are no such parameters for a
validation helper.