Sha256: 64de51f28198834cec29421aa9dd6fde30f71eb89d6666db4ee4e96209252121
Contents?: true
Size: 953 Bytes
Versions: 38
Compression:
Stored size: 953 Bytes
Contents
# frozen_string_literal: true module Decidim module Comments # A comment can belong to many Commentable models. This class is responsible # to Seed those models in order to be able to use them in the development # app. class Seed # Public: adds a random amount of comments for a given resource. # # resource - the resource to add the coments to. # # Returns nothing. def self.comments_for(resource) organization = resource.organization rand(1..5).times do author = Decidim::User.where(organization: organization).all.sample user_group = [true, false].sample ? author.user_groups.verified.sample : nil Comment.create( commentable: resource, root_commentable: resource, body: ::Faker::Lorem.sentence, author: author, user_group: user_group ) end end end end end
Version data entries
38 entries across 38 versions & 2 rubygems