Learning Rails following the Rails Tutorial book I have the following question. In chapter 8 at the Exercises part they talk about clearing the password field. I tried several things to do this, but till now didn''t find the solution. Anyone has a tip how to do this? Thanks in advance -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marcel Faas wrote:> Learning Rails following the Rails Tutorial book I have the following > question. > In chapter 8 at the Exercises part they talk about clearing the > password field. > I tried several things to do this, but till now didn''t find the > solution. > Anyone has a tip how to do this?What are you trying to do? (I haven''t seen the book.) What version of Rails are you using? What have you tried?> Thanks in advanceBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
when you have and html form with a password field and some one submits the form but there is an error the server sends the form back with its original values, so the password field has **** in it, what you usually should do is clear it. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
For about the 5th time: PLEASE QUOTE WHEN REPLYING! radhames brito wrote:> when you have and html form with a password field and some one submits > the > form but there is an error the server sends the form back with its > original > values, so the password field has **** in it, what you usually should do > is > clear it.So just set that field to nil in the controller, or perhaps in an after_validation callback. There may be other ways... Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marcel Faas wrote in post #944158:> Learning Rails following the Rails Tutorial book I have the following > question. > In chapter 8 at the Exercises part they talk about clearing the > password field. > I tried several things to do this, but till now didn''t find the > solution. > Anyone has a tip how to do this? > Thanks in advanceThe question comes from <a href="http://railstutorial.org/chapters/sign-up#sec:signup_exercises">railstutorial.org.</a> The exercise in question: Oftentimes signup forms will clear the password field for failed submissions, as shown in Figure 8.12. Modify the Users controller create action to replicate this behavior. Hint: Reset @user.password. The solution: SPOLIERS! In your user controller you defined ''create''. If the save is successful(if @user.save) nothing needs to be changed. If the save is unsuccessful(the ''else'' condition in your code) we render new again with error messages. You must reset @user.password before rendering the ''new'' page by setting it to nil. def create @user = User.new(params[:user]) if @user.save flash[:success] = "Welcome to the Sample App!" redirect_to @user else @title = "Sign up" @user.password = nil @user.password_confirmation = nil render ''new'' end end Note: this code will not work if its placed after render ''new''. It also will not work if you place it in ''def new'' because you aren''t calling that method, which is also why you have to set @title = "Sign up" again. Hope that helps, Dan Luchi Dan-+O/ZBotCRO9Wk0Htik3J/w@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I put: @title = "Sign up" @user.password.clear @user.password_confirmation.clear render "new" Regards. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.