validaciones
This commit is contained in:
parent
14eeab50e2
commit
535191d26d
3 changed files with 7 additions and 0 deletions
|
@ -4,4 +4,6 @@ class Arduino < ApplicationRecord
|
||||||
belongs_to :raspberry
|
belongs_to :raspberry
|
||||||
belongs_to :reading
|
belongs_to :reading
|
||||||
has_many :sensors
|
has_many :sensors
|
||||||
|
|
||||||
|
validates_presence_of :local_id
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,4 +3,7 @@
|
||||||
class Raspberry < ApplicationRecord
|
class Raspberry < ApplicationRecord
|
||||||
has_many :readings
|
has_many :readings
|
||||||
has_many :arduinos
|
has_many :arduinos
|
||||||
|
|
||||||
|
validates_presence_of :name
|
||||||
|
validates_uniqueness_of :name
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,4 +2,6 @@
|
||||||
|
|
||||||
class Sensor < ApplicationRecord
|
class Sensor < ApplicationRecord
|
||||||
belongs_to :arduino
|
belongs_to :arduino
|
||||||
|
|
||||||
|
validates_presence_of :timestamp, :local_type, :value, :unit
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue