2016-02-12 23:52:43 +08:00
|
|
|
class ResultText < ActiveRecord::Base
|
2017-01-05 19:51:14 +08:00
|
|
|
include InputSanitizeHelper
|
|
|
|
|
2016-09-21 21:35:23 +08:00
|
|
|
auto_strip_attributes :text, nullify: false
|
2017-01-05 19:51:14 +08:00
|
|
|
before_validation :sanitize_fields, on: [:create, :update]
|
2016-10-05 23:45:20 +08:00
|
|
|
validates :text,
|
|
|
|
presence: true,
|
2016-11-11 18:42:16 +08:00
|
|
|
length: { maximum: Constants::RICH_TEXT_MAX_LENGTH }
|
2016-02-12 23:52:43 +08:00
|
|
|
validates :result, presence: true
|
|
|
|
|
|
|
|
belongs_to :result, inverse_of: :result_text
|
2017-01-05 19:51:14 +08:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def sanitize_fields
|
|
|
|
self.text = sanitize_input(text)
|
|
|
|
end
|
2016-02-12 23:52:43 +08:00
|
|
|
end
|