whenever
whenever copied to clipboard
Brief question about basic implementation
Hi @javan
We are a not for profit (and not so advanced) volunteer coding team at BreakDiving.io. We have a worldwide social media community designed to inspire our members to achieve their goals in life.
We have a message board on the homepage. We want to have the system automatically do a few things every Monday morning on that homepage:
- Post a new post on the message board that says, "Time for your weekly update!", posted from a specific user
- Share a random quotation from quotations we have added to the database
- Put a random 'tag of the week' above all of the posts that pulls from the Tag model
I have read through the readme, but am still a bit unclear how this would work. As an example, here is our Tag model:
class Tag < ApplicationRecord
include PgSearch
multisearchable :against => [:name]
validates :name, uniqueness: true
has_many :taggings, :dependent => :destroy
has_many :posts, through: :taggings
COLORS = ['#F7464A', '#46BFBD', '#FDB45C', '#949FB1', '#4D5360',
'#FF5733', '#F4D03F', '#a569bd', '#22b256', '#68a1b9',
'#d7b1e1', '#d15269', '#37b9bb', '#7ebb85', '#bc328c']
end
How could we randomly post a tag from this model each week?
Would it be similar for posting the weekly 'share your update' reminder?
Thank you so much for your help!
I also am unclear the difference between these three commands, and when to use which: command, runner, and rake
Would it be something like this:
every :monday, at: '8am' do # Use any day of the week or :weekend, :weekday
runner "Tag.post_random_tag"
end
And then we would have to write a method in the tag model (or would it be in the controller?) that randomly grabs a tag and displays it on the view?
I apologize for tagging you all, but we're not the most advanced coders, and are hoping one of you may be able to assist: @andrew @olleolleolle @dce @dinossaur23 @alexdean @dreamwords
Thank you!
Run bundle exec whenever
from a command line and look at the output that is generated. This builds a cron file but doesn't send it anywhere. That will show you the differences between command
, runner
, and rake
.