I am trying to use the gem delayed_job from https://github.com/collectiveidea/delayed_job.
I put gem 'delayed_job_active_record' in my Gemfile and did bundle install.
Then, I did:
rails generate delayed_job
rake db:migrate
I believe the migration was supposed to create a table delayed_jobs, but it did not.
What am I missing?
Thanks.
If you are using Rails 3+, you need the following two in your Gemfile:
gem 'delayed_job'
gem 'delayed_job_active_record'
Then change your generate to:
rails g delayed_job:active_record
rake db:migrate
Read more info here and here.
Related
I'm using seeds.rb to populate my db on my dev server running in production mode.
Inside the seeds file I'm using the Faker gem to generate random values. In development mode everything works fine. But if I try to seed in production mode I get an error that Faker is not recognized.
Gemfile:
group :production do
gem 'faker'
end
Seeds.rb:
require 'faker'
user = User.create(name: Faker::Name.name)
So if I run rake db:seed RAILS_ENV=production I get the error message: NameError: uninitialized constant Faker.
Any advice?
I removed the faker gem completely from the Gemfile then made a bundle install. After that I added the gem back to the file and bundle install again.
Now it is working. So the issue was, bundle didn't put it in production the first time I installed.
Will delayed job work with Rails 4?
Currently, I am upgrading my application to Rails 4 and using
gem "delayed_job", :git => 'git://github.com/collectiveidea/delayed_job.git'
in gemfile.
when i run rake jobs:work i got error like this
Error while reserving job: undefined method reserve for
Delayed::Job:Class
any help on this?
add this gem 'delayed_job_active_record' line below gem "delayed_job" to your gem file like this,
gem "delayed_job", :git => 'git://github.com/collectiveidea/delayed_job.git'
gem 'delayed_job_active_record'
and do
bundle install
then try
bundle exec rake jobs:work
hope it will work.
Delayed job will work on rails 4. But the delayed_job folder inside the bin folder.
So, You can run delayed job by following command
bin/delayed_job start`
having a problem with a heroku upload. Quite new to RoR so please excuse the beginners question.
I'm following the Ruby on Rails Tutorial (http://ruby.railstutorial.org), and after the scaffolding, I type heroku rake db:migrate and get the following error:
rake aborted! Please install the postgresql adapter: gem install
activerecord-postgresql-adapter (pg is not part of the bundle. Add it
to Gemfile.)
Tasks: TOP => db:migrate => db:load_config (See full trace by running
task with --trace)
First time around, no problem, but this time I'm getting this error. Any ideas?
By default, a new Rails application is configured to use the SQLite3 database. Heroku doesn't support SQLite3, you must use PostgreSQL.
You have two alternatives:
Keep using SQLite3 in development and test, and switch to PostgreSQL in production.
Switch to PostgreSQL
Either ways, you need to add the pg gem to your Gemfile (assuming you are using Rails 3) and remove sqlite3.
# Gemfile
gem 'pg'
If you want to use Sqlite3 in development and test
# Gemfile
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
You might also need to change your database.yml configuration accordingly.
Not quite the answer Simone, but after more digging, the answer finally came up. I needed to do the following:
In the gemfile, I needed to change gem 'sqlite3' to:
group :development, :test do gem 'sqlite3' end
group :production do gem 'pg' end
and then I needed to heroku create --stack cedar.
Thanks for your help everyone regardless, and I hope this helps someone in the future.
I am trying to install and run Spree on my local machine by following the steps mentioned in Getting started with Spree
However, when I start the server I get the following error:
Could not find table 'pages'
Can someone please help me out with this?
Solved the issue!
Generated the following generators:
spree_static_content and spree_product_assembly which did the magic!
Could not find table 'pages' means rails is not being able to find that table in the database.
In those instructions, review the section 'configuring the database' and then '4.6 Populating the Database'.
It sounds like you want to give spree a go, but don't have experience with Rails.
The spot where you are stuck is not something specific to spree, its a step required in setting up all rails projects referred to as database migration.
For what you need to know about migrations the official Rails Guides are great.
http://guides.rubyonrails.org/migrations.html
For a comprehensive intro to Rails which may also answer a few of your other questions, check out http://railstutorial.org/ruby-on-rails-tutorial-book
If you just want to try stuff.. the spree tute is on track
Do these steps again..
(If it generates an error, to a rake db:drop first to get rid of what you have already done)
rake db:create
rails g spree:site
rake spree:install
rake spree_sample:install
rake db:bootstrap
rake db:migrate
rake db:seed
rake db:sample
rake db:admin:create
Here is what I did to get Spree up and running:
Create a new rails project:
$ rails new spree_project
Add these 5 gems to the projects Gemfile (/spree_project/Gemfile):
gem 'spree', :git => 'git://github.com/spree/spree.git'
gem 'spree_auth_devise', :git => 'git://github.com/spree/spree_auth_devise'
gem 'spree_gateway', :git => 'git://github.com/spree/spree_gateway.git'
gem 'spree_usa_epay'
gem 'spree_skrill'
Run a bundle install and setup the database (rake db:bootstrap did not work for me)
$ bundle install
$ rake db:migrate
$ rake db:seed
$ bundle exec rake spree_sample:load
The 'pages' table is used by the spree_static_content gem. You can either remove the gem from your gemfile, or you can generate migrations for the static content gem:
rails generate spree_static_content:install
If you've included the 'spree_product_assembly' gem as well, you'll want to do the same for it:
rails generate spree_product_assembly:install
Then, reset the database (just to make sure)
rake db:bootstrap
rake db:admin:create
I ran into similar issues after trying the http://spreecommerce.com/documentation/getting_started.html instructions, but it seems to have created a nice demo app after taking these additional steps.
Deploying a Rails3 app, and am having some issues getting rake to find the gems installed by 'bundle install --deployment':
$ rake db:migrate
(in /home/jrdev/rails/testapp)
rake aborted!
!!! Missing the mysql2 gem. Add it to your Gemfile: gem ‘mysql2’
But, that gem in is the Gemfile, and is also in the vendor/bundle folder…
$ bundle show mysql2
/home/jrdev/rails/testapp/vendor/bundle/ruby/1.8/gems/mysql2-0.2.6
My .gemrc file:
gemhome: /home/jrdev/.gems
gempath:
- /home/jrdev/.gems
- /usr/lib/ruby/gems/1.8
I thought rails3 apps already had the bundler code to detect which gems to use? I know I'm using the right rake, too (rake db:migrate --trace starts in /home/jrdev/rails/testapp/vendor/bundle/ruby/1.8/bin/rake). Same result using bundler's exec.
:(
Wouldn't you freaking know I solve it a minute after asking.
My database.yml file was still calling the 'mysql' adapter instead of 'mysql2'.
Still, what an OBSCURE error message!
In /home/jrdev/rails/testapp, you should find a file called Gemfile. Look into it and just add the line
gem 'mysql2'
somewhere.