Newb here. I have a form and a value that is being displayed ... and I have no idea where the value came from. I have done a <%= debugger; '''' %> in the form and, indeed, the debugger stops at the statement. I have tried to trace through the code to see where the value came from ... and I gave up. So ... what in Rails initializes the fields of a form? -- 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.
Ralph Shnelvar wrote:> Newb here. > > I have a form and a value that is being displayed ... and I have no idea > where the value came from. > > I have done a > <%= debugger; '''' %> > in the form and, indeed, the debugger stops at the statement. > > I have tried to trace through the code to see where the value came from > ... and I gave up. >You''re going to have to describe the problem in more detail, with actual code, if you want help. And what do your tests say?> > > > So ... what in Rails initializes the fields of a form?If you''re using form_for -- and you didn''t say if you were! -- then the form is initialized from the supplied model object. 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.
Marnen Laibow-Koser wrote:> Ralph Shnelvar wrote: >> Newb here. >> >> I have a form and a value that is being displayed ... and I have no idea >> where the value came from. >> >> I have done a >> <%= debugger; '''' %> >> in the form and, indeed, the debugger stops at the statement. >> >> I have tried to trace through the code to see where the value came from >> ... and I gave up. >> > > You''re going to have to describe the problem in more detail, with actual > code, if you want help. And what do your tests say? > >> >> >> >> So ... what in Rails initializes the fields of a form? > > If you''re using form_for -- and you didn''t say if you were! -- then the > form is initialized from the supplied model object.Ok ... here''s the code --------------------------------------------- \zauth\app\views\users\new.html.erb <fieldset> <legend>Signup for eMeantime Membership</legend> <%= error_messages_for :user %> <% form_for :user, :url => users_path do |f| -%> <p><label for="login">Login:</label><br/> <%= f.text_field :login %> <br/> <cite>Ex., aedenfield</cite> <p><label for="email">Email:</label><br/> <%= debugger; '''' -%> <%= f.text_field :email %><br/> <cite>Ex., amy-5wPc2VS3KtNfmgfxC/sS/w@public.gmane.org A valid email is required for an active account.</cite> <p><label for="password">Password:</label><br/> <%= f.password_field :password %><br/> <cite> Enter the password that is between 4 and 40 characters in length.</cite> <p><label for="password_confirmation">Confirm Password:</label><br/> <%= f.password_field :password_confirmation %><br/> <cite>Enter the same password as above.</cite> <p><%= submit_tag ''Sign up'' %></p> <% end -%> </fieldset> ------------------------------------------------------------ \zauth\app\controllers\users_controller.rb class UsersController < ApplicationController # Protect these actions behind an admin login # before_filter :admin_required, :only => [:suspend, :unsuspend, :destroy, :purge] before_filter :find_user, :only => [:suspend, :unsuspend, :destroy, :purge] # render new.rhtml def new end def create puts at_file_line_msg(__FILE__, __LINE__) cookies.delete :auth_token # protects against session fixation attacks, wreaks havoc with # request forgery protection. # uncomment at your own risk # reset_session @user = User.new(params[:user]) raise ActiveRecord::RecordInvalid.new(@user) unless @user.valid? @user.register! flash[:notice] = "Thanks for signing up!" rescue ActiveRecord::RecordInvalid render :action => ''new'' end def activate self.current_user = params[:activation_code].blank? ? :false : User.find_by_activation_code(params[:activation_code]) if logged_in? && !current_user.active? current_user.activate! flash[:notice] = "Signup complete!" end redirect_back_or_default(''/'') end def suspend @user.suspend! redirect_to users_path end def unsuspend @user.unsuspend! redirect_to users_path end def destroy @user.delete! redirect_to users_path end def purge @user.destroy redirect_to users_path end def change_password 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 profile_url(current_user.login) else flash[:alert] = "Password not changed" end else flash[:alert] = "New Password mismatch" @old_password = params[:old_password] end else flash[:alert] = "Old password incorrect" end end #gain email address def forgot_password return unless request.post? if @user = User.find_by_email(params[:user][:email]) @user.forgot_password @user.save redirect_back_or_default(''/'') flash[:notice] = "A password reset link has been sent to your email address" else flash[:alert] = "Could not find a user with that email address" end end #reset password def reset_password @user = User.find_by_password_reset_code(params[:id]) return if @user unless params[:user] if ((params[:user][:password] && params[:user][:password_confirmation]) && !params[:user][:password_confirmation].blank?) self.current_user = @user #for the next two lines to work current_user.password_confirmation = params[:user][:password_confirmation] current_user.password = params[:user][:password] @user.reset_password flash[:notice] = current_user.save ? "Password reset success." : "Password reset failed." redirect_back_or_default(''/'') else flash[:alert] = "Password mismatch" end end protected def find_user @user = User.find(params[:id]) end end ------------------------------------------------------------ I apologize for the length of the code but since I am lost as to where in the model the code initializes the form ... I provided everything. The fields that seem to be inappropriately initialized are the fields associated with :email (definitely) and :password (maybe). The :password field has big dots in it ... and it _may_ be initialized ... I can''t tell. -- 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.
Ralph Shnelvar wrote:> Marnen Laibow-Koser wrote: >> Ralph Shnelvar wrote: >>> Newb here. >>> >>> I have a form and a value that is being displayed ... and I have no idea >>> where the value came from. >>> >>> I have done a >>> <%= debugger; '''' %> >>> in the form and, indeed, the debugger stops at the statement. >>> >>> I have tried to trace through the code to see where the value came from >>> ... and I gave up. >>> >> >> You''re going to have to describe the problem in more detail, with actual >> code, if you want help. And what do your tests say? >> >>> >>> >>> >>> So ... what in Rails initializes the fields of a form? >> >> If you''re using form_for -- and you didn''t say if you were! -- then the >> form is initialized from the supplied model object. > > > > Ok ... here''s the code > > --------------------------------------------- > > \zauth\app\views\users\new.html.erbNote: This isn''t relevant to the issue at hand, but I *highly* recommend Haml instead of ERb.> <fieldset> > <legend>Signup for eMeantime Membership</legend> > <%= error_messages_for :user %> > > <% form_for :user, :url => users_path do |f| -%> > > <p><label for="login">Login:</label><br/> > <%= f.text_field :login %> <br/> > <cite>Ex., aedenfield</cite> > > <p><label for="email">Email:</label><br/> > <%= debugger; '''' -%> > <%= f.text_field :email %><br/> > <cite>Ex., amy-5wPc2VS3KtNfmgfxC/sS/w@public.gmane.org A valid email is required for an active > account.</cite><cite> is for book titles, not hints. Learn to use HTML properly.> > <p><label for="password">Password:</label><br/> > <%= f.password_field :password %><br/>This all looks fine. [...]> I apologize for the length of the code but since I am lost as to where > in the model the code initializes the form ... I provided everything.Read the form_for docs and the Rails guides.> > > The fields that seem to be inappropriately initialized are the fields > associated with :email (definitely) and :password (maybe).Initialized with what? You''ve provided everything but the essential info. :)> > The :password field has big dots in it ... and it _may_ be initialized > ... I can''t tell.What do you mean, you can''t tell? What is the generated HTML like? 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.
Marnen Laibow-Koser wrote:> Ralph Shnelvar wrote: >> Marnen Laibow-Koser wrote:>>>> So ... what in Rails initializes the fields of a form? >>>Ok ... this code is/was provided as example code from http://www.rubyplus.org/episodes/20-Extended-RESTful-Authentication-Rails-2-App.html I downloaded the movie and the source code ... neither of which seem to be available any more Attached, a screenshot. Where "Dave" (I presume "Dave Thomas") came from is completely beyond me.>>> If you''re using form_for -- and you didn''t say if you were! -- then the >>> form is initialized from the supplied model object. >> >> >> >> Ok ... here''s the code >> >> --------------------------------------------- >> >> \zauth\app\views\users\new.html.erb > > Note: This isn''t relevant to the issue at hand, but I *highly* recommend > Haml instead of ERb. > >> <fieldset> >> <legend>Signup for eMeantime Membership</legend> >> <%= error_messages_for :user %> >> >> <% form_for :user, :url => users_path do |f| -%> >> >> <p><label for="login">Login:</label><br/> >> <%= f.text_field :login %> <br/> >> <cite>Ex., aedenfield</cite> >> >> <p><label for="email">Email:</label><br/> >> <%= debugger; '''' -%> >> <%= f.text_field :email %><br/> >> <cite>Ex., amy-5wPc2VS3KtNfmgfxC/sS/w@public.gmane.org A valid email is required for an active >> account.</cite> > > <cite> is for book titles, not hints. Learn to use HTML properly.Thank you ... but I did not write that code. I believe a person by the name of Bala Paranj (http://www.rubyplus.org/episodes/20-Extended-RESTful-Authentication-Rails-2-App.html) created a video tutorial as well as source code. I downloaded both ... both seem to be inaccessible now.> >> >> <p><label for="password">Password:</label><br/> >> <%= f.password_field :password %><br/> > > This all looks fine. > > [...] >> I apologize for the length of the code but since I am lost as to where >> in the model the code initializes the form ... I provided everything. > > Read the form_for docs and the Rails guides.What do you think I''ve been doing for the last several weeks?> >> >> >> The fields that seem to be inappropriately initialized are the fields >> associated with :email (definitely) and :password (maybe). > > Initialized with what? You''ve provided everything but the essential > info. :) >> >> The :password field has big dots in it ... and it _may_ be initialized >> ... I can''t tell. > > What do you mean, you can''t tell? What is the generated HTML like?The screen shot (attached) source looks like this: --------------------------------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-US"> <head> <title>Killer App of 2008</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link href="/stylesheets/style.css?1198972466" media="screen" rel="stylesheet" type="text/css" /> <script src="/javascripts/prototype.js?1261074000" type="text/javascript"></script> <script src="/javascripts/effects.js?1261074000" type="text/javascript"></script> <script src="/javascripts/dragdrop.js?1261074000" type="text/javascript"></script> <script src="/javascripts/controls.js?1261074000" type="text/javascript"></script> <script src="/javascripts/application.js?1261074000" type="text/javascript"></script> </head> <body> <!-- ##### Header ##### --> <div id="header"> <div class="superHeader"> <span>Welcome Guest</span> </div> <div class="midHeader"> <h1 class="headerTitle" lang="la">Killer App of 2008</h1> <div class="headerSubTitle" title="Killer App of 2008"> How can I help you? </div> </div> <div class="subHeader"> <span class="doNotDisplay">Navigation:</span> <a href="http://localhost:3000/signup">Signup</a> | <a href="http://localhost:3000/login">Login</a> | <a href="contact">Contact Us</a> </div> </div> <!-- ##### Main Copy ##### --> <div id="main-copy"> <fieldset> <legend>Signup for eMeantime Membership</legend> <form action="/users" method="post"><div style="margin:0;padding:0"><input name="authenticity_token" type="hidden" value="f855b5f22afb03895860d163968b48a2ec9973cb" /></div> <p><label for="login">Login:</label><br/> <input id="user_login" name="user[login]" size="30" type="text" /> <br/> <cite>Ex., aedenfield</cite> <p><label for="email">Email:</label><br/> <input id="user_email" name="user[email]" size="30" type="text" /><br/> <cite>Ex., amy-5wPc2VS3KtNfmgfxC/sS/w@public.gmane.org A valid email is required for an active account.</cite> <p><label for="password">Password:</label><br/> <input id="user_password" name="user[password]" size="30" type="password" /><br/> <cite> Enter the password that is between 4 and 40 characters in length.</cite> <p><label for="password_confirmation">Confirm Password:</label><br/> <input id="user_password_confirmation" name="user[password_confirmation]" size="30" type="password" /><br/> <cite>Enter the same password as above.</cite> <p><input name="commit" type="submit" value="Sign up" /></p> </form> </fieldset> </div> <!-- ##### Footer ##### --> <div id="footer"> <div> Copyright © 2009 - 2010, eMeantimeo.com </div> </div> </body> </html> --------------------------------------- Attachments: http://www.ruby-forum.com/attachment/4338/snapshot001.jpg -- 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.
Hello all, Sorry for jump in.. But, I have to say “I''m totally lost in this thread..." What is the *exactly* question from the very beginning? Do you mean those "Dave" and the "Passwords" ? -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ralph Shnelvar wrote:> Marnen Laibow-Koser wrote: >> Ralph Shnelvar wrote: >>> Marnen Laibow-Koser wrote: > >>>>> So ... what in Rails initializes the fields of a form? >>>> > > Ok ... this code is/was provided as example code from > http://www.rubyplus.org/episodes/20-Extended-RESTful-Authentication-Rails-2-App.htmlYeah, I thought I saw restful_authentication spew in your User model. I would strongly advise against using restful_authentication, precisely because it clutters up your models. Try Authlogic instead.> > I downloaded the movie and the source code ... neither of which seem to > be available any more > > Attached, a screenshot. Where "Dave" (I presume "Dave Thomas") came > from is completely beyond me.Well, it''s not in your HTML. Unless you''ve got some JS in there, my best guess is that it''s coming from your Web browser, which is probably trying to "helpfully" autofill usernames and passwords. Try a different browser or a different computer, and I''ll bet you these entries won''t be there. I don''t think this is coming from Rails.>>> >>>[...]>>> <cite>Ex., amy-5wPc2VS3KtNfmgfxC/sS/w@public.gmane.org A valid email is required for an active >>> account.</cite> >> >> <cite> is for book titles, not hints. Learn to use HTML properly. > > Thank you ... but I did not write that code.Whoever wrote it, it''s bad and should be corrected. [...]>> Read the form_for docs and the Rails guides. > > What do you think I''ve been doing for the last several weeks?I wouldn''t venture to guess. :) 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.
> Well, it''s not in your HTML. Unless you''ve got some JS in there, my > best guess is that it''s coming from your Web browser, which is probably > trying to "helpfully" autofill usernames and passwords. Try a different > browser or a different computer, and I''ll bet you these entries won''t be > there. I don''t think this is coming from Rails.Yup ... I installed the Authologic tutorial app http://github.com/binarylogic/authlogic_example and lo and behold ... Dave and his password showed up again. That Dave guy is sure popular. So I tried both apps on IE instead of FireFox and ... no Dave. Goes to show you, if you can''t find a bug then either you''re looking in the wrong place or it isn''t a bug. Thank you for suggesting a different browser.> >>>> >>>> > [...] >>>> <cite>Ex., amy-5wPc2VS3KtNfmgfxC/sS/w@public.gmane.org A valid email is required for an active >>>> account.</cite> >>> >>> <cite> is for book titles, not hints. Learn to use HTML properly. >> >> Thank you ... but I did not write that code. > > Whoever wrote it, it''s bad and should be corrected.What tag do you suggest for a sample email address?> > [...] >>> Read the form_for docs and the Rails guides. >> >> What do you think I''ve been doing for the last several weeks? > > I wouldn''t venture to guess. :)It''s not what you are thing. OK, so why is restful authentication not as good as authlogic? The sample from Bala Paranj offers email confirmation and the sample from Authlogic does not. Am I looking at a ton of work to implement the email confirmation via Authlogic? -- 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.
Ralph Shnelvar wrote:>> Well, it''s not in your HTML. Unless you''ve got some JS in there, my >> best guess is that it''s coming from your Web browser, which is probably >> trying to "helpfully" autofill usernames and passwords. Try a different >> browser or a different computer, and I''ll bet you these entries won''t be >> there. I don''t think this is coming from Rails. > > Yup ... I installed the Authologic tutorial app > http://github.com/binarylogic/authlogic_example > and lo and behold ... Dave and his password showed up again. > > That Dave guy is sure popular. > > So I tried both apps on IE instead of FireFox and ... no Dave. > > Goes to show you, if you can''t find a bug then either you''re looking in > the wrong place or it isn''t a bug. > > Thank you for suggesting a different browser.You''re most welcome!> >> >>>>> >>>>> >> [...] >>>>> <cite>Ex., amy-5wPc2VS3KtNfmgfxC/sS/w@public.gmane.org A valid email is required for an active >>>>> account.</cite> >>>> >>>> <cite> is for book titles, not hints. Learn to use HTML properly. >>> >>> Thank you ... but I did not write that code. >> >> Whoever wrote it, it''s bad and should be corrected. > > What tag do you suggest for a sample email address?There is probably no tag made for the purpose (except perhaps <samp>), so I might use <span class=''hint''>.> >> >> [...] >>>> Read the form_for docs and the Rails guides. >>> >>> What do you think I''ve been doing for the last several weeks? >> >> I wouldn''t venture to guess. :) > > It''s not what you are thing. >:D> > OK, so why is restful authentication not as good as authlogic?I already explained that: it puts all sorts of crap in your User model instead of keeping it separate. Authlogic is also more flexible and uses a better architecture.> The > sample from Bala Paranj offers email confirmation and the sample from > Authlogic does not.Authlogic can do that.> > Am I looking at a ton of work to implement the email confirmation via > Authlogic?I don''t believe so. 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.
Seemingly Similar Threads
- rescue_from ActionController::RoutingError II
- Authlogic Password confirmation is too short Error. NEED HELP.
- form_for, submit, and parameters disappearing
- NoMethodError in User sessionsController#new
- tips on how to write a controller test for models associated with currently logged in user