-
Notifications
You must be signed in to change notification settings - Fork 277
PG::Error: ERROR: zero-length delimited identifier at or near """" -- nifty authentication #160
Description
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 | bridget@cnn.com
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