Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Alex Moore
RE: OraNumber [ reply ]  
2008-07-08 03:08
Thankyou for your solution and prompt reply Kubo!
Worked like a charm.

By: Kubo Takehiro
RE: OraNumber [ reply ]  
2008-07-07 14:15
> The issue I have is that OraNumber.new(1).to_json #=> {}
> Is this a known issue?

No. ruby-oci8 doesn't define OraNumber#to_json. Probably the method is handled by Object#to_json which is added by activesupport.
http://github.com/rails/rails/tree/master/activesupport/lib/active_support/json/encoders

Adding the following code to the end of oci8.rb fixes the problem.

class OraNumber
def to_json(options=nil)
to_s
end
end

By: Alex Moore
OraNumber [ reply ]  
2008-07-07 07:23
I don't know if this is the right place for this question, if not please do tell.

The issue I have is that OraNumber.new(1).to_json #=> {}
Is this a known issue?


The way i got to this was because I have to do something like
MyModel.find_by_sql('Select some_float_number from etc')
and instead of returning FixedNum like i expected i got OraNumber instead. to_json works fine on fixednum but not on OraNumber.

Any suggestions?