Override AR default attribute accessors

anybody know how one overrides the default AR attribute methods?

ex.

c = Group
c.id
=> 3.0

c.id.to_i
=> 3

reason is, I’m using Firebird DB which some tables return decimals for
id, I’d like to override that behavior so calling “c.id” returns an
integer

c = Group
c.id
=> 3

thanks

Andy K. wrote:

reason is, I’m using Firebird DB which some tables return decimals for

dang, it always happens…

flipped open Obie’s Rails way and got it…

def id
read_attribute(:id).to_i
end

def id
self[:id].to_i
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs