controlador de measurements
This commit is contained in:
parent
1d5ccde58f
commit
c5cfa79acb
2 changed files with 11 additions and 1 deletions
8
app/controllers/measurements_controller.rb
Normal file
8
app/controllers/measurements_controller.rb
Normal 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
|
|
@ -1,3 +1,5 @@
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue