From 4e0a1d2329ba58d48c122df44b48e57bc321546a Mon Sep 17 00:00:00 2001 From: f Date: Thu, 3 Mar 2022 14:12:39 -0300 Subject: [PATCH] `type` es un campo reservado --- app/controllers/readings_controller.rb | 4 +++- db/migrate/20220303170706_change_type.rb | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20220303170706_change_type.rb diff --git a/app/controllers/readings_controller.rb b/app/controllers/readings_controller.rb index bbfe0dd..135df50 100644 --- a/app/controllers/readings_controller.rb +++ b/app/controllers/readings_controller.rb @@ -49,7 +49,9 @@ class ReadingsController < ActionController::API # Procesa los parĂ¡metros de un sensor def sensor_params(sensor) - sensor.permit(:timestamp, :type, :value, :unit, :error) + sensor.permit(:timestamp, :type, :value, :unit, :error).tap do |p| + p[:local_type] = p.delete :type + end end end diff --git a/db/migrate/20220303170706_change_type.rb b/db/migrate/20220303170706_change_type.rb new file mode 100644 index 0000000..ee67a51 --- /dev/null +++ b/db/migrate/20220303170706_change_type.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class ChangeType < ActiveRecord::Migration[6.1] + def change + rename_column :sensors, :type, :local_type + end +end