Sha256: 4a0374c9420fa5789f3be0d70eed4251f90fee0a19893f48b7468061278d5dbc
Contents?: true
Size: 944 Bytes
Versions: 30
Compression:
Stored size: 944 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 2.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
30 entries across 30 versions & 1 rubygems