# Strange update\_attribures looping behaviour

**URL:** <https://www.ruby-forum.com/t/strange-update-attribures-looping-behaviour/123655>\
**Category:** Rails\
**Created:** [December 19, 2007, 3:26pm UTC](https://www.ruby-forum.com/t/strange-update-attribures-looping-behaviour/123655 "2007-12-19T15:26:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tatyree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f14d63/32.png) [@tatyree](https://www.ruby-forum.com/u/tatyree)\
**Post date:** [December 19, 2007, 3:26pm UTC](https://www.ruby-forum.com/t/strange-update-attribures-looping-behaviour/123655/1 "2007-12-19T15:26:06Z")

</div>

Hello,

I’m in the process of building a site using restful\_authentication  
with version 2.0.2 and I’ve got a puzzler with the update method in my  
user model (User) and I was wondering if someone might have some  
insight in to what is going on. In my Users Controller I have this  
update method:

class UsersController \< ApplicationController  
…

def update

```
 if current_user.update_attributes(params[:user])
   render update do |page|
     page.alert('Updated')
   end
 else
   render update do |page|
      page.alert('Error')
 end

```

end

Which is called via form\_remote\_tag from a user’s profile page:

form\_remote\_tag(:url =\> { :controller =\> ‘users’, :action  
=\> :update }, :method =\> :put) do  
text\_field :user, ‘gender’, :size =\> 20, :maxlength =\> 40  
end

I was originally looking to use this for a plaintext password that  
gets encrypted (per the standard way it is done in  
restful\_authentication), and so was using text\_field :user, ‘password’  
and … ‘password\_confirmation’. However, I’ve been unable to make it  
work even with simple data types (like the gender example, above).  
What happens is that the update method goes into a loop as soon as it  
is called. If the data is valid, it does update it, but the loop  
never stops. If the data is invalid, it continually reselects the  
user. Either way, I have to kill rails to regain control.

It doesn’t matter what is in the model or the controller and, although  
I’ve got a :collection on the route, it does not matter if I remove it  
and use a standard map.resources :users. The loop always happens.  
Stranger still, it does not do it with any other controller–I have  
tried substituting the target of the form to other attributes on other  
controllers and they worked fine.

I was wondering if anyone might have any insight into what was going  
on here?

---

<div class="post-metadata">

**Author:** ![tatyree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f14d63/32.png) [@tatyree](https://www.ruby-forum.com/u/tatyree)\
**Post date:** [December 19, 2007, 3:49pm UTC](https://www.ruby-forum.com/t/strange-update-attribures-looping-behaviour/123655/2 "2007-12-19T15:49:41Z")

</div>

On 19 Dec 2007, at 14:26, tatyree wrote:

> …  
> end

You need render :update  
render update causes ruby to execute the update method recursive ly

Fred

---

<div class="post-metadata">

**Author:** ![tatyree](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/f14d63/32.png) [@tatyree](https://www.ruby-forum.com/u/tatyree)\
**Post date:** [December 19, 2007, 4:22pm UTC](https://www.ruby-forum.com/t/strange-update-attribures-looping-behaviour/123655/3 "2007-12-19T16:22:06Z")

</div>

Frederick,

That was it! Thanks!

Best,  
Todd
