controlador de measurements

This commit is contained in:
nopor 2021-07-19 18:32:57 -03:00
parent 1d5ccde58f
commit c5cfa79acb
2 changed files with 11 additions and 1 deletions

View file

@ -0,0 +1,8 @@
class MeasurementsController < ApplicationController
protect_from_forgery with: :null_session
def create
sensor = Sensor.find_or_create_by id: params[:sensor_id]
sensor.measurements.create params.permit(:temperature, :level, :flow, :turbidity, :conductivity, :ph)
end
end

View file

@ -1,3 +1,5 @@
Rails.application.routes.draw do Rails.application.routes.draw do
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html resources :sensors, only: [] do
resources :measurements, only: [:create]
end
end end