# ActiveRecord subclass with manual DB connect ion canâ€™t directly access column variables

**URL:** <https://www.ruby-forum.com/t/activerecord-subclass-with-manual-db-connect-ion-cana-t-directly-access-column-variables/169816>\
**Category:** Rails\
**Created:** [June 9, 2009, 7:10am UTC](https://www.ruby-forum.com/t/activerecord-subclass-with-manual-db-connect-ion-cana-t-directly-access-column-variables/169816 "2009-06-09T07:10:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [June 9, 2009, 7:10am UTC](https://www.ruby-forum.com/t/activerecord-subclass-with-manual-db-connect-ion-cana-t-directly-access-column-variables/169816/1 "2009-06-09T07:10:08Z")

</div>

Hi All,

I’m having a slight issue with one of my Rails models. It’s nothing I  
can’t work around (as I’ve already done so), but I’m interested in the  
actual issue.

Basically, I have an ActiveRecord-based class named “Events” that I’ve  
connected to a remote database using “establish\_connection”. It all  
works fine and I can even perform an “Event.find(:all)”. However, I am  
unable to use any of the convenience (column\_name) methods. I am  
forced to do something like the following:

for each event in Event.find(:all)  
puts event[“Point”]  
puts event[“Timestamp”]  
end  
…instead of

for each event in Event.find(:all)  
puts event.point  
puts event.timestamp  
end  
FYI, when I generated the model I only ran “script/generate model  
event” and absolutely nothing else. I then used “establish\_connection”  
and “set\_table” inside the model in order to get a connection. Besides  
that I’ve done nothing. Again, querying works, but I don’t get my  
convenience access.

Ideas?

Best.

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [June 9, 2009, 10:01am UTC](https://www.ruby-forum.com/t/activerecord-subclass-with-manual-db-connect-ion-cana-t-directly-access-column-variables/169816/2 "2009-06-09T10:01:18Z")

</div>

On Jun 9, 6:09 am, gberz3 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> forced to do something like the following:
> 
> for each event in Event.find(:all)  
> puts event[“Point”]  
> puts event[“Timestamp”]  
> end  
> …instead of
> 
> for each event in Event.find(:all)  
> puts event.point  
> puts event.timestamp

Are the table column names uppercased ?

Fred

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [June 9, 2009, 4:36pm UTC](https://www.ruby-forum.com/t/activerecord-subclass-with-manual-db-connect-ion-cana-t-directly-access-column-variables/169816/3 "2009-06-09T16:36:07Z")

</div>

On Jun 9, 4:00 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Are the table column names uppercased ?
> 
> Fred

Wow, that was absolutely it. Thanks so much!
