ruby on rails - Why is ActiveRecord/PostgreSQL not finding my data in the database? -


i'm sure simple i'm overlooking since i've been dealing strange issue few days i'm asking help.

here apps setup , issue:

a rails 3.2.13 app pg gem , following db scheme:

create_table "clients", :force => true |t|   t.string   "uuid"   t.string   "private_key"   t.datetime "created_at",  :null => false   t.datetime "updated_at",  :null => false end  add_index "clients", ["private_key"], :name => "index_clients_on_private_key" add_index "clients", ["uuid"], :name => "index_clients_on_uuid" 

i have 2 rows in "clients" database. pictured below:

enter image description here

the issue

when perform simple "select * clients;" using rubymine database console rows pictured in screen shot above. when perform "select * clients id = 11;" row, there. however, issue when try perform "select * clients private_key = "mkrbnuzbqzutmzvdri00nzq3lthfnjetnji4otheruqzqkrf";" fails , shows following in console output...

sql> select * clients private_key = "mkrbnuzbqzutmzvdri00nzq3lthfnjetnji4otheruqzqkrf" [2013-04-17 20:09:51] [42703] error: column "mkrbnuzbqzutmzvdri00nzq3lthfnjetnji4otheruqzqkrf" not exist   position: 43 

i've tried pulling row out of db utilizing active record helper methods...

client.exists?(:private_key => token) client.find_by_private_key(token) 

however, nothing works, never finds record exist in db. have idea going on here? need able utilize active record helpers, "client.exists?(:private_key => token)" able check , see if supplied token exists in db.

thanks help!

update 4/18/13 @ 9:30am

i tried client.find(12) see if find record id, , works. doesn't me understand why still can't use client.exists?(:private_key => token) or client.find_by_private_key(token).

update 4/19/13 @ 9:15am

the answer problem code generating private_key value adding return/white space end of value. when trying query db row based on private_key failing find anything.

to fix problem added gsub end of code generates private_key, this...

private_key = securityhelper.encrypt_private_key(client_uuid).gsub(/\s+/, "") 

this strips white space generated private key , solved problem.

have tried

client.exists?(:private_key => "mkrbnuzbqzutmzvdri00nzq3lthfnjetnji4otheruqzqkrf") 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -