# RESTful RESOURCE PARTIAL UPDATE

**URL:** <https://www.ruby-forum.com/t/restful-resource-partial-update/104862>\
**Category:** Rails\
**Created:** [May 23, 2007, 10:58am UTC](https://www.ruby-forum.com/t/restful-resource-partial-update/104862 "2007-05-23T10:58:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lambo4jos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8baadc/32.png) [@lambo4jos](https://www.ruby-forum.com/u/lambo4jos)\
**Post date:** [May 23, 2007, 10:58am UTC](https://www.ruby-forum.com/t/restful-resource-partial-update/104862/1 "2007-05-23T10:58:28Z")

</div>

I have modified scaffolding code slightly to get three edit actions  
and three update actions.

The requirement: to allow users to edit attributes for the same model  
from seperate forms instead of one form, while using the given  
scaffolding code and performing model validations. I am using  
restful\_authentication with the login email password validations  
defined.

class users\_controller

edit\_email  
edit\_login  
edit\_password

update\_email if update\_attr save else render =\> edit\_email  
update\_login if update\_attr save else render =\> edit\_login  
update\_password @curr\_pass = params[:curr+passs] if update\_attr  
save else render =\> edit\_password

end

i have made routes

edit\_email\_path  
edit\_login\_path  
edit\_password\_path  
update\_email\_path  
update\_login\_path  
update\_password\_path

I can get the update\_email and update\_login to work if I avoid setting  
password validations on update. When i set the password validations  
on update, i can get the update\_password to work, but update\_email,  
and update\_login fail validations because they are trying to validate  
passwords too when there is no form elements for them.

Is there a way to make password validations only run when  
update\_attribute(params[:user]) is called within the update\_password  
controller method and to prevent password validations to run when  
update\_email and update\_login update\_attribute(params[:user]) methods  
are called? Thanks in advance.

---

<div class="post-metadata">

**Author:** ![lambo4jos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8baadc/32.png) [@lambo4jos](https://www.ruby-forum.com/u/lambo4jos)\
**Post date:** [May 23, 2007, 11:01am UTC](https://www.ruby-forum.com/t/restful-resource-partial-update/104862/2 "2007-05-23T11:01:28Z")

</div>

@curr\_pass is defined in update\_password for user model user.rb

validate\_on\_update  
User.authenticate(@user.login, @user.curr\_pass)  
errors.add(@curr\_pass, ‘is incorrect’)  
end

---

<div class="post-metadata">

**Author:** ![lambo4jos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8baadc/32.png) [@lambo4jos](https://www.ruby-forum.com/u/lambo4jos)\
**Post date:** [May 23, 2007, 11:03am UTC](https://www.ruby-forum.com/t/restful-resource-partial-update/104862/3 "2007-05-23T11:03:29Z")

</div>

@curr\_pass is defined in update\_password for user model user.rb

validate\_on\_update  
User.authenticate(@user.login, @user.curr\_pass)  
errors.add(@curr\_pass, ‘is incorrect’)  
end

---

<div class="post-metadata">

**Author:** ![lambo4jos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8baadc/32.png) [@lambo4jos](https://www.ruby-forum.com/u/lambo4jos)\
**Post date:** [May 23, 2007, 11:02am UTC](https://www.ruby-forum.com/t/restful-resource-partial-update/104862/4 "2007-05-23T11:02:29Z")

</div>

@curr\_pass is defined in update\_password for user model user.rb

validate\_on\_update  
User.authenticate(@user.login, @user.curr\_pass)  
errors.add(@curr\_pass, ‘is incorrect’)  
end

---

<div class="post-metadata">

**Author:** ![lambo4jos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8baadc/32.png) [@lambo4jos](https://www.ruby-forum.com/u/lambo4jos)\
**Post date:** [May 23, 2007, 11:02am UTC](https://www.ruby-forum.com/t/restful-resource-partial-update/104862/5 "2007-05-23T11:02:28Z")

</div>

@curr\_pass is defined in update\_password for user model user.rb

validate\_on\_update  
User.authenticate(@user.login, @user.curr\_pass)  
errors.add(@curr\_pass, ‘is incorrect’)  
end
