Frederick C. wrote:
On 29 May 2008, at 10:53, Divyesh Kumar wrote:
If you want to get the validation messages you can’t use redirect_to
(at least not without some extra work) since that throws away the user
with errors. You need to use render
Fred
Ok, I will take care of this suggestion into my account.
I added like this:
if params[:user]
user = User.find(session[:user].id)
if user.update_attributes(params[:user])
session[:user] = user
if params[:picture] != “”
User.upload_picture(params,session[:user])
end
#####
render :action => “show” , :id => session[:user].id
else
#flash[:notice]=“Field marked with asterisk(*) are necessary
or might be wrong”
render :action => “edit_user_info” , :id =>
session[:user].id
end
But still it is not working:
In model class I am using this…code
validates_uniqueness_of :login, :on => :create
validates_format_of :login, :with => /^\w+$/i,:message => “can only
contain
letters and numbers.”
validates_presence_of :login
validates_presence_of :name , :on => :create
validates_presence_of :password , :on => :create
validates_length_of :login, :within => 3…40
validates_length_of :password, :within => 5…40 , :if=> Proc.new { |u|
u.password.size > 0 && u.password.size < 5 }
validates_confirmation_of :password, :if=> Proc.new { |u|
u.password.size > 0}
validates_presence_of :email
validates_format_of :email, :with =>
/\A([\w.-+]+)@((?:[-a-z0-9]+.)+[a-z]{2,})\z/i ,:message => “cannot
have #,$,%,!,^,&,*… such characters”
validates_presence_of :name, :on => :update
Need ur help
Thanks
Divyesh