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 Pragmatic Bookshelf: By Developers, For Developers 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.