Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brief question about basic implementation #800

Open
monroemann opened this issue Apr 28, 2020 · 4 comments
Open

Brief question about basic implementation #800

monroemann opened this issue Apr 28, 2020 · 4 comments

Comments

@monroemann
Copy link

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!

@monroemann
Copy link
Author

I also am unclear the difference between these three commands, and when to use which: command, runner, and rake

@monroemann
Copy link
Author

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?

@monroemann
Copy link
Author

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!

@alexdean
Copy link

alexdean commented May 2, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants