Bdc4a6aa272bea6d585fbe8be6d1ba38

er_quantitative, pr_quantitative.. are decimal columns in the database. When rails displays them in a text input there is a decimal point shown. I don't want to display the decimal point. Since we're porting the system from coldfusion to rails I would rather not change the column type and/or the js validation verifying this field is all numbers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  %w(er_quantitative pr_quantitative p53_quantitative fish_quantitative oncotype_quantitative).each do |field|
    class_eval <<-RUBY
      def #{field}_s
        if #{field}.blank?
          #{field}
        else
          '%d' % #{field}
        end
      end
      def #{field}_s=(val)
        #{field} =
          if #{field}.blank?
            #{field}
          else
            val.to_i
          end
      end
    RUBY
  end

Refactorings

No refactoring yet !

Your refactoring





Format Copy from initial code

or Cancel