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 
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?
···
--
Posted via http://www.ruby-forum.com/\.
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.
···
On Oct 25, 6:20 pm, Daniel Waite <rabbitb...@gmail.com> wrote:
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?
http://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMet\.\.\.
--
Posted viahttp://www.ruby-forum.com/.- 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.
···
On Oct 25, 6:38 pm, baka...@yahoo.com wrote:
On Oct 25, 6:20 pm, Daniel Waite <rabbitb...@gmail.com> wrote:
> 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?
>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.- Hide quoted text -
- Show quoted text -