From c4be57e525f992110fb2b72869e5304a7b41b515 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Fri, 18 Dec 2015 09:25:54 +0800 Subject: [PATCH] topic and synapse validate permission --- app/models/synapse.rb | 3 +++ app/models/topic.rb | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/models/synapse.rb b/app/models/synapse.rb index 943c8635..225485e5 100644 --- a/app/models/synapse.rb +++ b/app/models/synapse.rb @@ -10,6 +10,9 @@ class Synapse < ActiveRecord::Base validates :desc, length: { minimum: 0, allow_nil: false } + validates :permission, presence: true + validates :permission, inclusion: { in: Perm::ISSIONS.map(&:to_s) } + def user_name self.user.name end diff --git a/app/models/topic.rb b/app/models/topic.rb index 6f694868..e80d3df7 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -10,6 +10,9 @@ class Topic < ActiveRecord::Base has_many :mappings, as: :mappable, dependent: :destroy has_many :maps, :through => :mappings + + validates :permission, presence: true + validates :permission, inclusion: { in: Perm::ISSIONS.map(&:to_s) } # This method associates the attribute ":image" with a file attachment has_attached_file :image