rake

How do I execute Rake tasks with arguments multiple times?

余生长醉 提交于 2019-12-12 08:21:32
问题 It's not possible to invoke the same rake task from within a loop more than once. But, I want to be able to call rake first and loop through an array and invoke second on each iteration with different arguments. Since invoke only gets executed the first time around, I tried to use execute , but Rake::Task#execute doesn't use the splat (*) operator and only takes a single argument. desc "first task" task :first do other_arg = "bar" [1,2,3,4].each_with_index do |n,i| if i == 0 Rake::Task["foo

rake cucumber and rake spec always use “develop” environment

家住魔仙堡 提交于 2019-12-12 07:50:01
问题 My rake tasks for running Cucumber and RSpec tests are always using my development environment. Here are the relevant config files: RAILS_ROOT/config/environments/cucumber.rb # Edit at your own peril - it's recommended to regenerate this file # in the future when you upgrade to a newer version of Cucumber. # IMPORTANT: Setting config.cache_classes to false is known to # break Cucumber's use_transactional_fixtures method. # For more information see https://rspec.lighthouseapp.com/projects

rake db:create generated “if you set the charset manually, make sure you have a matching collation” error

旧时模样 提交于 2019-12-12 07:26:43
问题 I got a rails project in version 2.3.8. When i tried to run rake db:create, the below error occured. Couldn't create database for {"encoding"=>"utf8", "username"=>"root", "adapter"=>"mysql", "database"=>"claims_test", "host"=>"localhost", "password"=>"root", "socket"=>"/var/run/mysqld/mysqld.sock"}, charset: utf8, collation: utf8_unicode_ci (if you set the charset manually, make sure you have a matching collation) And I created DB manually and tried to run the application. And now I am

Make rake task from gem available everywhere?

孤者浪人 提交于 2019-12-12 07:08:52
问题 So I'm writing a small gem and I have a '/tasks' dir in it with some specific rake tasks. How do I make those tasks available automatically everywhere, where the gem is required? For example I wish I could run 'rake mygemrake:task' inside my rails root dir after I have the gem installed. 回答1: For Rails3 applications, you might want to look into making a Railtie for your gem. You can do so with: lib/your_gem/railtie.rb require 'your_gem' require 'rails' module YourGem class Railtie < Rails:

Rails help creating a delayed_job from a rake file

☆樱花仙子☆ 提交于 2019-12-12 06:04:55
问题 How do I create a delayed job from a rake file. How should I move it into a controller and create a delayed_job that runs the task every 15 minutes. Here is an example how my rake file: namespace :reklamer do task :runall => [:iqmedier, :euroads, :mikkelsen] do # This will run after all those tasks have run end task :iqmedier => :environment do require 'Mechanize' agent = WWW::Mechanize.new agent.get("http://www.iqmedier.dk") end task :euroads => :environment do require 'Mechanize' require

heroku run rake db:migrate - /bin/sh: 1: rake: not found

ぃ、小莉子 提交于 2019-12-12 05:49:31
问题 When I am trying to run heroku run rake db:migrate from Heroku code=H10 desc="App crashed" - Can't figure out why it's crashing I get /bin/sh: 1: rake: not found - git push heroku master # if not done - heroku run rake db:migrate - heroku restart Any suggestions? Logs of the command: 2017-07-08T23:10:22.242114+00:00 app[api]: Starting process with command `rake db:migrate` by user myname@gmail.com 2017-07-08T23:10:36.592694+00:00 heroku[run.1110]: Awaiting client 2017-07-08T23:10:36.631698+00

Rake aborting with error

可紊 提交于 2019-12-12 05:38:58
问题 Trying to setup the exception_logger plugin on a production server. Everything worked fine on the dev machine. Trying to rake db:migrate on the prod server and i get this error: rake aborted! no such file to load -- pagination What am i missing? 回答1: Classic Pagination is not supported in 2.1 - or at least it is a dead library http://workingwithrails.com/railsplugin/5289-classic-pagination Have a look at will_paginate - http://github.com/mislav/will_paginate/wikis that's what all the cool

rakefile.rb doesn't work correctly

冷暖自知 提交于 2019-12-12 05:28:49
问题 I have the following task task :default => ['build_html'] desc 'Generar documentacion desde markdown' task :build_html do SRC = FileList['*.md'] directory 'html' SRC.each do |md| html = md.sub(/\.[^.]*$/, '.html') file html do sh "markdown #{md} > html/#{html}" end end end It does not work correctly, is supposed to find all files .md, for each file extract only the name, append .html and finally execute markdown file.md > html/file.html . But it doesn't work. It doesn't even create the 'html'

CURSOR_NOT_FOUND - my cron jobs started dying in the middle

淺唱寂寞╮ 提交于 2019-12-12 05:03:58
问题 a cron job that was successfully running for years suddenly started dying after about 80% completion. Not sure if it is because the collection with results was steadily growing and reached some critical size (does not seem to be all that big to me) or for any other reason. I am not sure how to debug this, I found the user at whom the job died and tried to run the job for this user, got CURSOR_NOTFOUND message after 2 hours. Yesterday it died after 3 hours of running for all users. I am still

creating rake task for importing data from csv file

江枫思渺然 提交于 2019-12-12 04:43:03
问题 I am creating a rake task to import csv file data to my database (MySQL). Here is what I did but It is not working require 'csv' namespace :tech do desc "Import tech from csv file" task temp: :environment do file = "tech.csv" CSV.foreach(file, :headers => true) do |row| Temp.create ({ :current => row[1], :today => row[2], :week=> row[3], :month => row[4] }) end end end but when I run rake tech:temp it throws this error Don't know how to build task 'tech:temp' y/gems/2.0.0/gems/rake-10.3.2/lib