Class: Decidim::Comments::Seed
- Inherits:
-
Object
- Object
- Decidim::Comments::Seed
- Defined in:
- app/models/decidim/comments/seed.rb
Overview
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 Method Summary collapse
-
.comments_for(resource) ⇒ Object
Public: adds a random amount of comments for a given resource.
Class Method Details
.comments_for(resource) ⇒ Object
Public: adds a random amount of comments for a given resource.
resource - the resource to add the coments to.
Returns nothing.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/models/decidim/comments/seed.rb', line 13 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 |