Skip to content

Instantly share code, notes, and snippets.

@eqbal
Created December 6, 2016 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eqbal/948ffcb0b52d818e7301b3874b2bf967 to your computer and use it in GitHub Desktop.
Save eqbal/948ffcb0b52d818e7301b3874b2bf967 to your computer and use it in GitHub Desktop.
# app/forms/entry_form.rb
class EntryForm
include ActiveModel::Model
attr_accessor :distance, :time_period, :date_time,
:status_weather, :status_landform
validates_presence_of :distance, :time_period, :date_time
validates_numericality_of :distance, :time_period
validates :status_weather, inclusion: {
in: EntryStatus::OPTIONS[:weather]
}
validates :status_landform, inclusion: {
in: EntryStatus::OPTIONS[:landform]
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment