Sha256: b488637558841d2200ae90fee6b3f3a3b4629fe82fd51d723c17bec1790f0d8c
Contents?: true
Size: 817 Bytes
Versions: 13
Compression:
Stored size: 817 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 random = rand(Decidim::User.count) Comment.create( commentable: resource, body: ::Faker::Lorem.sentence, author: Decidim::User.where(organization: organization).offset(random).first ) end end end end end
Version data entries
13 entries across 13 versions & 2 rubygems