first commit
This commit is contained in:
4
app/controllers/application_controller.rb
Normal file
4
app/controllers/application_controller.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
|
||||
allow_browser versions: :modern
|
||||
end
|
||||
0
app/controllers/concerns/.keep
Normal file
0
app/controllers/concerns/.keep
Normal file
26
app/controllers/modbus_controller.rb
Normal file
26
app/controllers/modbus_controller.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
class ModbusController < ApplicationController
|
||||
def index
|
||||
@schedule = Schedule.all
|
||||
end
|
||||
|
||||
def schedule_edit
|
||||
@schedule = Schedule.all
|
||||
end
|
||||
|
||||
def schedule_edit_update
|
||||
error_hours = []
|
||||
|
||||
params[:schedule].each do |id, attributes|
|
||||
schedule = Schedule.find_by(id: id)
|
||||
unless schedule.update(temperature: attributes[:temperature])
|
||||
error_hours << "#{schedule.hour}시"
|
||||
end
|
||||
end
|
||||
|
||||
if error_hours.any?
|
||||
redirect_to modbus_index_path, alert: "#{error_hours.join(', ')}의 온도 업데이트에 실패하였습니다."
|
||||
else
|
||||
redirect_to modbus_index_path, notice: "스케줄이 성공적으로 업데이트되었습니다."
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user