I am experiencing the below exception if I am running the sidekiq:
It can be seen that the date_at_relative_to_now class is required twice by some weird reason despite the fact that I am not using require nor require_relative in my application. I am relying exclusively to rails autoload feature.
Any ide or help is appreciated
→ sidekiq
loading...
loading...
Cannot define multiple 'included' blocks for a Concern
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/concern.rb:126:in `included'
/Users/boti/Rails/checker/app/exhibits/concerns/date_at_relative_to_now.rb:6:in `<module:DateAtRelativeToNow>'
/Users/boti/Rails/checker/app/exhibits/concerns/date_at_relative_to_now.rb:3:in `<top (required)>'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:457:in `load'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:457:in `block in load_file'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:647:in `new_constants_in'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:456:in `load_file'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:354:in `require_or_load'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:317:in `depend_on'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:233:in `require_dependency'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/engine.rb:472:in `block (2 levels) in eager_load!'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/engine.rb:471:in `each'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/engine.rb:471:in `block in eager_load!'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/engine.rb:469:in `each'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/engine.rb:469:in `eager_load!'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/engine.rb:346:in `eager_load!'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/application/finisher.rb:56:in `each'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `instance_exec'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/initializable.rb:30:in `run'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/boti/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:226:in `block in tsort_each'
/Users/boti/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
/Users/boti/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:429:in `each_strongly_connected_component_from'
/Users/boti/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:347:in `block in each_strongly_connected_component'
/Users/boti/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `each'
/Users/boti/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `call'
/Users/boti/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:345:in `each_strongly_connected_component'
/Users/boti/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:224:in `tsort_each'
/Users/boti/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/tsort.rb:203:in `tsort_each'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/initializable.rb:54:in `run_initializers'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/railties-4.2.0/lib/rails/application.rb:352:in `initialize!'
/Users/boti/Rails/checker/config/environment.rb:5:in `<top (required)>'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/sidekiq-3.3.4/lib/sidekiq/cli.rb:241:in `boot_system'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/sidekiq-3.3.4/lib/sidekiq/cli.rb:50:in `run'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/gems/sidekiq-3.3.4/bin/sidekiq:8:in `<top (required)>'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/bin/sidekiq:23:in `load'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/bin/sidekiq:23:in `<main>'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/bin/ruby_executable_hooks:15:in `eval'
/Users/boti/.rvm/gems/ruby-2.2.0@checker/bin/ruby_executable_hooks:15:in `<main>'
ruby-2.2.0@checker:boti:~/Rails/checker git:active_job_exercise
→
The code for date_at_relative_to_now.rb:
module DateAtRelativeToNow
puts 'loading...'
extend ActiveSupport::Concern
included do
include ActionView::Helpers::DateHelper
end
module ClassMethods
attr_reader :field
def applicable_to?(object, _context)
field = self.field
object.respond_to? field
end
def applicable_to(field)
@field = field
define_method field do
date = __getobj__.send self.__class__.field
if date.present?
"#{distance_of_time_in_words_to_now date} ago"
else
'Never'
end
end
end
end
end