Sha256: fab82a61504fe7bcf4793790498c955130ecc86803befec1ff50b3aa5c19f89b
Contents?: true
Size: 857 Bytes
Versions: 2
Compression:
Stored size: 857 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, root_commentable: resource, body: ::Faker::Lorem.sentence, author: Decidim::User.where(organization: organization).offset(random).first ) end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
decidim-comments-0.1.0 | app/models/decidim/comments/seed.rb |
decidim-0.1.0 | decidim-comments/app/models/decidim/comments/seed.rb |