You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.
I'm getting this error on what had been a perfectly functional authentication system using nifty auth.
Could not log "sql.active_record" event. NoMethodError: undefined method `name' for nil:NilClass
PG::Error: ERROR: zero-length delimited identifier at or near """"
LINE 1: SELECT "users".* FROM "users" WHERE "users"."" = $1 LIMIT
This happens when the current_user method is called. What's odd is that in rails db, this works:
dgap=> select first_name, email from users where id=1;
-[ RECORD 1 ]--------------------------------------
first_name | bridget
email | [email protected]
but in console I get the same error as above:
ruby -> User.find(1)
Could not log "sql.active_record" event. NoMethodError: undefined method `name' for nil:NilClass
ActiveRecord::StatementInvalid: PG::Error: ERROR: zero-length delimited identifier at or near """"
LINE 1: SELECT "users".* FROM "users" WHERE "users"."" = $1 LIMIT ...
and
ruby -> User
returns the model's attributes.
It's as if it suddenly can't tell what column to id with. All required columns contain values. This started happening after I made a back up of the users table,
dgap => create table users_bak as select * from users;
Then I removed some users:
dgap => delete from users where id > 1;
The user with an id of one is definitely still there.
So I restored the table:
dgap=> alter table users rename to users_borken;
dgap=> alter table users_bak rename to users;
and I'm still getting the same errors.
lib/controller_authentication.rb:
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
Untouched.
Thoughts? Any insight would be greatly appreciated.
Steve
The text was updated successfully, but these errors were encountered:
Also, if I log out, I can use the site, mostly. It's only after logging in that I'm getting the error reported above. There is a session id, logger.debug "session is #{session}\n\n\n" shows:
session is {"session_id"=>"0513ea4815ba2bd011884ecc59f25014", "_csrf_token"=>"dOqfBdirnnLcGh40hIYyrOGJSHevCqsE/rU3uvDt/6Q="}
However, if I go to ~/users/new I get a new exception:
Unknown primary key for table users in model User. The offending line:
Hi,
I'm getting this error on what had been a perfectly functional authentication system using nifty auth.
Could not log "sql.active_record" event. NoMethodError: undefined method `name' for nil:NilClass
PG::Error: ERROR: zero-length delimited identifier at or near """"
LINE 1: SELECT "users".* FROM "users" WHERE "users"."" = $1 LIMIT
This happens when the current_user method is called. What's odd is that in rails db, this works:
dgap=> select first_name, email from users where id=1;
-[ RECORD 1 ]--------------------------------------
first_name | bridget
email | [email protected]
but in console I get the same error as above:
ruby -> User.find(1)
Could not log "sql.active_record" event. NoMethodError: undefined method `name' for nil:NilClass
ActiveRecord::StatementInvalid: PG::Error: ERROR: zero-length delimited identifier at or near """"
LINE 1: SELECT "users".* FROM "users" WHERE "users"."" = $1 LIMIT ...
and
ruby -> User
returns the model's attributes.
It's as if it suddenly can't tell what column to id with. All required columns contain values. This started happening after I made a back up of the users table,
dgap => create table users_bak as select * from users;
Then I removed some users:
dgap => delete from users where id > 1;
The user with an id of one is definitely still there.
So I restored the table:
dgap=> alter table users rename to users_borken;
dgap=> alter table users_bak rename to users;
and I'm still getting the same errors.
lib/controller_authentication.rb:
def current_user
@current_user ||= User.find(session[:user_id]) if session[:user_id]
end
Untouched.
Thoughts? Any insight would be greatly appreciated.
Steve
The text was updated successfully, but these errors were encountered: