diff --git a/app/models/map.rb b/app/models/map.rb index e45db636..e5c483f1 100644 --- a/app/models/map.rb +++ b/app/models/map.rb @@ -13,9 +13,11 @@ class Map < ActiveRecord::Base #:full => ['940x630#', :png] }, :default_url => 'https://s3.amazonaws.com/metamaps-assets/site/missing-map.png' - validates_presence_of :name - validates_presence_of :arranged - validate_presence_of :permission + validates :name, presence: true + validates :arranged, presence: true + validates :arranged, inclusion: { in: [true, false] } + validates :permission, presence: true + validates :permission, inclusion: { in: Perm::ISSIONS } # Validate the attached image is image/jpg, image/png, etc validates_attachment_content_type :screenshot, :content_type => /\Aimage\/.*\Z/ diff --git a/app/services/perm.rb b/app/services/perm.rb index 7bded989..c18c26b7 100644 --- a/app/services/perm.rb +++ b/app/services/perm.rb @@ -1,7 +1,8 @@ class Perm + # e.g. Perm::ISSIONS + ISSIONS = [:commons, :public, :private] + class << self - # e.g. Perm::ISSIONS - ISSIONS = [:commons, :public, :private] def short(permission) case permission diff --git a/config/application.rb b/config/application.rb index dc13c79d..93bdb8bf 100644 --- a/config/application.rb +++ b/config/application.rb @@ -11,7 +11,7 @@ module Metamaps # -- all .rb files in that directory are automatically loaded. # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) + config.autoload_paths << Rails.root.join('app', 'services') # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named.