No entry in delayed jobs table - jobs
From active admin after create of any record.
In model i have called callback method: after_save :check_delayed_job
def check_delayed_job
run_at_time = Time.now.utc + 50
Delayed::Job.enqueue(AdminNewsletterRequest.new('example#gmail.com', 'sample newsletter content'), :priority => 3 , :run_at => run_at_time)
end
But it is not making any entry in delayed job table and directly executing perform method
In lib i have created one file called admin_newsletter_request.rb
class AdminNewsletterRequest < Struct.new(:email, :subject)
def perform
UserMailer.sample_letter(email, subject).deliver
puts " weekly mail delivered succussfully! "
end
end
I am not getting how can i make entry in delayed jobs table. In log also i am not getting any error.
I want to make entry in delayed job to run the task written in perform method at run_at time.
Is their any alternate way from admin we cam make entry in delayed job to run the task at specific time.
sample application gem list
source 'https://rubygems.org'
gem 'rails', '~> 3.2.0'
gem 'pg'
gem 'daemons'
gem 'delayed_job_active_record'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
For sample application I am able to make entry in delayed job:
Below í is the console output
1.9.2-p290 :002 > Delayed::Job.enqueue(AdminNewsletterRequest.new('example#gmail.com', 'sample newsletter content'), :priority => 3 , :run_at => run_at_time)
(0.4ms) BEGIN
SQL (103.4ms) INSERT INTO "delayed_jobs" ("attempts", "created_at", "failed_at", "handler", "last_error", "locked_at", "locked_by", "priority", "queue", "run_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING "id" [["attempts", 0], ["created_at", Thu, 13 Dec 2012 07:27:49 UTC +00:00], ["failed_at", nil], ["handler", "--- !ruby/struct:AdminNewsletterRequest \nemail: example#gmail.com\nsubject: sample newsletter content\n"], ["last_error", nil], ["locked_at", nil], ["locked_by", nil], ["priority", 3], ["queue", nil], ["run_at", Thu, 13 Dec 2012 07:28:22 UTC +00:00], ["updated_at", Thu, 13 Dec 2012 07:27:49 UTC +00:00]]
(13.6ms) COMMIT
=> #<Delayed::Backend::ActiveRecord::Job id: 9, priority: 3, attempts: 0, handler: "--- !ruby/struct:AdminNewsletterRequest \nemail: san...", last_error: nil, run_at: "2012-12-13 07:28:22", locked_at: nil, failed_at: nil, locked_by: nil, queue: nil, created_at: "2012-12-13 07:27:49", updated_at: "2012-12-13 07:27:49">
1.9.2-p290 :003 >
But the application in which I am working on from the console I am getting something different output. Below is the sample output.
Delayed::Job.enqueue(AdminNewsletterRequest.new('example#gmail.com', 'sample newsletter content'), :priority => 3 , :run_at => run_at_time)
weekly mail delivered succussfully!
=> #<Delayed::Backend::ActiveRecord::Job id: nil, priority: 0, attempts: 0, handler: "--- !ruby/struct:AdminNewsletterRequest \nemail: san...", last_error: nil, run_at: nil, locked_at: nil, failed_at: nil, locked_by: nil, queue: nil, created_at: nil, updated_at: nil>
Working application gem list
source 'http://rubygems.org'
gem 'rails', '~> 3.2.0'
gem 'pg'
# Gem used by scap:
# To minimize merge conflicts, keep this list sorted alphabetically
gem 'activeadmin', '>= 0.5'
gem 'airbrake'
gem 'braintree'
gem 'compass', '~> 0.12.alpha.0'
gem 'context-io', git: 'https://github.com/henrikhodne/context-io.git'
gem 'covenant'
gem 'delayed_job_active_record'
gem 'devise', '~> 2.0.0'
gem 'dragonfly'
gem 'fog'
gem 'foreigner'
gem 'formtastic', '~> 2.2.1'
gem 'friendly_id'
gem 'geocoder'
gem 'gmaps4rails'
gem 'haml', '~> 3.1'
gem 'has_scope'
gem 'hashie'
gem 'httparty'
gem 'i18n-js'
gem 'jquery-rails'
gem 'js-routes'
gem 'kaminari'
gem 'meta_search', '>= 1.1.0.pre'
gem 'newrelic_rpm'
gem 'omniauth'
gem 'omniauth-google-oauth2'
gem 'pry-rails'
gem 'rdiscount'
gem 'seed-fu'
gem 'simple-navigation'
gem 'thin'
gem 'uuidtools'
gem 'valid_email', require: 'valid_email/email_validator'
gem 'valium'
gem 'yipit_n4l', require: 'yipit', git: 'git://github.com/Nest4LessDev/yipit.git'
#gem 'bootstrap-colorpicker-rails', :require => 'bootstrap-colorpicker-rails',
#:git => 'git://github.com/alessani/bootstrap-colorpicker-rails.git'
gem 'jquery-minicolors-rails'
gem 'therubyracer'
gem 'jquery-timepicker-rails'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier', '>= 1.0.3'
gem 'haml_coffee_assets'
end
group :test do
gem 'cucumber-rails', require: false
gem 'database_cleaner'
gem 'email_spec'
gem 'factory_girl_rails'
gem 'capybara'
gem 'rr'
gem 'shoulda-matchers'
gem 'valid_attribute'
gem "shoulda-matchers"
gem 'fake_braintree', require: false
end
group :development, :test do
gem 'launchy'
gem 'rspec-rails'
gem 'awesome_print', :require => 'ap' # pretty print objects in console via `ap my_object`
end
gem 'pry'
Is it problem with the gem dependences, I am not able to track it out.
Related
uninitialized constant ActiveMerchant::Billing::Integrations::Helper (NameError) in Rails 5
I am try to integrate allpay payment. gem 'rails', '>= 5.0.0.rc1', '< 5.1' gem 'activemerchant', :require => 'active_merchant' gem 'active_merchant_allpay' But i am getting: uninitialized constant ActiveMerchant::Billing::Integrations::Helper (NameError).
You will have to add offsite_payments as a dependency,and update any mentions of ActiveSupport::Billing::Integration to OffsitePayments::Integrations https://github.com/activemerchant/active_merchant/issues/1357
Guard starts then exits?
I want to use guard to run my bacon tests, my Gemfile looks like: source 'https://rubygems.org' gem 'sinatra' gem 'sidekiq' gem 'slim' gem 'puma' gem 'nokogiri' gem 'httparty' group :test, :development do gem 'guard' gem 'bacon' gem 'guard-bacon' gem 'libnotify' gem 'rb-inotify' end My Guardfile looks like # parameters: # output => the formatted to use # backtrace => number of lines, nil = everything guard 'bacon', :output => "BetterOutput", :backtrace => 4 do watch(%r{^lib/(.+)\.rb$}) { |m| "specs/lib/#{m[1]}_spec.rb" } watch(%r{specs/.+\.rb$}) end When I run guard the following happens $ guard Bacon: Using output BetterOutput. Bacon: Limiting backtrace to 4 lines. 09:02:05 - INFO - Guard uses Libnotify to send notifications. 09:02:05 - INFO - Guard uses TerminalTitle to send notifications. 09:02:05 - INFO - Guard is now watching at '/home/martin/code/jse-api' Guard::Bacon started. [1] guard(main)> % $ It seems to load everything, get to the guard prompt and exit. I have no idea why?
The issue seems to the version of guard required by guard-bacon 1.1.0 If you force it to the latest version of guard gem 'guard', '>= 1.8.0' It falls back to a older version of guard-bacon 1.0.5 and everything works.
DeviseCreateUsers: migrating create_table(:users) rake aborted
I encountered the following error while running rake db:migrate --trace. my rails version - rails 3.2.0. And i am trying to run the project https://github.com/ninetwentyfour/Hospitium. I am newbie to ruby to ruby on rails errors: ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Invoke disable_rails_admin_initializer (first_time) ** Execute disable_rails_admin_initializer ** Execute environment ** Invoke db:load_config (first_time) ** Invoke rails_env (first_time) ** Execute rails_env ** Execute db:load_config ** Execute db:migrate == **DeviseCreateUsers: migrating** ============================================== -- **create_table(:users)** **rake aborted! An error has occurred, all later migrations canceled: undefined method `database_authenticatable'** for #<ActiveRecord::ConnectionAdapte rs::TableDefinition:0x5d49098> E:/ruby projects/Hospitium Animal Hospital/db/migrate/20110904205556_devise_crea te_users.rb:4:in `block in up' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/connect ion_adapters/abstract/schema_statements.rb:160:in `create_table' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/connect ion_adapters/abstract_mysql_adapter.rb:422:in `create_table' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:450:in `block in method_missing' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:424:in `block in say_with_time' C:/Ruby193/lib/ruby/1.9.1/benchmark.rb:280:in `measure' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:424:in `say_with_time' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:444:in `method_missing' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:334:in `method_missing' E:/ruby projects/Hospitium Animal Hospital/db/migrate/20110904205556_devise_crea te_users.rb:3:in `up' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:358:in `up' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:396:in `block (2 levels) in migrate' C:/Ruby193/lib/ruby/1.9.1/benchmark.rb:280:in `measure' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:396:in `block in migrate' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/connect ion_adapters/abstract/connection_pool.rb:118:in `with_connection' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:377:in `migrate' C:in `migrate' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:704:in `block (2 levels) in migrate' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:761:in `call' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:761:in `ddl_transaction' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:703:in `block in migrate' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:684:in `each' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:684:in `migrate' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:554:in `up' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/migrati on.rb:535:in `migrate' C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/railtie s/databases.rake:153:in `block (2 levels) in <top (required)>' C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:205:in `call' C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:205:in `block in execute' C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `each' C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:200:in `execute' C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:158:in `block in invoke_with_call_chain' C:/Ruby193/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:151:in `invoke_with_call_chain' C:/Ruby193/lib/ruby/1.9.1/rake/task.rb:144:in `invoke' C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:116:in `invoke_task' C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block (2 levels) in top_lev el' C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `each' C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:94:in `block in top_level' C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handlin g' C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:88:in `top_level' C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:66:in `block in run' C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:133:in `standard_exception_handlin g' C:/Ruby193/lib/ruby/1.9.1/rake/application.rb:63:in `run' C:/Ruby193/bin/rake:32:in `<main>' Tasks: TOP => db:migrate My GEM file source 'http://rubygems.org' gem 'rails', '3.2.0' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem "eventmachine", "1.0.0.beta.4.1" gem 'mysql2' gem 'devise' # Devise must be required before RailsAdmin gem 'rails_admin' gem 'nokogiri' gem 'mechanize' gem 'uuidtools' gem 'cancan' gem 'paperclip' gem 'aws-sdk', '~> 1.3.4' gem 'will_paginate' gem 'paper_trail' gem 'oauth' #gem 'twitter' gem 'rest-client' gem 'json' #gem 'libxml-xmlrpc' gem 'bitly' gem 'site_meta' gem 'meta_search' gem 'airbrake' gem 'spork', '~> 1.0rc' gem 'client_side_validations' gem 'jqplot-rails' gem 'asset_sync' gem 'gravatar_image_tag' gem 'best_in_place' gem 'juggernaut' gem 'jquery-rails' #gem 'less-rails-bootstrap' gem "spreadsheet", "0.6.5.8" gem 'to_xls' gem 'sanitize' gem 'redcarpet' gem 'rqrcode-rails3' gem 'octokit' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails' gem 'coffee-rails' gem 'uglifier' gem 'closure-compiler' end group :development do gem 'metrical' end group :production do gem 'home_run', :require=>'date' #gem 'slim_scrooge', :git => "git://github.com/sdsykes/slim_scrooge.git" gem 'dalli' gem 'thin' gem 'pg' gem 'newrelic_rpm' gem 'heroku' end gem "rspec-rails", :group => [:test, :development] group :test do gem "factory_girl_rails" gem "capybara" #gem 'capybara-webkit' gem 'shoulda-matchers' gem 'cucumber-rails', :require => false gem 'database_cleaner' gem 'launchy' gem 'email_spec' end # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' ---------------------------------------------------------------------------------------- as per Said Kaldybaev solution , i tried E:\ruby projects\Hospitium Animal Hospital>rails g devise:install conflict config/initializers/devise.rb Overwrite E:/ruby projects/Hospitium Animal Hospital/config/initializers/devise. rb? (enter "h" for help) [Ynaqdh] h Y - yes, overwrite n - no, do not overwrite a - all, overwrite this and all others q - quit, abort d - diff, show the differences between the old and the new h - help, show this help Overwrite E:/ruby projects/Hospitium Animal Hospital/config/initializers/devise. rb? (enter "h" for help) [Ynaqdh] a force config/initializers/devise.rb identical config/locales/devise.en.yml =============================================================================== Some setup you must do manually if you haven't yet: 1. Ensure you have defined default url options in your environments files. Her e is an example of default_url_options appropriate for a development environm ent in config/environments/development.rb: config.action_mailer.default_url_options = { :host => 'localhost:3000' } In production, :host should be set to the actual host of your application. 2. Ensure you have defined root_url to *something* in your config/routes.rb. For example: root :to => "home#index" 3. Ensure you have flash messages in app/views/layouts/application.html.erb. For example: <p class="notice"><%= notice %></p> <p class="alert"><%= alert %></p> If you are deploying Rails 3.1 on Heroku, you may want to set: config.assets.initialize_on_precompile = false On config/application.rb forcing your application to not access the DB or load models when precompiling your assets. =============================================================================== E:\ruby projects\Hospitium Animal Hospital>rails g devise user invoke active_record Another migration is already named add_devise_to_users: E:/ruby projects/Hospiti um Animal Hospital/db/migrate/20120518093709_add_devise_to_users.rb E:\ruby projects\Hospitium Animal Hospital>rake db:migrate == DeviseCreateUsers: migrating ============================================== -- create_table(:users) rake aborted! An error has occurred, all later migrations canceled: undefined method `database_authenticatable' for # Tasks: TOP => db:migrate (See full trace by running task with --trace)
It seems to problem with that repo at that time, https://github.com/ninetwentyfour/Hospitium, now its working fine.
Not getting RAILS ActiveRecord::Relation returned
I am running RAILS 3.0.9, and for the life of me, I can not get RAILS to do the new lazy loading. My gemfile is: gem 'rails', '3.0.9' gem 'sqlite3' gem 'nifty-generators', '>= 0.4.6' gem 'mocha', :group => :test gem 'carrierwave' gem 'rmagick' gem 'devise', '1.1.rc0' gem 'jquery-rails', '>= 1.0.3' And if I do: Period.where("id=1") I get: [#<Period id: 1, start: "2011-07-06", end: "2011-07-13", created_at: "2011-07-06 23:01:46", updated_at: "2011-07-06 23:01:46"] I really need it to do the ActiveRecord::Relation thing instead! Anyone know what's going on?
You are doing the ActiveRecord::Relation thing. foo = Period.where("id=1") # does AR::Relation thing foo.select( :start ) # does AR::Relation thing p foo.to_a # Does SQL cmd thing cuz u forced AR::Relation thing to SQL You should only see your start column reported. An ActiveRecord::Relation doesn't evaluate until forced to... like you want it to print values.
ERROR Errno::ECONNRESET: Connection reset by peer
gem 'rails', '3.0.0' gem 'devise' gem 'bson_ext', '>= 1.0.7' gem 'bson', '>= 1.0.7' gem 'mongo_mapper', :branch => 'rails3', :git => 'http://github.com/jnunemaker/mongomapper.git' gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper' With the above setup I get the following errors on requests: Started GET "/users/sign_out" for 127.0.0.1 at 2010-09-27 13:16:30 +0300 Processing by Devise::SessionsController#destroy as HTML Redirected to http://localhost:3000/ Completed 302 Found in 19ms [2010-09-27 13:16:31] ERROR Errno::ECONNRESET: Connection reset by peer /usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `eof?' /usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `run' /usr/local/ruby/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread' Started GET "/users/edit" for 127.0.0.1 at 2010-09-27 13:16:35 +0300 Processing by Devise::RegistrationsController#edit as HTML Completed in 16ms [2010-09-27 13:16:35] ERROR Errno::ECONNRESET: Connection reset by peer /usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `eof?' /usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `run' /usr/local/ruby/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread' The user model: class User include MongoMapper::Document plugin MongoMapper::Devise devise :registerable, :database_authenticatable, :recoverable end Ideas?
WebRick has been replaced with Thin. Doing the following worked for me: Gemfile: gem 'thin' Now do bundle install
My quick guess is this looks like you have a problem with your sessions and protect_from_forgery is kicking in. I had a similar problem and smashed my head against the wall for a few days, it turned out to be I was assigning an entire object to a session object instead of just the id. A quick note, non-GET requests are the ones that trigger the protect_from_forgery.
Adding this to my development.rb file fixed the issue. config.assets.raise_runtime_errors = true config.web_console.whitelisted_ips = replace_this_with_the_public_ip