diff --git a/app/models/privilege.rb b/app/models/privilege.rb index 7779e3a0696ba97f68217bfd7f81efe70c71939e..a715420c291a5c1b1bb8a0399f4b4f988232a5f2 100644 --- a/app/models/privilege.rb +++ b/app/models/privilege.rb @@ -7,5 +7,5 @@ class Privilege < ApplicationRecord has_and_belongs_to_many :users - validates :name, uniqueness: true + validates :name, uniqueness: { scope: [:community_id] } end diff --git a/db/seeds.rb b/db/seeds.rb index 77940fde8ba2df62bdb588f42687d899ffabe1ee..70927307cc59ecd90ac26be9a2405d474950a2fe 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,7 +4,13 @@ require 'redcarpet/render_strip' Rails.application.eager_load! -Dir.glob(Rails.root.join('db/seeds/**/*.yml')).each do |f| +if ENV['SEEDS'].present? + find_glob = "db/seeds/**/#{ENV['SEEDS'].underscore}.yml" +else + find_glob = 'db/seeds/**/*.yml' +end + +Dir.glob(Rails.root.join(find_glob)).each do |f| basename = Pathname.new(f).relative_path_from(Pathname.new(Rails.root.join('db/seeds'))).to_s type = basename.gsub('.yml', '').singularize.classify.constantize begin