Files
simple-aircraft-manager-rails/app/controllers/logbook_entries_controller.rb
T
rickyandClaude Opus 5.5 a4b72cf2c1 Part 91 inspection rules: limitations, annual as 100-hour, overrun, clock
- Inspection types say what overdue means: grounds the aircraft, no IFR
  (91.411), no transponder (91.413) or advisory. Overdue limitations show
  as a new LIMITED status ("VFR only", "No transponder") and don't block
  flights under airworthiness enforcement
- "Also counts as": an annual satisfies the 100-hour (91.409(b))
- Overrun allowance: a 100-hour done within 10 hrs of due counts the next
  one from when it was due; done early, from when it was done
- Per-aircraft maintenance clock (tach or Hobbs) for time in service; new
  records default to it (fixes the tach-offset mismatch)
- Status labels Current / Due soon / limitation / Grounded, with the
  91.7 pilot-in-command note
- Migration converts existing types by name; archives carry the new fields

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 10:04:46 -05:00

58 lines
1.8 KiB
Ruby

class LogbookEntriesController < ApplicationController
include AircraftScoped
before_action :require_owner!, except: %i[index show]
before_action :set_entry, only: %i[show edit update destroy]
def index
@query = params[:q]
@log_type = params[:log_type].presence
scope = @aircraft.logbook_entries.search(@query).recent_first.includes(:document)
scope = scope.where(log_type: @log_type) if @log_type
@entries = scope.limit(500)
end
def show; end
def new
@entry = @aircraft.logbook_entries.new(date: Date.current, aircraft_hours_at_entry: @aircraft.current_hours)
end
def create
@entry = @aircraft.logbook_entries.new(entry_params)
if @entry.save
log_event("logbook", "Logbook entry added (#{@entry.date})")
redirect_to aircraft_logbook_entries_path(@aircraft), notice: "Logbook entry added."
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @entry.update(entry_params)
log_event("logbook", "Logbook entry updated (#{@entry.date})")
redirect_to aircraft_logbook_entry_path(@aircraft, @entry), notice: "Logbook entry updated."
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@entry.destroy!
log_event("logbook", "Logbook entry deleted (#{@entry.date})")
redirect_to aircraft_logbook_entries_path(@aircraft), notice: "Logbook entry deleted."
end
private
def set_entry = @entry = @aircraft.logbook_entries.find(params[:id])
def entry_params
p = params.require(:logbook_entry).permit(:log_type, :entry_type, :date, :text, :signoff_person,
:signoff_location, :aircraft_hours_at_entry, :document_id, :page_number)
p[:document_id] = scoped_id(@aircraft.documents, p[:document_id])
p
end
end