# Self.id returning an array in 2.3?

**URL:** <https://www.ruby-forum.com/t/self-id-returning-an-array-in-2-3/173733>\
**Category:** Rails\
**Created:** [August 14, 2009, 12:02am UTC](https://www.ruby-forum.com/t/self-id-returning-an-array-in-2-3/173733 "2009-08-14T00:02:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjijackson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e36b37/32.png) [@mjijackson](https://www.ruby-forum.com/u/mjijackson)\
**Post date:** [August 14, 2009, 12:02am UTC](https://www.ruby-forum.com/t/self-id-returning-an-array-in-2-3/173733/1 "2009-08-14T00:02:53Z")

</div>

I’m upgrading from 2.1 to 2.3 and having a small problem with my  
models. It appears that when I use self.id now (say, from inside an  
instance method) I’m getting an array back instead of a string. For  
example, where under 2.1 I would get a “7” I’m now getting a [“7”].  
Why the changed behavior?

---

<div class="post-metadata">

**Author:** ![mjijackson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e36b37/32.png) [@mjijackson](https://www.ruby-forum.com/u/mjijackson)\
**Post date:** [August 14, 2009, 12:05am UTC](https://www.ruby-forum.com/t/self-id-returning-an-array-in-2-3/173733/2 "2009-08-14T00:05:49Z")

</div>

Ugh, nevermind. Figured out what I was doing wrong.

---

<div class="post-metadata">

**Author:** ![mjijackson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e36b37/32.png) [@mjijackson](https://www.ruby-forum.com/u/mjijackson)\
**Post date:** [August 14, 2009, 3:41am UTC](https://www.ruby-forum.com/t/self-id-returning-an-array-in-2-3/173733/3 "2009-08-14T03:41:47Z")

</div>

Quoting mjijackson [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I’m upgrading from 2.1 to 2.3 and having a small problem with my  
> models. It appears that when I use self.id now (say, from inside an  
> instance method) I’m getting an array back instead of a string. For  
> example, where under 2.1 I would get a “7” I’m now getting a [“7”].  
> Why the changed behavior?

My experience is that using the .id method is unreliable. Sometimes it  
is  
interpreted as the object ID which is deprecated instead of the id  
column of  
the database row. self[:id] always works as expected, in my experience.

HTH,  
Jeffrey
