From 1f8a90ee9bbe43f904e0cf7187ae4ce1b6422261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sat, 21 Apr 2012 09:10:36 -0300 Subject: [PATCH] Refactoring the limit method --- lib/simple_form/inputs/base.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/simple_form/inputs/base.rb b/lib/simple_form/inputs/base.rb index af2f441f..8cff09f9 100644 --- a/lib/simple_form/inputs/base.rb +++ b/lib/simple_form/inputs/base.rb @@ -87,19 +87,22 @@ module SimpleForm end def limit - decimal_or_float? ? decimal_limit : column_limit + if column + decimal_or_float? ? decimal_limit : column_limit + end end def column_limit - column && column.limit + column.limit end + # Add one for decimal point def decimal_limit - column_limit && (column_limit + 1) #for decimal point + column_limit && (column_limit + 1) end def decimal_or_float? - column && column.number? && column.type != :integer + column.number? && column.type != :integer end def nested_boolean_style?