Simple validation silently fails on update or save

Hi its a really simple thing but i can’t get validation to kick in on
updates. It lets me put in any junk instead of a valid email and saves
it. I have tried
:on => :update
:on => :save

if @user.save
if @user.update

with the same results.
can anyone see what my problem is?
regards
Clare

def update_email
@user = Subscriber.find_by_id(session[:user])
@user.email = params[:new_email]
if @user.save
redirect_to :action => ‘index’
else
render :action => ‘change_email’
end
end

validates_format_of :email,:with =>
/^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i, :on => :save

:on => :update
:on => :save

if @user.update

def update_email
@user = Subscriber.find_by_id(session[:user])
@user.email = params[:new_email]
if @user.save
redirect_to :action => ‘index’
else
render :action => ‘change_email’
end
end

where’s the update method in your controller? maybe (guessing longshot)
putting :on => :update_email
will work? or using the update method in the given action etc

?

That was just one variation f my update method, the other one is
identical apart from the line “if @user.save” is replaced with “if
@user.update”.

:on => :update_email == a horrible error

regards
c

where’s the update method in your controller? maybe (guessing longshot)
putting :on => :update_email
will work? or using the update method in the given action etc
Validations are called against models, not controllers.

Clare: You should be about to just leave set up the validation like
this:

class User < ActiveRecord::Base
validates_format_of :email, :with =>
/^([^@\s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$/i
end

That should fire on any save command.

Steve