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

run rake task inside rails application

I want to run asset precompile task inside the rails application,As I had many dependencies who will change the code,in that case all the time whenever they change i need to run the script as I cant give server access to them so I am providing the…
Jenorish
  • 1,694
  • 14
  • 19
3
votes
1 answer

Lost connection to MySQL server at 'reading initial communication packet' for remote mysql server

I am trying to access remote mysql database using rake task. Here i am posting my active record connection logic client = ActiveRecord::Base.establish_connection( :host => "server_ip", :port => 22, :adapter => "mysql2", :pool => 5, :database =>…
3
votes
1 answer

Start sidekiq from a rake task

I'm trying to start Sidekiq by executing a rake task. Here is my code. namespace :sidekiq do task start: :environment do system "bundle exec sidekiq -C 'Path To Config File' -P 'Path For PID File' -d -L 'Path To Log File'" end end When I…
RQ Bukhari
  • 167
  • 3
  • 8
3
votes
2 answers

How can you pass in arguments to rake tasks called using Heroku Scheduler?

Rake tasks scheduled in Heroku found online are in the "rake task-name" format. Heroku passes in an :environment argument to the rake task, but there is no documentation about extra args being passed to a task listed in scheduler.rake Heroku…
cabe56
  • 404
  • 2
  • 14
3
votes
4 answers

How to increment counter in Ruby loop

For my Rails application I am trying to build a rake task that will populate the database with 10 invoices for each user: def make_invoices User.all.each do |user| 10.times do date = Date.today i = user.invoices.create!(:number =>…
Tintin81
  • 9,821
  • 20
  • 85
  • 178
3
votes
1 answer

Rails - run rake task or new thread from controller?

I have a class (/lib/updater.rb) that do a large updating of the database (calling external server, calculations,...). Normally this task is called by the cron of the server (rake /lib/tasks/launch_updater.rake that start the updater.rb), but I…
damoiser
  • 6,058
  • 3
  • 40
  • 66
3
votes
1 answer

Rake task failing to load :environment properly

I'm running a custom rake task... namespace :import do desc "Import terms of service as HTML from stdin" task :terms => :environment do html = STDIN.read settings = ApplicationWideSetting.first settings.terms_and_conditions = html …
ocodo
  • 29,401
  • 18
  • 105
  • 117
3
votes
1 answer

Rake::TestTask not running minitest files

I'm using minitest for one of my projects, and I can't seem to get the Rake TestTask to actually run the files. require 'rake' require 'rake/testtask' task :mytest do Rake::TestTask.new do |t| t.test_files = Dir.glob('test/model/*_test.rb') …
CJ.
  • 153
  • 2
  • 8
3
votes
2 answers

Including Rails classes in a rake task?

I'm pretty new to Rails, so I apologize if my question doesn't make the most sense. I have a class called PaymentGatewayCipher that looks like: require 'openssl' # Encapsulates payment gateway encryption / decryption utility functions class…
Shamoon
  • 41,293
  • 91
  • 306
  • 570
3
votes
2 answers

How to load db rake tasks in rails 3.2.9 engine

We are working on rails engine on 3.2.9. Engine is generated with : rails plugin new rails_engine -mountable --skip-test-unit --dummy-path=spec/dummy After initial setup, we can generate a model just like what we do in regular rails app: rails g…
user938363
  • 9,990
  • 38
  • 137
  • 303
3
votes
1 answer

How to run rake task as a worker process on Heroku?

Let assume that I have scaled Heroku application to 1 worker process, but how to specify that the rake task with particular name should run as a worker process?
Paul
  • 25,812
  • 38
  • 124
  • 247
3
votes
2 answers

Rails 3: How to intercept any http request

Lets say I have an image at app/assets/images/privateimages/myrestrictedimage1.jpg If I try to go directly to the image via url say with something like http://localhost:5555/assets/privateimages/myrestrictedimage1.jpg I am able to view the…
snowleopard
  • 781
  • 3
  • 13
  • 36
3
votes
2 answers

How can I see the output from automated daily Rake tasks?

Our company use rails as our server, and we will rake tasks daily without monitoring. When the rake aborts, we can not get the aborting information until we find that our data is strange. How can I get the rake-aborting infomation as soon as…
2
votes
1 answer

How find the file/test which is causing rake test task to terminate?

I'm using a rake task to run the test suites of my application. I can see that when I launch the task it run the command ruby -I"lib:test" -I"[...]/lib" "[...]/lib/rake/rake_test_loader.rb" "vendor/plugins/shop/test/**/*_test.rb" Where [...] is the…
Adrien Coquio
  • 4,870
  • 2
  • 24
  • 37
2
votes
2 answers

Rails 3.1 - stack level too deep on db:seed

I dropped my old development db to get a fresh one on my rails 3.1.3 application. But, when i run bundle exec rake db:seed --trace I get the following error: rafael@WALL-A:~/workspace/media-choice$ bundle exec rake db:seed --trace ** Invoke db:seed…
manzo
  • 51
  • 3