# Can't update due to validation limitation

**URL:** <https://www.ruby-forum.com/t/cant-update-due-to-validation-limitation/111367>\
**Category:** Rails\
**Created:** [August 6, 2007, 3:52pm UTC](https://www.ruby-forum.com/t/cant-update-due-to-validation-limitation/111367 "2007-08-06T15:52:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [August 6, 2007, 3:52pm UTC](https://www.ruby-forum.com/t/cant-update-due-to-validation-limitation/111367/1 "2007-08-06T15:52:17Z")

</div>

I’ve got an odd case where the certain models doesn’t want to either  
update and/or create a new one. The problem, as I later found out,  
was due to validation errors (which is great, actually) except for  
some reason, \<%= error\_messages\_for ‘some\_model’ %\> doesn’t print  
anything. This is problematic, because as it turns out, one of my  
user models won’t update because I have to provide a new password,  
each time.

Long story short, I have two problems:

## error\_messages\_for method doesn’t seem to print anything. Does this have to do with how I’m bringing up the code in my controller? A typical update method in my controllers look like this:

def edit\_user  
@user=User.find(params[:id])  
end

## def update\_user @user=User.find(params[:id]) if !params[:user] flash[:notice]=nil render :action =\> ‘edit\_user’ elsif @user.update\_attributes(params[:user]) flash[:notice] = “#{@user.username} was successfully updated.” redirect\_to #someplace. else flash[:notice]=“Failed to update user. Please try again.” render :action =\> ‘edit\_user’ end end

Does flash[:notice] prevent error\_messages\_for from showing up? Last  
time I tried taking off that line, error\_messages\_for gave me nothing!

The second problem is how do I update only portions of the model  
(preferably some method that accepts an :except parameter) given by  
the text field in the view forms that’s supposed to update the model.  
I’m currently using the method update\_attributes(params[:user]), and I  
DON’T want it to update the password if the password field is empty,  
which this method seems to be doing.

---

<div class="post-metadata">

**Author:** ![taro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/df705f/32.png) [@taro](https://www.ruby-forum.com/u/taro)\
**Post date:** [August 6, 2007, 3:58pm UTC](https://www.ruby-forum.com/t/cant-update-due-to-validation-limitation/111367/2 "2007-08-06T15:58:17Z")

</div>

> The second problem is how do I update only portions of the model  
> (preferably some method that accepts an :except parameter) given by  
> the text field in the view forms that’s supposed to update the model.  
> I’m currently using the method update\_attributes(params[:user]), and I  
> DON’T want it to update the password if the password field is empty,  
> which this method seems to be doing.

I forgot to mention that I want the method to update portions of the  
Model while, at the same time, passes through the validation filter.  
I also realized half the problem also lies on how some parameters are  
required in the user model. By using singular update method, do I  
have to pass through those validation filters as well?
