[Rails] Accessing @org.id yields internal number, not record id
Hammed Malik
hammed at gmail.com
Mon Jul 31 03:25:27 GMT 2006
org = Organization.find :first, :conditions = ["user_id = ? and password =
?", sUserId, sPassword]
logger.info "Org found. Id = #{@org.id}"
On 7/31/06, Michael Wilkes <vbsql7 at gmail.com> wrote:
>
> 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/.
> _______________________________________________
> Rails mailing list
> Rails at lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060731/11d0640a/attachment.html
More information about the Rails
mailing list