<% content_for :title, "Export for AirTrail" %> <%= render "shared/aircraft_header", aircraft: @aircraft %>
<%= form_with url: aircraft_air_trail_export_path(@aircraft), class: "card card-body space-y-4 lg:col-span-2", data: { turbo: false } do |f| %>

Export flights for AirTrail

<% if @export.errors.any? %>
<% end %>
<%= label_tag :username, "Your AirTrail username", class: "label" %> <%= text_field_tag :username, params[:username].presence || @export.as_json[:users].first[:username], class: "input", required: true, autocomplete: "off" %>

AirTrail assigns the flights to the account with this username (you can also pick the account while importing).

<%= label_tag :aircraft_type, "Aircraft type (ICAO, optional)", class: "label" %> <%= text_field_tag :aircraft_type, params[:aircraft_type].presence || @aircraft.icao_type, class: "input", placeholder: "C150", maxlength: 4 %>

ICAO type designator, e.g. C150, C172, PA28.

Flights
<% all = AirTrailExport.new(@aircraft, username: "preview") %>

<%= pluralize(all.exportable.size, "flight") %> ready to export<% if all.skipped.positive? %>; <%= all.skipped %> skipped because the From or To airport is missing or isn't a code AirTrail can look up<% end %>.

<%= f.submit "Download AirTrail file", class: "btn-primary" %> <% end %>

Importing into AirTrail

  1. In AirTrail, open Settings → Import and choose AirTrail as the source.
  2. Select the downloaded file.
  3. Map any airports AirTrail doesn't recognize (small private fields may need this).

Each flight is imported with you in the pilot seat, the tail number as the registration, and its tach/Hobbs time in the note. Duration comes from Hobbs time (or tach). GPS track logs (GPX, KML or CSV) are included.

Prefer automatic? <%= link_to "Set up AirTrail sync", air_trail_connection_path, class: "link" %> to push new flights as you log them.

Re-importing later is safe with AirTrail's de-duplication left on; repeat legs on the same day and route are numbered #2, #3… so they aren't merged.