add permission service, refactor map model a bit, add validations
This commit is contained in:
parent
bfd4e4f228
commit
2525a6fb65
3 changed files with 9 additions and 6 deletions
|
@ -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/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue