Muhammed kanyi
Muhammed kanyi

Reputation: 89

rails recurring event with whenever gem

i have a winner controller which have a

before_action :set_winners
  def create

    Winner.create(
    date: Time.now,
    likes: winner.selfy.likes_count,
    user_id: winner.user.id,
    selfy_id: winner.selfy.id
    )
  end
private

def set_winners
  date = DateTime.now.utc
  likes = Like.where('created_at >= ? and created_at <= ?', 2.week.ago.beginning_of_week, 1.week.ago.end_of_week).select(:selfy_id)
  top = Selfy.where(id: likes)
  top.order("COALESCE(likes_count, 0) DESC").limit(1)
end

i want this to be perform every 5 minutes, i try to use whenever gem like this

every 2.minutes do
#   command "/usr/bin/some_great_command"
   runner "Winner.create"
#   rake "some:great:rake:task"
 end

am getting this error

/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found
/bin/bash: bundle: command not found

what am i doing wrong here.

Upvotes: 0

Views: 39

Answers (2)

Boris
Boris

Reputation: 557

Try adding

env :PATH, ENV['PATH']
env :GEM_PATH, ENV['GEM_PATH']

Upvotes: 0

Joel Blum
Joel Blum

Reputation: 7878

Try adding

  env :PATH, ENV['PATH'] 

to the top of your schedule.rb file.

Upvotes: 1

Related Questions