We're going to make it dynamic using the geozones. Besides, class methods can be overwritten using custom models, while constants can't be overwritten without getting a warning [1]. Makes the definition of segments with geozones a little cleaner. I think it’s worth it, compared to the slight memory gain of using a constant [2]. [1] warning: already initialized constant UserSegments::SEGMENTS [2] https://stackoverflow.com/questions/15903835/class-method-vs-constant-in-ruby-rails#answer-15903970
24 lines
1.1 KiB
Ruby
24 lines
1.1 KiB
Ruby
section "Creating Newsletters" do
|
||
newsletter_body = [
|
||
"We choose to go to the moon in this decade and do the other things, not because they are easy"\
|
||
", but because they are hard, because that goal will serve to organize and measure the best of"\
|
||
" our energies and skills, because that challenge is one that we are willing to accept, one we"\
|
||
" are unwilling to postpone, and one which we intend to win.",
|
||
"Spaceflights cannot be stopped. This is not the work of any one man or even a group of men."\
|
||
" It is a historical process which mankind is carrying out in accordance with the natural laws"\
|
||
" of human development.",
|
||
"Many say exploration is part of our destiny, but it’s actually our duty to future generations"\
|
||
" and their quest to ensure the survival of the human species."
|
||
]
|
||
|
||
5.times do |n|
|
||
Newsletter.create!(
|
||
subject: "Newsletter subject #{n}",
|
||
segment_recipient: UserSegments.segments.sample,
|
||
from: "no-reply@consul.dev",
|
||
body: newsletter_body.sample,
|
||
sent_at: [Time.current, nil].sample
|
||
)
|
||
end
|
||
end
|