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
2
votes
1 answer

Issue regarding running rake db:seed task

I have an existing rails project and I am using postgres database and after successful execution of bundle exec rake db:migrate command when I am going to execute the bundle exec rake db:seed command then it throws me the following error. rake…
2
votes
2 answers

Rails 4: PG::InFailedSqlTransaction when testing a rake task with RSpec

I am currently trying to test a rake task with RSpec. My Rails version is 4.2.4 and rspec-rails version is 3.3.2. I've have the following in rails_helper.rb: ENV['RAILS_ENV'] ||= 'test' require 'spec_helper' require…
DaniG2k
  • 4,772
  • 36
  • 77
2
votes
2 answers

Rails uninitialized constant in production

I have a weird problem. In development this problem does not exist, but in production rake throws this error message at me "uninitialized constant Program" The "Program" is an active record model, and it's there, it's in the schema file and it's in…
kristian nissen
  • 2,809
  • 5
  • 44
  • 68
2
votes
1 answer

Advanced? rule for Rake file tasks

I have without success been trying to combine some of my mostly redundant Rake file tasks. Even directing me towards some documentation on rake rules would be great, I've found very little. All examples I've found have been files that were…
Drew
  • 4,683
  • 4
  • 35
  • 50
2
votes
1 answer

Run all rake tasks?

How can I run all rake tasks? task :a do # stuff end task :b do # stuff end task :c do # stuff end task :all do # Run all other tasks? end I know I can just do task :all => [:a, :b, :c] do end but if I add new task, I also need to…
graywolf
  • 7,092
  • 7
  • 53
  • 77
2
votes
0 answers

Rake task to fetch current price and update object attribute

I have a Portfolio model and am currently running rake tasks to fetch updated price data from Yahoo Finance API, updating the amounts for the Portfolios and create a new Valuation object that takes a snapshot of each portfolio and their values. A…
Coder_Nick
  • 781
  • 1
  • 8
  • 25
2
votes
1 answer

How do you include modules in rails schedule.rake?

I'm trying to require some modules I've written inside my schedule.rake file but am having trouble loading the file 'LoadError: cannot load such file -- app/models/concerns/sharedmethods' What am I doing wrong? Is it the syntax? Here is my…
echan00
  • 2,788
  • 2
  • 18
  • 35
2
votes
1 answer

How can a rake task run any time a directory or any of its contents changes?

I have a rakefile with a task that copies the contents of a directory to somewhere else on disk. When the rakefile is executing, I need this task to run if any of the contents of this directory have changed since the last execution of the rakefile…
Bri Bri
  • 2,169
  • 3
  • 19
  • 44
2
votes
2 answers

Ruby: CSV parser tripping over double quotation in my data

I 'm working on a daily scheduled rake task that will download a CSV that is automatically sent to Dropbox every day, parse it and save to the database. I don't have control over the way the data is entered into the program that generates the CSV…
Tatiana Frank
  • 418
  • 5
  • 22
2
votes
1 answer

Rails error Uninitialized constant importing csv

This is my first time importing a csv file to my rails app. I have the code below in /lib/tasks/import.rake require 'csv' CSV.foreach("lib/articles.csv", headers: true, encoding: "ISO8859-1") do |row| Article.new(title:…
jgrant
  • 582
  • 6
  • 20
2
votes
2 answers

How to use current_user method in rake task rails

I creating a rake task for sending SMS to user from an Organisation which is signed in as current_user and I have to send the organisation name in the end which is stored in the organisation table. But the problem is that current_user method is not…
Supertracer
  • 462
  • 6
  • 17
2
votes
1 answer

Ensure Rails database record uniqueness when updating without aborting the update process

Ruby 2.3.0, Rails 4.2.4, and actually using postgreSQL rather than SQLite Updated for clarity I have a large csv file (externally updated & downloaded daily) and wrote a method to update a Rails database table. I do not want the method to append all…
JHFirestarter
  • 63
  • 1
  • 9
2
votes
1 answer

Are rake task arguments immutable?

I want to modify the value of a task arguments (e.g. I want the argument to become a symbol). But it seems that the rake task arguments are immutable, is this correct? task :my_task,[:some_arg,:another_arg] do |cmd,args| puts…
Paul Verschoor
  • 1,479
  • 1
  • 14
  • 27
2
votes
1 answer

Explain Rake query to create csv

I have inherited a ruby app which connects to a mongodb. I have no idea about mongo or ruby unfortunately so im on a rapid googling and learning curve. The app stores placenames as well as their lat longs, alternative name, peoples memories, and…
Paul M
  • 3,937
  • 9
  • 45
  • 53
2
votes
2 answers

Create a zip file using Rake::PackageTask

I am trying to package up a zip file in my rake file and I am pretty inexperienced with Rake and ruby, so I am having a hard time identifying why this is failing. This is what I have tried: def create_zip_file(targetDirectory, projectToZip) …
David Watts
  • 2,249
  • 22
  • 33