tyliong
2008-Sep-23 08:46 UTC
Need help with AJAX partial not refreshing browser asking to save .js instead
Hi, when i use the updatepassword action, it does not refresh the ajax partial but forces the browser to save a file why does that happen? def updatepassword @user = current_user return unless request.post? if User.authenticate(current_user.login, params[:old_password]) if ((params[:password] == params[:password_confirmation]) && ! params[:password_confirmation].blank?) current_user.password_confirmation params[:password_confirmation] current_user.password = params[:password] if current_user.save flash[:notice] = "Password successfully updated." redirect_to login_path #profile_url(current_user.login) else flash[:error] = "An error occured, your password was not changed." respond_to do |format| format.js end end else flash[:error] = "New password does not match the password confirmation." @old_password = params[:old_password] respond_to do |format| format.js end end else flash[:error] = "Your old password is incorrect." respond_to do |format| format.js end end end --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
tyliong
2008-Sep-23 11:58 UTC
Re: Need help with AJAX partial not refreshing browser asking to save .js instead
never mind i solved it On Sep 23, 4:46 pm, tyliong <tyli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, when i use the updatepassword action, it does not refresh the ajax > partial but forces the browser to save a file > why does that happen? > > def updatepassword > @user = current_user > return unless request.post? > if User.authenticate(current_user.login, params[:old_password]) > if ((params[:password] == params[:password_confirmation]) && ! > params[:password_confirmation].blank?) > current_user.password_confirmation > params[:password_confirmation] > current_user.password = params[:password] > if current_user.save > flash[:notice] = "Password successfully updated." > redirect_to login_path #profile_url(current_user.login) > else > flash[:error] = "An error occured, your password was > not changed." > respond_to do |format| > format.js > end > end > else > flash[:error] = "New password does not match the > password confirmation." > @old_password = params[:old_password] > respond_to do |format| > format.js > end > end > else > flash[:error] = "Your old password is incorrect." > respond_to do |format| > format.js > end > end > end--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---