topic and synapse validate permission

This commit is contained in:
Devin Howard 2015-12-18 09:25:54 +08:00
parent cf6411988d
commit c4be57e525
2 changed files with 6 additions and 0 deletions

View file

@ -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

View file

@ -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