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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Andy Koch wrote:> 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 > > > > >dang, it always happens... flipped open Obie''s Rails way and got it.. def id read_attribute(:id).to_i end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
def id self[:id].to_i end On Fri, Mar 14, 2008 at 3:47 PM, Andy Koch <andy.koch-sBIqA0PYact54TAoqtyWWQ@public.gmane.org> wrote:> > 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 > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---