Resque - rake aborts - ruby-on-rails-3

Iam new to ruby on rails, currently iam trying to make my task to run at background using resque gem
I had installed redis and resque gem successfully, Now i want to run my rake file which is placed at .../lib/tasks/resque.rake
content in resque.rake
require 'resque/tasks'
task "resque:setup" => :environment
I had started my redis server, Opened a new terminal and moved to my app path now i executed the rake command which is
rake resque:work QUEUE='*'
Now i got an error as
rake aborted!
Don't know how to build task 'resque:work'
.../.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in eval'
.../.rvm/gems/ruby-1.9.3-p448/bin/ruby_noexec_wrapper:14:in'
Please help me to fix the bug

Try the following to start the rake task,
QUEUE=* VVERBOSE=1 rake environment resque:work
From here,
http://bradhe.wordpress.com/2011/05/09/notes-on-working-with-resque-in-rails-3and-ruby-1-8/

Related

Rake aborting with Devise installation on Ruby - cannot migrate the db

I'm trying my hands on Ruby on Rails and needed to set up a simple authentication using devise. I followed the instructions however I'm constantly getting the following error:
>rake db:migrate
rake aborted!
uninitialized constant User
Tasks: TOP => db:migrate => environment
I get this error every time I try to run rake db:migrate - the migrate file does exist in the db/migrate folder but it wont proceed further. Please help.
Run the rake command in trace mode, and the error will become visible.
rake db:migrate --trace
First remove devise_for :users line from routes.rb file then try to run rake db:migrate.

cron and bundle exec problem

I've upgraded to rails 3.0.9 which has introduced the rake issues. I've gotten it all resolved except for a problem with a cron job.
This used to work:
#!/bin/sh
source /usr/local/rvm/scripts/rvm
cd /home/p1r65759/apps/abbc/
/usr/local/bin/rake refresh_events RAILS_ENV=production
But now I get this error:
You have already activated rake 0.8.7, but your Gemfile requires rake 0.9.2. Consider using bundle exec.
/home/p1r65759/apps/abbc/Rakefile:4:in `'
(See full trace by running task with --trace)
How do I modify my script to use bundle exec so it will use the proper version of rake and run successfully?
Thanks.
If you are using bundler for your application then you don't need to use "/usr/local/bin/rake" as a path for rake.
you can just use bundle exec rake
so your new script will be
#!/bin/sh
source /usr/local/rvm/scripts/rvm
cd /home/p1r65759/apps/abbc/
bundle exec rake refresh_events RAILS_ENV=production
bundle exec will work because you are already in your project directory.
And don't forgot to include rake in your Gemfile.
instead of
/usr/local/bin/rake refresh_events RAILS_ENV=production
you should use
bundle exec rake refresh_events RAILS_ENV=production
or better yet install your bundle with --binstubs:
bundle install --binstubs --without development test
then you will have bin/rake:
./bin/rake refresh_events RAILS_ENV=production

rake db:seed issue

I'm seeing a weird issue here when I run rake db:seed or rake db:migrate:
user#ubuntu:~/Desktop/staging/config$ bundle show activeresource
/usr/lib/ruby/gems/1.8/gems/activeresource-3.0.3
user#ubuntu:~/Desktop/staging/config$ rake db:seed
(in /home/rohan/Desktop/staging)
Could not find activesupport-3.0.3 in any of the sources
Try running `bundle install`.
user#ubuntu:~/Desktop/staging/config$ ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [i686-linux]
I don't know what to do. Any help would be appreciated. For the record, I am using RVM.
Run bundle install. This will fix the problem.
you need to require rails in gemfile then run bundle install.
gem "rails", 'version'
now run bundle install
On the assumption that you tried running bundle install like it asked, you probably just need to use:
$ bundle exec rake db:seed
to run rake in the context of the bundle.

Rails 3.1 engine rake task doesnt work

I created a new engine with Rails 3.1.rc1
➜ (ruby-1.9.2-p180#rails3-pre) rails git:(master) be bin/rails plugin new ../first_engine --mountable
rails g scaffold project title:string
Scaffold is generated and now when I run
bundle exec rake db:migrate
I get the following error:
rake aborted!
Don't know how to build task 'app:db:migrate'
Tasks: TOP => db:migrate
Before rc1, it was working. But what happened now? I couldn't figure it out!
Here is the gist with all the steps and backtraces https://gist.github.com/990641
Can anyone put me the right direction?
In you Gemfile or RVM Global Gemset file. Change rake to include the version. e.g.
gem 'rake', '0.8.7'
Just using rake will not work until Rails comes out with a fix. Let us know how you get on. All the best.

heroku rake db:migrate > no such file to load -- faker

I'm trying to deploy a rails 3 app to heroku for the first time. It seems to push up ok but when I try to run
heroku rake db:migrate
I get the following error:
rake aborted!
no such file to load -- faker
/app/98c71cc3-375f-4397-9de3-034dd7268be3/home/Rakefile:7
(See full trace by running task with --trace)
(in /app/98c71cc3-375f-4397-9de3-034dd7268be3/home)
Here's my rakefile (line 7 is the last one):
require File.expand_path('../config/application', __FILE__)
require 'rake'
SampleApp::Application.load_tasks
Now I have a task called sample_data.rake which uses the faker gem to populate the development database with sample data and that task has the line:
require 'faker'
at the top which must be what's causing the problem.
How can I fix this error or is there a way that I can get heroku to ignore this task file? I'm not going to want to populate the production version with nonsense sample data anyway.
By the way, faker is only active in the development environment in my gemsfile:
# gemfiles for the rspec testing environment
group :development do
gem 'rspec-rails', '2.5.0'
gem 'annotate-models', '1.0.4'
gem 'faker', '0.3.1'
end
Move the require statement into the task.
For instance
# sample_data.rake
require 'faker'
task :sample_data => :environment do
# ...
end
to
# sample_data.rake
task :sample_data => :environment do
require 'faker'
# ...
end
In this way, the library will be required only when the task is invoked.
The other alternative is to not require Faker in your rake file.
In fact, it is already loaded by Bundler when the bundle is executed in development.
If you don't want Bundler to load the Gem, use
gem 'faker', '0.3.1', :require => false
for me, Simone’s first approach didn’t work, but the second did: require 'faker' can be deleted from the rake file.
I too commented out require 'faker' in the lib/tasks/sample_data.rake file and (After committing this change via git) pushed the files to heroku, which allowed
$heroku rake db:migrate --app <my app name> to successfully execute, and ergo the heorku site began working again.
Thanks!