Rails 2.2.2 Ruby 1.8.6 I am developing an application that uses a gem for authentication. When I try and add a new user then the rails code within the gem enters an infinite loop. The author is working on this issue but I would like to obtain the benefit of your collective experience. Given map.resource :account, :controller => ''users'' map.resource :user_session map.resources :users # GET /users/new # GET /users/new.xml def new @user = User.new(params[:user]) if @user.save flash[:notice] = ''User Account Added'' redirect_back_or_default account_url else render :action => new end end # POST /users # POST /users.xml def create @user = User.new(params[:user]) respond_to do |format| if @user.save flash[:notice] = ''User was successfully created.'' format.html { redirect_to(@user) } format.xml { render :xml => @user, :status => :created, :location => @user } else format.html { render :action => "new" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end Here is what happens when the server tries to reach localhost:3000/account/new CACHE (0.0ms) SELECT "users".id FROM "users" WHERE ("users"."login" IS NULL) LIMIT 1 User Exists (0.7ms) SELECT "users".id FROM "users" WHERE ("users"."perishable_token" = ''MNrVzl2G5B3AiVl8d3M2'') LIMIT 1 User Exists (0.4ms) SELECT "users".id FROM "users" WHERE ("users"."persistence_token" ''d0357dc4dd2660ae35cdc910a8b9084d4146f3f590722ae683efd974c22095dedba100af859a15a442621444114fa1cd5d66bff0a62f6585f715de9b1de33429'') LIMIT 1 CACHE (0.0ms) SELECT "users".id FROM "users" WHERE ("users"."login" IS NULL) LIMIT 1 User Exists (0.6ms) SELECT "users".id FROM "users" WHERE ("users"."perishable_token" = ''1Vyz36vPA5frHn8J0XII'') LIMIT 1 User Exists (0.5ms) SELECT "users".id FROM "users" WHERE ("users"."persistence_token" ''b2e81093c5ca6a9078b08077fdd8fee8d3a4d4a9d7a299316ac8a15f4a9ea5c6af649800f1b52ad546c6e099d4b7720906b9ef091d224c09b35cc6c29debc333'') LIMIT 1 I infer from this that when the user is null, as is the case with a new user, then the gem code sets two session tokens that it then checks in its database. The conclusion that I reach is that the client user session is not getting these values set by the application and that, as the user login value remains null, the process repeats ad infinitum. The question becomes: why are tokens not being set in the session? I ran across this thread http://forums.pragprog.com/forums/43/topics/276 and wonder if I may have encountered a related problem. The problem arises whether I use cookie based sessions or AR based sessions. Has anyone else run across this type of problem? How was it resolved. -- 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-/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 12 Dec 2008, at 17:03, James Byrne wrote:> > Rails 2.2.2 > Ruby 1.8.6 > > > I am developing an application that uses a gem for authentication. > When > I try and add a new user then the rails code within the gem enters an > infinite loop. The author is working on this issue but I would like > to > obtain the benefit of your collective experience.which gem ? You haven''t really shown us anything much beyond what a standard scaffolded model would look like. What is the actual code responsible from the log excerpt you pasted below? In addition it would be helpful to see what happened before it got stuck in a loop. Fred> > > Given > map.resource :account, :controller => ''users'' > map.resource :user_session > map.resources :users > > # GET /users/new > # GET /users/new.xml > def new > @user = User.new(params[:user]) > if @user.save > flash[:notice] = ''User Account Added'' > redirect_back_or_default account_url > else > render :action => new > end > end > > # POST /users > # POST /users.xml > def create > @user = User.new(params[:user]) > > respond_to do |format| > if @user.save > flash[:notice] = ''User was successfully created.'' > format.html { redirect_to(@user) } > format.xml { render :xml => @user, :status => :created, > :location => @user } > else > format.html { render :action => "new" } > format.xml { render :xml => @user.errors, :status => > :unprocessable_entity } > end > end > end > > > Here is what happens when the server tries to reach > localhost:3000/account/new > > CACHE (0.0ms) SELECT "users".id FROM "users" WHERE ("users"."login" > IS NULL) LIMIT 1 > User Exists (0.7ms) SELECT "users".id FROM "users" WHERE > ("users"."perishable_token" = ''MNrVzl2G5B3AiVl8d3M2'') LIMIT 1 > User Exists (0.4ms) SELECT "users".id FROM "users" WHERE > ("users"."persistence_token" > ''d0357dc4dd2660ae35cdc910a8b9084d4146f3f590722ae683efd974c22095dedba100af859a15a442621444114fa1cd5d66bff0a62f6585f715de9b1de33429 > '') > LIMIT 1 > CACHE (0.0ms) SELECT "users".id FROM "users" WHERE ("users"."login" > IS NULL) LIMIT 1 > User Exists (0.6ms) SELECT "users".id FROM "users" WHERE > ("users"."perishable_token" = ''1Vyz36vPA5frHn8J0XII'') LIMIT 1 > User Exists (0.5ms) SELECT "users".id FROM "users" WHERE > ("users"."persistence_token" > ''b2e81093c5ca6a9078b08077fdd8fee8d3a4d4a9d7a299316ac8a15f4a9ea5c6af649800f1b52ad546c6e099d4b7720906b9ef091d224c09b35cc6c29debc333 > '') > LIMIT 1 > > > I infer from this that when the user is null, as is the case with a > new > user, then the gem code sets two session tokens that it then checks in > its database. The conclusion that I reach is that the client user > session is not getting these values set by the application and that, > as > the user login value remains null, the process repeats ad infinitum. > The question becomes: why are tokens not being set in the session? > > I ran across this thread http://forums.pragprog.com/forums/43/topics/276 > and wonder if I may have encountered a related problem. > > The problem arises whether I use cookie based sessions or AR based > sessions. > > Has anyone else run across this type of problem? How was it resolved. > -- > 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-/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 Cheung wrote:> On 12 Dec 2008, at 17:03, James Byrne wrote: > >> obtain the benefit of your collective experience. > which gem ? You haven''t really shown us anything much beyond what a > standard scaffolded model would look like. > What is the actual code responsible from the log excerpt you pasted > below? In addition it would be helpful to see what happened before it > got stuck in a loop. > > FredI would rather not publicize the gem name since that might be taken as a public criticism. I changed the users/new controller call from save to save! and what turned up was a bunch of model validation errors. The loop was caused by the controller simply re-rendering the form when the save failed. evidently there is some problem causing the the model validations to be checked before the input form template is rendered. I have communicated this to the gem author. -- 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-/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 12 Dec 2008, at 19:54, James Byrne wrote:> > Frederick Cheung wrote: >> On 12 Dec 2008, at 17:03, James Byrne wrote: >> >>> obtain the benefit of your collective experience. >> which gem ? You haven''t really shown us anything much beyond what a >> standard scaffolded model would look like. >> What is the actual code responsible from the log excerpt you pasted >> below? In addition it would be helpful to see what happened before it >> got stuck in a loop. >> >> Fred > > > I would rather not publicize the gem name since that might be taken > as a > public criticism.Come, on this is open source after all :-) Besides I reckon the gem in question is authlogic Fred> I changed the users/new controller call from save to > save! and what turned up was a bunch of model validation errors. The > loop was caused by the controller simply re-rendering the form when > the > save failed. evidently there is some problem causing the the model > validations to be checked before the input form template is > rendered. I > have communicated this to the gem author. > -- > 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-/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 Cheung wrote:> Come, on this is open source after all :-)Yes, but the problem was with my code, not his. def new @user = User.new(params[:user]) if @user.save flash[:notice] = ''User Account Added'' redirect_back_or_default account_url else render :action => new end end Should have been. def new @user = User.new end Somehow I ended up coding a create method and labelling it as new. -- 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-/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 -~----------~----~----~----~------~----~------~--~---