Parcourir la source

Fixed error with variables

Andrew Kane il y a 8 ans
Parent
commit
56f4d56fed
1 fichiers modifiés avec 12 ajouts et 4 suppressions
  1. 12 4
      app/controllers/blazer/base_controller.rb

+ 12 - 4
app/controllers/blazer/base_controller.rb

@@ -35,16 +35,24 @@ module Blazer
         @bind_vars.each do |var|
           value = params[var].presence
           if value
+            if ["start_time", "end_time"].include?(var)
+              value = value.to_s.gsub(" ", "+") # fix for Quip bug
+            end
+
+            if var.end_with?("_at")
+              begin
+                value = Blazer.time_zone.parse(value)
+              rescue
+                # do nothing
+              end
+            end
+
             if value =~ /\A\d+\z/
               value = value.to_i
             elsif value =~ /\A\d+\.\d+\z/
               value = value.to_f
             end
           end
-          if var.end_with?("_at")
-            value = Blazer.time_zone.parse(value) rescue nil
-          end
-          value.gsub!(" ", "+") if ["start_time", "end_time"].include?(var) # fix for Quip bug
           statement.gsub!("{#{var}}", ActiveRecord::Base.connection.quote(value))
         end
       end