Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Tiago Fernandes's latest activity

Sunday, December 19 2010
6103 average() returns integer values instead of decimals was updated in Ruby on Rails
  • Tiago Fernandes
    Tiago Fernandes commented at 11:53 PM
         # Casts value (which is a String) to an appropriate instance.
          def type_cast(value)
            return nil if value.nil?
            puts "Class: #{type.clas...
  • Tiago Fernandes
    Tiago Fernandes commented at 11:52 PM

    Think that the bug is related with type_cast method in the schema_definitions.rb

    If you create a second field rating2 of type float, and test Post.average(:rati...

  • Tiago Fernandes
    Tiago Fernandes commented at 1:11 AM

    Did a quick test with a fresh rails install and sqlite3, and the calculated value is different for columns of type integer and float.

  • Tiago Fernandes
    Tiago Fernandes commented at 1:10 AM

    Think this bug is related with the type cast of the calculated value. the activerecord tries to cast the value based on the type of the column.

    If the rating co...