Add & Display Flights
This commit is contained in:
1 parent
796a070af4
commit
022b63fc1a
26 files changed
+395
No files matched your search
@@ -0,0 +1,12 @@
|
||||
class Aircraft < ApplicationRecord
|
||||
has_one :inspection
|
||||
has_many :engine
|
||||
has_many :flights
|
||||
|
||||
validates :reg, presence: true
|
||||
validates :serial, presence: true
|
||||
|
||||
def to_s
|
||||
return reg
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
class Engine < ApplicationRecord
|
||||
belongs_to :aircraft
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
class Flight < ApplicationRecord
|
||||
belongs_to :aircraft
|
||||
validates :to, presence: true
|
||||
validates :from, presence: true
|
||||
validates :tach, presence: true
|
||||
validates :hobbs, presence: true
|
||||
validates :date, presence: true
|
||||
|
||||
def title
|
||||
return aircraft.reg << " - " << date.to_s << " - " << time.to_s
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,3 @@
|
||||
class Inspection < ApplicationRecord
|
||||
belongs_to :aircraft
|
||||
end
|
||||
Reference in new issue
Block a user