Forum: Ruby on Rails Active Record Attributes using Dot Notation doesn't work

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F0ca9313450626895a1ecec6aa62b3f3?d=identicon&s=25 Stan Shore (Guest)
on 2006-01-09 22:33
I have been having some problems with accessing active record attributes
using dot notation.  Some attributes work, others do not.  The attribute
exists in the database (it is a smallint).  Using breakpointer and IRB I
can see it in the active record:

irb(#<Transition:0x3900f48>):012:0> self
=> #<Transition:0x3900f48
@__bp_line=61, @attributes={"name"=>"ChargeCC",
"created_on"=>"2006-01-04 18:35:06", "created_user"=>"wfe_admin",
"updated_on"=>"2006-01-04 18:35:06", "lock_version"=>"0", "id"=>"33",
"trigger"=>"2", "description"=>nil, "updated_user"=>"wfe_admin",
"workflow_id"=>"51", "time_limit"=>nil}>

When I attempt to access it via dot notation it shows as nil:

irb(#<Transition:0x3900f48>):013:0> self.trigger
=> nil

Using hash notation it's there:

irb(#<Transition:0x3900f48>):014:0> self["trigger"]
=> 2

One other note.  I am accessing this record via a belongs_to/has_many
relationship.  It is the parent. I am displaying the child in a view.
The embedded ruby is asking for info on the parent, ie,

Any idea what is going on?


Stan Shore
This topic is locked and can not be replied to.