There is a base model and models whose values come from the form as nested parameters. It is necessary to replace the comma with a point in the incoming parameter of type float , so that you can enter into the form both 23.5 and 23.5. But Rails cuts the values after the decimal point. I am trying to do such a check in the model using the before_save , before_validation like this:
before_validation(on: :create) do self.total_area = total_area.to_s.gsub(',', '.').to_f if attribute_present?("total_area") end But here the values come already cropped, only with the whole part. How can you solve this problem without putting the execution of the code in the controller?