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?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 19 Dec 2007, at 14:26, tatyree wrote:> > 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 >You need render :update render update causes ruby to execute the update method recursive ly Fred> 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? > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick, That was it! Thanks! Best, Todd --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---