summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authoralpaca-tc <alpaca-tc@alpaca.tc>2017-04-16 23:28:26 +0900
committerEugen <eugen@zeonfederated.com>2017-04-16 16:28:26 +0200
commitde72db99fac56fa06fccdab443a1c4e44e8fb985 (patch)
treee84017fd58fe9e08f320be87685bd62556beb609 /app
parent77d1447ac407395a87b758d35eda2b4de8ca9413 (diff)
Add presence validation to Import (#1928)
``` *An* `ActiveRecord::StatementInvalid` *occurred while* `POST </settings/import>` *was processed by* `imports#create` Exception ---------------- PG::NotNullViolation: ERROR: null value in column "type" violates not-null constraint ```
Diffstat (limited to 'app')
-rw-r--r--app/models/import.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/import.rb b/app/models/import.rb
index 3013bc50eb4..85f6ca4bdf5 100644
--- a/app/models/import.rb
+++ b/app/models/import.rb
@@ -1,13 +1,15 @@
# frozen_string_literal: true
class Import < ApplicationRecord
+ FILE_TYPES = ['text/plain', 'text/csv'].freeze
+
self.inheritance_column = false
- enum type: [:following, :blocking, :muting]
+ belongs_to :account, required: true
- belongs_to :account
+ enum type: [:following, :blocking, :muting]
- FILE_TYPES = ['text/plain', 'text/csv'].freeze
+ validates :type, presence: true
has_attached_file :data, url: '/system/:hash.:extension', hash_secret: ENV['PAPERCLIP_SECRET']
validates_attachment_content_type :data, content_type: FILE_TYPES