Questions tagged [rake-task]

Task is the basic unit of work in a Rakefile.

Tasks have associated actions (possibly more than one) and a list of prerequisites. When invoked, a task will first ensure that all of its prerequisites have an opportunity to run and then it will execute its own actions.

Tasks are not usually created directly using the new method, but rather use the file and task convenience methods.

689 questions
6
votes
1 answer

Can't debug rake task in VS Code

I configured my environment properly to debug rails apps in VS Code. It works fine for debug Rails Server. When I start the debug, it boots the server and stop at the breakpoints that I have marked. But, I can't figure out how to debug local files,…
Samuel
  • 259
  • 3
  • 15
6
votes
1 answer

How to test a rake task with RSpec?

I have an Ruby 2.1/Rails 3.2 application which uses the asset pipeline. We are also using a fragile (alpha) gem which causes "rake assets:precompile" to fail at times. I would like to write an rspec test which ensures that this rake task always…
Jay Godse
  • 15,163
  • 16
  • 84
  • 131
6
votes
1 answer

Set Multiple Environmental Variables On Invocation of Rake Task

I can invoke a Rake task and set a single environmental variable like this: $ ONE=1 rake temp:both But how do I set two environmental variables? This doesn't work: $ ONE=1 TWO=2 rake temp:both This works, but is confusing to read: $ ONE=1 rake…
Undistraction
  • 42,754
  • 56
  • 195
  • 331
6
votes
1 answer

Rake task to list all migrations for a given model

On the terminal, is there a rake task to list all the migrations which have been run on a particular model? If not, how do I go about building one? When I ran rake -T, rake db:migrate:status seemed to be the right answer, but it gave me Migration…
WinkyCharlie
  • 146
  • 2
  • 3
  • 13
6
votes
2 answers

how to force rake task to run under development environment using Whenever gem

I'm using Whenever gem to run a rake task. When I run rake task it runs under development environment, but when it runs on a scheduled time it refers to a production environment. How can I force to run a scheduled rake task under development…
Askar
  • 5,784
  • 10
  • 53
  • 96
5
votes
3 answers

Generate Rake test tasks dynamically (based on existing test files) in a Rakefile

I'm generating test tasks dynamically based on existing test files in a Rakefile. Consider you have various unit test files named after the pattern test_.rb. So what I'm doing is creating a task named after the file name inside the 'test'…
jasoares
  • 1,811
  • 17
  • 22
5
votes
1 answer

Using rails logger in rake tasks, rails 5

I'm building a ruby on rails app, using rails 5, and I have a number of rake tasks from which I'd like to log information. However, when I attempt to access the logger, I get an error: undefined local variable or method `logger' I have my rake tasks…
Nathan Lauer
  • 381
  • 5
  • 18
5
votes
3 answers

How to ensure a rake task only running a process at a time

I use crontab to invoke rake task at some time for example: every 3 hour I want to ensure that when crontab ready to execute the rake task it can check the rake task is running. if it is so don't execute. how to do this. thanks.
www
  • 4,065
  • 7
  • 30
  • 27
5
votes
2 answers

Log issue in Rails4 with Docker running rake task

My rails4 application is running with docker. It runs a rake task for fetching messages from AWS SQS. The problem I met is that logs can't show up in a console in time. The console doesn't show anything until exception/error comes. In other words,…
Eason Caizhen Liu
  • 459
  • 1
  • 5
  • 12
5
votes
2 answers

Ruby rake loaderror - bundle exec rake not working

I'm trying to run the command rake db:migrate but I keep getting this error: /Users/[name]/.rvm/gems/ruby-2.2.1/bin/rake:23:in `load': cannot load such file -- /Users/[name]/.rvm/rubies/ruby-2.2.1/lib/ruby/gems/2.2.0/specifications/default/bin/rake…
Ol' Reliable
  • 570
  • 1
  • 8
  • 19
5
votes
2 answers

Rake task variable under namespace

I see a strange thing in my rake script today. I have two Rake tasks under the different namespaces like following: path = "/home/tomcat/tomcat" namespace :stage do path = "/home/tomcat/stage-tomcat" desc "Deploys a java application to stage…
5
votes
1 answer

bad component(expected host component): received when running a rake task to send email with roadie on heroku

I'm using the roadie gem to help with the inline css for emails and am getting the following error when running a rake task to send emails. My app is hosted on heroku. It works fine in development mode, but get this error in production. I don't…
jtmanuel
  • 53
  • 1
  • 4
5
votes
3 answers

Crontab in Amazon Elastic Beanstalk

I am doing a cron tab in AWS - Elastic Beanstalk with Ruby on Rails 3, but I don't know what is wrong. I have this code in my .ebextensions/default.config container_commands: 01remove_old_cron_jobs: command: "crontab -r || exit 0" …
5
votes
2 answers

bundle exec rake test does nothing

I am trying to get my heads "dirty" with TDD and for some reason when I run bundle exec rake test on the command line, nothing happens. Here is my RakeFile: require 'rake/testtask' Rake::TestTask.new do |test| test.libs << 'test' end desc "Run…
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
4
votes
0 answers

rake aborted! uninitialized constant Object::Country, why can't see model?

I have rails 3.1, I am trying to populate data with seeds.rb I have a model Country which is migrated into a countries table But it seems that rails can't see Country model from seeds.rb I get this error: rake aborted! uninitialized constant…
simo
  • 23,342
  • 38
  • 121
  • 218