Forum: Ruby on Rails ActiveRecord subclass with manual DB connect ion can’t directly access column variables.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ecbfce0d407ac7af6e33c4c575315ece?d=identicon&s=25 Michael W. (gberz3)
on 2009-06-09 07:10
(Received via mailing list)
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.
Frederick Cheung (Guest)
on 2009-06-09 10:01
(Received via mailing list)
On Jun 9, 6:09 am, gberz3 <gbe...@gmail.com> 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
Ecbfce0d407ac7af6e33c4c575315ece?d=identicon&s=25 Michael W. (gberz3)
on 2009-06-09 16:36
(Received via mailing list)
On Jun 9, 4:00 am, Frederick Cheung <frederick.che...@gmail.com>
wrote:
> Are the table column names uppercased ?
>
> Fred


Wow, that was absolutely it.  Thanks so much!
This topic is locked and can not be replied to.