rake

How can I run a ruby class from rake file?

ぃ、小莉子 提交于 2019-12-07 11:14:07
问题 I want to run a ruby class from a sample.rake file. Consider myruby.rb is a ruby file. I want to run this from sample.rake like ruby myruby.rb 回答1: Adding to what @tobias has to say here you go with an example script sample content of myruby.rb puts "hello world" Create file called Rakefile task :default => [:test] task :test do ruby "my_file.rb" end Now if you invoke rake it should file up hello world text in console. Update It would make more sense if you wrap your call in a function call

rake aborted! undefined method `prerequisites' for nil:NilClass

我怕爱的太早我们不能终老 提交于 2019-12-07 10:45:25
问题 Spoiler: It was an outdated version of the rspec-rails gem! I encountered this error with any rake command issued from my rails project directory after moving my sqlite3 gem into a development block and then running 'rake db:migrate' to make sure everything still worked. Rake works fine elsewhere on my system. But any rake task I run in that directory gives me the following output with the trace: /Users/ianyoung/.rvm/gems/ruby-1.9.2-p290/gems/rspec-rails-2.0.0.beta.18/lib/rspec/rails/tasks

how to run rake task in background in rails

你。 提交于 2019-12-07 10:18:45
问题 This is my command bundle exec rake resque:work QUEUE="*" --trace I want to run this command on my server as a background process. please help me. 回答1: A method I often use is: nohup bundle exec rake resque:work QUEUE="*" --trace > rake.out 2>&1 & This will keep the task running even if you exit your shell. Then if I want to just observe trace output live, I do: tail -f rake.out And you can examine rake.out at any time. If you need to kill it before completion, you can find it with ps and

Run rake task from outside RAILS_ROOT

一个人想着一个人 提交于 2019-12-07 09:18:07
问题 My RAILS_ROOT is /usr/local/www/application/ If I run 'rake db:migrate RAILS_ENV=production" from within the RAILS_ROOT it works fine. However I can't seem to find a way to run the same command from outside the RAILS_ROOT. 回答1: Try: rake -f $RAILS_ROOT/Rakefile db:migrate RAILS_ENV=production # Assuming you set the environment variable. # Else, just replace $RAILS_ROOT by actual value 回答2: I think you need to re-think your question. When running rake without specifying a rakefile, it's going

Ruby rake loaderror - bundle exec rake not working

北城以北 提交于 2019-12-07 09:01:18
问题 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 (LoadError) from /Users/[name]/.rvm/gems/ruby-2.2.1/bin/rake:23:in `<main>' from /Users/[name]/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval' from /Users/[name]/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>' Trying

How do I use the Clockwork Rails scheduler Gem?

别说谁变了你拦得住时间么 提交于 2019-12-07 08:45:42
问题 I'm having problems with the syntax for the Clockwork scheduler process. I'm actually having similar issues to what is discussed in this thread but never fully answered(How do I use Rails clockwork gem to run rake tasks?) My 'scheduler.rake' is working correctly when I test it with a 'heroku rake send_notifications'. My clock.rb process is working too as it will trigger every 30 seconds. However, I'm having issues with the clock.rb's syntax to correctly run the 'send_notifications' task in my

Rails Seed-Fu Writer why seed got commented out?

蓝咒 提交于 2019-12-07 08:40:31
So, here's my custom rake task: task :backup => :environment do |t| SeedFu::Writer.write('/path/to/file.rb', class_name: 'Category', constraints: [:id] do |w| Category.all.each do |x| w << x end end end And the following result file contains: # DO NOT MODIFY THIS FILE, it was auto-generated. # # Date: 2014-06-15 21:08:13 +0700 # Seeding Category # Written with the command: # # /home/dave/.rvm/gems/ruby-2.1.2/bin/rake backup # Category.seed(:id, #<Category id: 1, name: "foo">, #<Category id: 2, name: "bar">, #<Category id: 3, name: "baz"> ) # End auto-generated file. Question: Why did the

How to invoke rake with non-rake parameters

你说的曾经没有我的故事 提交于 2019-12-07 07:14:54
问题 I have a rake task that creates diagrams: task :diagram do `rake erd filetype=dot disconnected=true` end The execution of this task is quite slow and I guess it is because in the nested rake-invoke statement the whole rails environment is loaded again. I wanted to use Rake::Task['...'].invoke instead. But the erd task has some non-rake arguements ( filetype=dot etc.), which don't seem to work with the invoke method. Is there a way to pass those arguments to rake so that I can use the proper

heroku rake require 'rake/dsl_definition' fix not working + breaking local rake

落爺英雄遲暮 提交于 2019-12-07 07:08:49
问题 I'm having the same heroku rake issues described (and from what I can tell solved) in this question. When I try the fix (include require 'rake/dsl_definition' above require 'rake') I get the same 'uninitialized constant Rake::DSL' error from heroku + I get the error 'no such file to load -- rake/dsl_definition' from my local rake. Without incorporating the fix (using the standard rakefile) I can use rake on my local setup with no errors (with the same heroku error) I'm using rake version 0.8

rake db:structure:dump fails under PostgreSQL / Rails 3.2

让人想犯罪 __ 提交于 2019-12-07 07:08:35
问题 I get this error message: pg_dump: too many command-line arguments (first is "demo_db") Try "pg_dump --help" for more information. rake aborted! Error dumping database Tasks: TOP => db:structure:dump (See full trace by running task with --trace) This used to work under Rails 3.1. I'm using Rails 3.2.3 and PostgreSQL 9.0.5. Other tasks like db:migrate or db:rollback work just fine. 回答1: The pg_dump command is executed in activerecord/lib/active_record/railties/databases.rake at line 428. `pg