Files
simple-aircraft-manager-rails/app/controllers/inspection_records_controller.rb
T
rickyandClaude Opus 5.5 38df19c331 Initial commit: Rails port of Simple Aircraft Manager
Rails 8.1 + SQLite rewrite of marbindrakon/simple-aircraft-manager,
designed to self-host as a single container (Solid Queue/Cache/Cable,
Active Storage on disk, Hotwire + importmap, Tailwind).

- Airworthiness engine ported from health/services.py (ADs, grounding
  squawks, inspection recurrency, component replacement)
- Hours updates and flight logs cascading to in-service components,
  optional airworthiness enforcement
- Components, squawks, ADs, inspections, logbook, documents, major
  records, oil/fuel consumption stats and charts, activity log
- Admin/owner/pilot RBAC and public share links (status/maintenance)
- Docker Compose and Kamal deployment, env-driven production config
- Service and integration tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 17:59:08 -05:00

52 lines
1.9 KiB
Ruby

class InspectionRecordsController < ApplicationController
include AircraftScoped
before_action :require_owner!
before_action :set_record, only: %i[edit update destroy]
def new
@record = InspectionRecord.new(aircraft: @aircraft, date: Date.current,
aircraft_hours: @aircraft.tach_time,
inspection_type_id: params[:inspection_type_id])
end
def create
@record = InspectionRecord.new(record_params.merge(aircraft: @aircraft))
if @record.save
log_event("inspection", "Inspection completed: #{@record.inspection_type.name}")
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection recorded."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @record.update(record_params)
log_event("inspection", "Inspection record updated: #{@record.inspection_type.name}")
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection record updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@record.destroy!
log_event("inspection", "Inspection record deleted: #{@record.inspection_type.name}")
redirect_to aircraft_inspections_path(@aircraft), notice: "Inspection record deleted."
end
private
def set_record = @record = InspectionRecord.for_aircraft(@aircraft).find(params[:id])
def record_params
p = params.require(:inspection_record).permit(:inspection_type_id, :date, :aircraft_hours, :notes,
:logbook_entry_id, :component_id)
p[:inspection_type_id] = scoped_id(@aircraft.applicable_inspection_types, p[:inspection_type_id])
p[:logbook_entry_id] = scoped_id(@aircraft.logbook_entries, p[:logbook_entry_id])
p[:component_id] = scoped_id(@aircraft.components, p[:component_id])
p
end
end