Skip to content

Instantly share code, notes, and snippets.

@bochi
Created April 8, 2021 07:32
Show Gist options
  • Save bochi/29bb1e3ef769854d6251dad99b01e0a3 to your computer and use it in GitHub Desktop.
Save bochi/29bb1e3ef769854d6251dad99b01e0a3 to your computer and use it in GitHub Desktop.
class Source < ApplicationRecord
has_many :reports, :through => :logs
has_many :logs
validates_lengths_from_database
validates :value, :presence => true
def to_s
value
end
# DEPRECATED: use Rails method (no warning because this is called many times)
def self.find_or_create(value)
find_or_create_by(value: value)
end
def skip_strip_attrs
['value']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment