# Problem with attribute name

**URL:** <https://www.ruby-forum.com/t/problem-with-attribute-name/118350>\
**Category:** Ruby\
**Created:** [October 25, 2007, 11:15pm UTC](https://www.ruby-forum.com/t/problem-with-attribute-name/118350 "2007-10-25T23:15:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 25, 2007, 11:15pm UTC](https://www.ruby-forum.com/t/problem-with-attribute-name/118350/1 "2007-10-25T23:15:53Z")

</div>

Hi, i’m new at ruby on rails and i have this little problem. I have a  
table named “translations”. Translations has “id”, “message” and  
“description” as attributes. When i try to get information from  
“translations” i write

aux1 = Translation.find\_by\_id(1).description

and no problem with that, but when i write this

aux2= Translation.find\_by\_id(1).message

it return something like #Message:0x4851f70

i’ve tried with Translation.find\_by\_id(1).“message” or  
Translation.find\_by\_id(1).‘message’ but nothing works. Any idea how  
should i rescue the value??. I can’t rename the attribute on data  
base ☹

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 25, 2007, 11:20pm UTC](https://www.ruby-forum.com/t/problem-with-attribute-name/118350/2 "2007-10-25T23:20:56Z")

</div>

unknown wrote:

> Hi, i’m new at ruby on rails and i have this little problem. I have a  
> table named “translations”. Translations has “id”, “message” and  
> “description” as attributes. When i try to get information from  
> “translations” i write
> 
> aux1 = Translation.find\_by\_id(1).description
> 
> and no problem with that, but when i write this
> 
> aux2= Translation.find\_by\_id(1).message
> 
> it return something like #Message:0x4851f70
> 
> i’ve tried with Translation.find\_by\_id(1).“message” or  
> Translation.find\_by\_id(1).‘message’ but nothing works. Any idea how  
> should i rescue the value??. I can’t rename the attribute on data  
> base ☹

Did you design the model? When you see something like Message:0x4851f70,  
that’s usually an instance of a class. Are you using aggregate objects  
for that model?

> **[ActiveRecord::Aggregations::ClassMethods](https://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMethods.html)**
>
> Active Record implements aggregation through a macro-like class method called composed\_of for representing attributes as value objects.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 25, 2007, 11:41pm UTC](https://www.ruby-forum.com/t/problem-with-attribute-name/118350/3 "2007-10-25T23:41:03Z")

</div>

On Oct 25, 6:20 pm, Daniel W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > aux2= Translation.find\_by\_id(1).message  
> > for that model?
> 
> ## [http://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMet](http://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMet)…
> 
> Posted viahttp://www.ruby-forum.com/.- Hide quoted text -
> 
> - Show quoted text -

Hi, i’m working with an existing model. There’s another table named  
“messages” and it’s related with translations. Translations  
belongs\_to :message and message has\_many :translations. Translation  
has a “message\_id” attribute. Maybe there’s a name confusion there,  
between the table and the atribute, but with “description” i have no  
problem.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [October 26, 2007, 1:32am UTC](https://www.ruby-forum.com/t/problem-with-attribute-name/118350/4 "2007-10-26T01:32:43Z")

</div>

On Oct 25, 6:38 pm, removed\_email\_address@domain.invalid wrote:

> > > “translations” i write  
> > > Translation.find\_by\_id(1).‘message’ but nothing works. Any idea how
> 
> > - Show quoted text -
> 
> Hi, i’m working with an existing model. There’s another table named  
> “messages” and it’s related with translations. Translations  
> belongs\_to :message and message has\_many :translations. Translation  
> has a “message\_id” attribute. Maybe there’s a name confusion there,  
> between the table and the atribute, but with “description” i have no  
> problem.- Hide quoted text -
> 
> - Show quoted text -

definitely the problem is with the name, because if i put something  
like

aux2= Translation.find\_by\_id(1).message.name

where “name” is attribute of “messages”, there’s no problem. There’s a  
confusion between the name of the table and the name of the attributes  
from Translation table.
