How to extent activrerecord,just make id to id.to_i

Posted by qichunren on Stack Overflow See other posts from Stack Overflow or by qichunren
Published on 2010-04-29T06:30:21Z Indexed on 2010/04/29 6:37 UTC
Read the original article Hit count: 616

module ActiveRecord module Mixin

alias old_id id

def id
  old_id.to_i
end

def hello
  "hellooooooooooooo"
end

end end

ActiveRecord::Base.send :include, ActiveRecord::Mixin

I make is because:

id column in oracle is number type,not number(10), @user.id return 123.0,not 123,so I would like to do it by extend ar.

But my way above does not work for me,it still show number with dot zero,123.0.

How to make id auto invove id.to_i???

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about Oracle