Files
simple-aircraft-manager-rails/app/controllers/major_records_controller.rb
T
rickyandClaude Opus 5.5 89ed0a76f9 Move all user-facing text into config/locales/en.yml for localization
- Views use lazy t(".key") lookups; sentences with values or links stay
  whole (interpolation, _html keys); counts use one/other plurals
- Stored-value labels (statuses, types, priorities...) are LabelSets read
  from labels: in the current locale; field names and validation messages
  under activerecord:; flash and activity text under flash:
- Services, models, helpers, mailer subjects, the logbook PDF, procedures
  templates, records package README and transcription warnings localized;
  the PDF reuses LogbookEntry#certification_statement instead of a copy
- Scripts read js: strings from a JSON tag via app/javascript/i18n.js
- Dates through I18n.l (app, weekday, month_year, long formats); html lang
  follows the locale
- APP_LOCALE picks the language (falls back to English); missing
  translations raise in development and tests
- README: Translating section and APP_LOCALE

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 22:08:20 -05:00

60 lines
2.2 KiB
Ruby

class MajorRecordsController < ApplicationController
include AircraftScoped
before_action :require_owner!, except: %i[index show]
before_action :set_record, only: %i[show edit update destroy]
def index
@records = @aircraft.major_records.recent_first.includes(:component)
end
def show; end
def new
@record = @aircraft.major_records.new(record_type: params[:type] || "repair", date_performed: Date.current,
aircraft_hours: @aircraft.current_hours)
end
def create
@record = @aircraft.major_records.new(record_params)
if @record.save
log_event("major_record", t("flash.major_records.added", type_label: @record.type_label, title: @record.title))
redirect_to aircraft_major_records_path(@aircraft), notice: t("flash.major_records.record_added")
else
render :new, status: :unprocessable_entity
end
end
def edit; end
def update
if @record.update(record_params)
log_event("major_record", t("flash.major_records.updated", type_label: @record.type_label, title: @record.title))
redirect_to aircraft_major_record_path(@aircraft, @record), notice: t("flash.major_records.record_updated")
else
render :edit, status: :unprocessable_entity
end
end
def destroy
@record.destroy!
log_event("major_record", t("flash.major_records.deleted", type_label: @record.type_label, title: @record.title))
redirect_to aircraft_major_records_path(@aircraft), notice: t("flash.major_records.record_deleted")
end
private
def set_record = @record = @aircraft.major_records.find(params[:id])
def record_params
p = params.require(:major_record).permit(
:record_type, :title, :description, :date_performed, :performed_by, :component_id,
:form_337_document_id, :stc_number, :stc_holder, :stc_document_id, :logbook_entry_id,
:aircraft_hours, :has_ica, :ica_notes, :notes
)
p[:component_id] = scoped_id(@aircraft.components, p[:component_id])
p[:logbook_entry_id] = scoped_id(@aircraft.logbook_entries, p[:logbook_entry_id])
%i[form_337_document_id stc_document_id].each { |k| p[k] = scoped_id(@aircraft.documents, p[k]) }
p
end
end