mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
As POH moment-envelope charts and Garmin Pilot give it. Stored as CG inches (moment x 1000 / weight), shown back as entered with the CG next to each point; switching the units and saving re-reads the numbers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
23 lines
874 B
Ruby
23 lines
874 B
Ruby
# The aircraft's loading stations (arms) and CG envelope, from the POH, for
|
|
# the loading calculator.
|
|
class LoadingSetupsController < ApplicationController
|
|
include AircraftScoped
|
|
before_action :require_owner!
|
|
|
|
def edit
|
|
@setup = @aircraft.loading_setup
|
|
end
|
|
|
|
def update
|
|
permitted = params.fetch(:setup, {}).permit(:fuel_lb_per_gal, :envelope_unit, stations: %i[name arm max fuel], envelope: %i[weight cg])
|
|
@setup = LoadingSetup.from_params(permitted.to_h)
|
|
if @setup.valid?
|
|
@aircraft.update!(loading_stations: @setup.stations_json, cg_envelope: @setup.envelope.map { |w, cg| [ w.to_f, cg.to_f ] })
|
|
log_event("aircraft", "Loading stations and CG envelope updated")
|
|
redirect_to aircraft_weight_balance_records_path(@aircraft), notice: "Loading setup saved."
|
|
else
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
end
|