Questions tagged [rake-task]

Task is the basic unit of work in a Rakefile.

0
votes
1answer
15 views

Store a value in a string type field which stores value as an array

I am creating a rake take for multiple attachment import and the only issue that I am not able to figure-out is how to store the filename in the documents field as it stores the filename name as an ...
0
votes
1answer
17 views

Multiple file basename in rake task

I have a folder with multiple pdf files and the file name are like this as below 1_abc.pdf 2_xyz.pdf 3_qwe.pdf What is want to do is just get the first part of the file name that is 1 2 3 So I am ...
1
vote
1answer
22 views

rake task rspec test does not respond to :have_received method

I have a pretty simple rake task: namespace :subscriptions do desc 'Send expired subscription notifications' task notify_trial_expired: :environment do Subscription.where(expires_at: Date....
0
votes
0answers
22 views

LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError/Environment Variable set with Encryption Key?

I just started learning Ruby and partnered with a backend developer to build out my property reservation app. Unfortunately he no longer wanted to work on the project and I am now trying to deploy my ...
0
votes
0answers
12 views

Is there a way to send Sendgrid email using rake tasks?

Im trying to send emails on a rake task in my app. My mailer works perfectly with the server, but when running on a rake task it does nothing. Here is my rake task: namespace :booking do desc "...
0
votes
0answers
37 views

Why are DB tasks missing from rake?

When I run bundle exec rake db:setup I get an error saying that rake doesn't know how to build that task. I then run bundle exec rake -T and see that db tasks are missing (all output below). How can I ...
0
votes
1answer
28 views

How to reference the previously created object in a create loop Rails/Ruby

So I have the concept of a Campaign which has a start_time and end_time. I am building a small rake task which I'll use to "repeat" or "recur" the campaign again, a set number of times again, on a set ...
1
vote
1answer
51 views

How to parse XML with non-pair tags using Nokogiri

All examples seen on the internet are XML files with structure like: <open_tag>data that I want</close_tag> but my XML file is different: <Report xmlns:xsi="http://www.w3.org/2001/...
0
votes
0answers
19 views

Running custom rake task for multi tenant app rails

I have a custom rake task namespace :abc do desc "seeds abc to a database" do task seed_abc: :environment do Tenant.find_each do |tenant| puts "Running task for tenant#{tenant....
0
votes
1answer
15 views

Run mailer only after rake task is finished

I only want to run my mailer if my rake task is NOT running. If I run both the api gets throttled. So I'm trying to define a variable in a method on my OrderMailer and just watch for a true value on ...
0
votes
1answer
47 views

Uninitialised Constant Doorkeeper::AccessToken in Doorkeeper Rake Task

I've implemented OAuth 2 with Doorkeeper Gem in a rails project(Grape API). I want to delete the expired and revoked access_token by a rake task. So far, I've been following the official doorkeeper ...
1
vote
2answers
38 views

rails migration apparently causing infinite forking

I've encountered a problem today that I've so far not had any luck tracking down. I created a new migration file (via 'rails g migrate ...'). After creating the file, when I run rails db:migrate or ...
1
vote
1answer
23 views

Real-time output of a rake task with popen3

It seems impossible to run a rake task from within a popen3 block while getting real-time output. All lines come at once at the end of the rake task. I'm trying to get real-time output from rake tasks ...
1
vote
1answer
19 views

Rails 5.2 Rake Task Not Sending Mailer (Despite inner mailer working perfectly)

I have the following mailer set up in a rake task in lib/tasks/scheduler.rake: desc "Send capsule reminder emails" task send_capsule_reminders: :environment do require 'time' t = Time.now....
0
votes
2answers
32 views

`Rake::Task['db:seed'].invoke` doesn't work - “Don't know how to build task 'db:seed'”

I have a problem with testing my rake task. The task looks like this: namespace :db do desc 'Load the seed data from db/seeds.rb' task :seed => :environment do puts 'seed' end end And ...
0
votes
0answers
43 views

Indexer Failing for Sphinx on mysql library

Sphinx Reindexing failing for the rake task because of an error with mysql library Below is the rake log -bash-4.2$ RAILS_ENV=production bundle exec rake ts:index Generating configuration to /var/...
2
votes
2answers
39 views

How to catch raised exception in rake task

I have a rake task that loops through rows in CSV file, and inside that loop, there's a begin/rescue block to catch any possible raised exception. But when I run it, it keeps on saying 'rake aborted!' ...
1
vote
2answers
87 views

Running rake tasks from crontab

I have run into a problem that I can't imagine a solution for, and has had me stuck for a week. I have the following two lines in sudo crontab -e. * * * * * echo "crontab can log to reports" >> ...
1
vote
1answer
34 views

Why isn't standard output displayed from a rake task called via backticks?

When a rake task is called via backpacks its output is suppressed: task :two do puts 'two' end task :one do puts 'one' `rake two` end -bash> bundle exec rake one one Whereas, the ...
0
votes
1answer
54 views

Rails Import: “No Implicit conversion of string into array”

I'm attempting to import values from a spreadsheet into a table. I am adding new records for each row to an array, and then importing that array. My Code is below: def import(path) spreadsheet = ...
0
votes
1answer
62 views

error when use “rake db:migrate” on Ubuntu 16.04.5 LTS

I'm use "rake db:migrate" and getting this error message: Pls help me to fix that: # rake db:migrate rake aborted! StandardError: An error has occurred, this and all later migrations canceled: ...
0
votes
0answers
37 views

How to send params to before hook for rake task

I want to see "start" and "finish" message for all rake tasks. task :my_before_hook, [:name] => :environment do |_t, args| puts "Rake task #{args[:name]} started" end task :my_after_hook, [:...
0
votes
0answers
28 views

Emulate bash source with Rake

How can I run a bash command inside a rakefile that would impact the calling shell? For example, changing working directory of the calling shell. With straight bash I would have a script.sh: #!/bin/...
0
votes
0answers
134 views

Don't know how to build task 'environment' when namespaced

Having issues with what should appropriately work for the environment. I've followed the answer to: rake-aborted-dont-know-how-to-build-task but end up with... bash-4.4$ rake -T rake jenkins ...
1
vote
1answer
26 views

DigitalOcean - cap staging deploy error on precompiling assets

When I run cap staging deploy:check it succeeds. When I run cap staging deploy it succeeds until deploy:assets:precompile at which I get this error: 01 ~/.rvm/bin/rvm default do bundle exec rake ...
0
votes
0answers
18 views

Rails 4.2: read text file and write it correctly on DB

I'm working on a quite big project in Rails and I love the language, though I'm not an expert programmer. I'm facing a problem that I apparently can't overcome. It's a backend task (rake) which ...
0
votes
0answers
37 views

What to consider when writing long running rake task?

I already read the following question: Dealing with very long running rake task but my question is not about executing the task, but writing the task itself. I am currently writing a rake task that ...
0
votes
1answer
27 views

images not showing up in rask task with action mailer on Rails

So I created a welcome email for my users. I want this email to be sent at a specific time so I nest it into a rake task and add it to my heroku scheduler. The thing is, the email template has ...
0
votes
1answer
66 views

Include spec_helper in Rakefile

In Rspec 3, the preferred way to include the spec/spec_helper.rb file is to add a flag to the .rpsec file: --require spec_helper Which eliminates the need to add a reference at the top of each _spec ...
1
vote
0answers
23 views

How to run subtasks multiple times in rake multitask?

So I have multitask :do_something => [ :task1, :task2, :task3, :task4, :task5, :task6 ] And each task runs a script. I want the tasks1 to task6 concurrently to run 1000 ...
0
votes
1answer
111 views

How to run a rake task on jenkins with string parameters?

I have the follow execute shell command: bundle exec rake ${RAKE_TASK[@]} RAILS_ENV=$ENVIRONMENT But it doesn't work when I need to run a task with parameters like that: bundle exec rake {...
1
vote
1answer
76 views

Rake task to send emails. Do i need a queue?

I have setup crontab with whenever gem to send emails at time. Cron just calls the rake task, which gather all emails and sends them in loop. My question is do I need some queue system that provide me ...
1
vote
1answer
66 views

ActiveRecord or Postgresql Setting Wrong ID When Creating New Record

I am Rails 5.1 with Postgresql 9.6.9 on Heroku free tier. I recently was using a rake task with csv files to try to create a couple of batches or records. I then wanted to test the front end use and ...
0
votes
1answer
36 views

Implement rake db:rollback STEP=n inside rakefile

I'm trying to combine a bunch of rake tasks like this: desc 'Resets the database' task :reset do Rake::Task["db:rollback"].invoke Rake::Task["db:migrate"].invoke Rake::Task["db:seed"].invoke ...
0
votes
1answer
34 views

Rake task selectivly ignoring new code

In a rake task I'm writing some puts statements show changes while others don't. For instance changing puts model+" | "+id into puts model+" * "+id doesn't change in the output of the script. ...
0
votes
1answer
26 views

What does the rake task db:full_reset do?

I have the following in my deploy script in which I inherited from other devs. Does any one know what the rake task db:full_reset does? I would think it resets the db but I can't find that actual task ...
0
votes
1answer
43 views

How to add exception handling to an existing Rake task?

I want to rescue an exception thrown by a rake task provided by an external gem. Ideally, I would like to create a rake task with the same name that invokes the original one and just handles the ...
0
votes
0answers
24 views

Rails - How to customize process after db:migrate [duplicate]

I would like to add some process or at least some log to console after a rake db:migrate My goal for simple is to start rake diagram:all request from railroady after each migration to keep my ...
0
votes
0answers
34 views

rails rake task paused for a while and resumed pressing enter on console

I experienced weird issue today, I was running rake task witch does some batch processing one after the other. One the console I log progress details on command prompt. In the rake task I make API ...
0
votes
0answers
57 views

Rakefile rake multiple tasks arguments

I'm writing some puppet modules and when it's done, I want to run some tasks to check code etc. When I run this on the command prompt: rake syntax:manifests rake strings:generate[,,,markdown,false,...
2
votes
1answer
334 views

How to pick random element from array without repeating in Ruby?

I am new to coding and am trying to learn Ruby. I am working in a Rake. What should I use to ensure that the random selection never repeats the same response back to back? array = ["1", "2", "3", "4",...
0
votes
1answer
330 views

Sudden “already initialized constant” errors when running rake tasks

I've been running rake tasks no problem for a while, on a Windows machine. Then I suddenly started getting an error when I ran anything rake-related. It happened for the first time after I ran rake db:...
0
votes
1answer
553 views

Heroku Scheduler task not running as expected

I'm using Heroku's Scheduler add-on to run jobs in my app at scheduled time intervals, much like cron in a traditional server environment. The tasks are rather trivial, in it that they simply enqueue ...
0
votes
1answer
297 views

Rake Task and Namespaces [closed]

Is it a good idea to put rake tasks with different namespaces in different folders under task, also if there's only one file with a different namespace what should be done?
1
vote
3answers
104 views

Ruby on Rails - Change column value in rake task

I have a rake task that sends an email if MailCourseWarn.where(needs_warned: true). I want that after email is delivered, the needs_warned be false and not true. Rake task: namespace :...
0
votes
1answer
31 views

Ruby on Rails - Get user email from database in a Rake Task

I have that Mailer method and a Rake task to later scheduled with Cron Job and automate with Gem Whenever for send a email to a users: # Mailer: class MailCourseWarnMailer < ActionMailer::Base ...
0
votes
1answer
562 views

Ruby on Rails - undefined local variable or method in rake task

I've created a Rake Task for a Mailer to later scheduled wth Crontab and automate with Gem Whenever for send a email to a users. For a while is a just a test to know if task is working. My Rake Task ...
0
votes
0answers
20 views

Rails adding 'nd' to a simple line substitution rake task

This is a rake task that changes a line in config/application.rb. File.open('../project2/config/application.rb', 'r+') do |file| lines = file.each_line.to_a lines.each_with_index do |l, i| if ...
0
votes
0answers
26 views

Rake tasks invoked in different thread doesn't call Rakefile

i have a rake file which has different tasks mentioned in it namespace :spec do puts "running rake" task :hello do puts "hello" end task :world do puts "world" end task :...
0
votes
2answers
38 views

How do I get Active Record query that works in Rails console working in a rake task?

I have an active record query that works fine in the console but does not work when I use it in a rake task Here is the beginning of my rake task: namespace :attendees do desc "Migrate sms plans ...