[Rails] Accessing @org.id yields internal number, not record id

Michael Wilkes vbsql7 at gmail.com
Sun Jul 30 23:24:58 GMT 2006


With apologies, I can't figure out the simplest thing: How to reference 
a record id instead of the internal memory location of that value. I'm 
new to Ruby but otherwise a veteran VB6/SQL programmer.

My code:

<snip>

     sSQL = "SELECT id, org_name FROM organizations WHERE user_id = 
'#{sUserId}' AND user_password = '#{sPassword}'"

     @org = Organization.find_by_sql sSQL

     if @org

        write_log("Org found. Id = #{@org.id}")


</snip>

My log file contains:

   Org found. Id = 30382648

I am expecting Id to be 1.
There are only two records in the organizations table: 1 and 2.

Thanks for putting me straight!

Michael

-- 
Posted via http://www.ruby-forum.com/.


More information about the Rails mailing list