rake-task

testing rake tasks with Rspec is not accepting arguments

浪子不回头ぞ 提交于 2019-12-01 03:44:15
问题 I am trying to write a Rspec test for one of my rake task, according to this post by Stephen Hagemann. lib/tasks/retry.rake : namespace :retry do task :message, [:message_id] => [:environment] do |t, args| TextMessage.new.resend!(args[:message_id]) end end spec/tasks/retry_spec.rb : require 'rails_helper' require 'rake' describe 'retry namespace rake task' do describe 'retry:message' do before do load File.expand_path("../../../lib/tasks/retry.rake", __FILE__) Rake::Task.define_task(

rake db:migrate is being aborted due to rake version difference [duplicate]

我的梦境 提交于 2019-11-30 13:57:33
This question already has an answer here: You have already activated X, but your Gemfile requires Y 6 answers I am getting the error rake db:migrate --trace rake aborted! You have already activated rake 10.1.1, but your Gemfile requires rake 10.1.0. Using bundle exec may solve this. /Users/iang/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:33:in `block in setup' /Users/iang/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/runtime.rb:19:in `setup' /Users/iang/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup' /Users/iang

Use environment variables in Rake task

怎甘沉沦 提交于 2019-11-30 09:56:41
task :some_task, :environment do |t, args| puts Rails.env #=> development, production, etc puts ENV #=> {} end I set some environment variables (either via a local .env, or via Heroku Config via Herokusan), such as which AWS bucket to use, and I want to reference them in the rake task, but ENV is an empty hash. I know something related to environment gets done because of the :environment task dependency and that Rails.env has a value, but I'm not clear on the details. So, how can I use ENV in a Rake task? Two good ways to do it: Use Heroku's "Foreman" tool. Put all your environment variables

Use environment variables in Rake task

被刻印的时光 ゝ 提交于 2019-11-29 14:55:31
问题 task :some_task, :environment do |t, args| puts Rails.env #=> development, production, etc puts ENV #=> {} end I set some environment variables (either via a local .env, or via Heroku Config via Herokusan), such as which AWS bucket to use, and I want to reference them in the rake task, but ENV is an empty hash. I know something related to environment gets done because of the :environment task dependency and that Rails.env has a value, but I'm not clear on the details. So, how can I use ENV in

How to build task 'db:populate'

我的未来我决定 提交于 2019-11-29 06:24:23
1 namespace :db do 2 desc "Fill database with sample videos" 3 task :populate => :environment do 4 require 'faker' 5 Rake::Task['db:reset'].invoke 6 100.times do |n| 7 headline = Faker::Lorem.sentence(3) 8 video = Faker::Lorem.words(5) 9 Video.create!(:headline => headline, 10 :video => video) 11 end 12 end 13 end I currently have this rake task in lib/tasks/sample_data.rb When running rake db:populate I get the error, Don't know how to build task 'db:populate' . How do I get around this? Notes: I am a newbie in Rails/Ruby. I am using Rails 3. Try renaming the file to sample_data.rake. I was

How do I override rake tasks for a custom database adapter?

我只是一个虾纸丫 提交于 2019-11-28 01:01:12
问题 I've written a custom database adapter that works correctly and effectively when a rails server is running. I would now like to add the usual rake task definitions for creating, dropping and migrating the database. I would like to implement: db:[drop|create|migrate] How do I package these definitions with my gem so that they override the default ones for anyone who uses the gem? I looked through the source of other adapters but all the rake task logic appears to be baked into active_record

How to build task 'db:populate'

偶尔善良 提交于 2019-11-27 23:59:06
问题 1 namespace :db do 2 desc "Fill database with sample videos" 3 task :populate => :environment do 4 require 'faker' 5 Rake::Task['db:reset'].invoke 6 100.times do |n| 7 headline = Faker::Lorem.sentence(3) 8 video = Faker::Lorem.words(5) 9 Video.create!(:headline => headline, 10 :video => video) 11 end 12 end 13 end I currently have this rake task in lib/tasks/sample_data.rb When running rake db:populate I get the error, Don't know how to build task 'db:populate' . How do I get around this?

PG undefinedtable error relation users does not exist

◇◆丶佛笑我妖孽 提交于 2019-11-26 15:53:23
I see this question up before, but only for rspec. I am not create test yet because its too advance for me but one day soon i will! :P I am getting this error when i try to sign up/ log in with my app. I'm not sure where to look to fix it. I use devise to create my user and also omniauth2 to sign in with google . this is the error ActiveRecord::StatementInvalid at /users/auth/google_oauth2/callback PG::UndefinedTable: ERROR: relation "users" does not exist LINE 5: WHERE a.attrelid = '"users"'::regclass ^ : SELECT a.attname, format_type(a.atttypid, a.atttypmod), pg_get_expr(d.adbin, d.adrelid),