I've a huge problem with asset precompile on production mode...
I'm using RequireJS and Conditioner.js to modularize my frontend, there's no problem on my development server (without asset precompilation), but I can't precompile asset on production.
Here is my requirejs.yml config:
map:
'*':
conditioner: "lib/conditioner"
modules:
- name: "application"
- name: "jquery"
- name: "conditioner"
paths:
jquery: "lib/jquery"
conditioner: "lib/conditioner"
priority: ['jquery', 'conditioner', 'application']
Here is a stack from my console:
Requirejs::BuildError: Cannot compute digest for missing asset:/home/birdnet/rails_projects/reczna-chks.pl/tmp/requirejs/dst/conditioner.js
/home/birdnet/.rvm/gems/ruby-2.1.2#reczna-chks/gems/requirejs-rails-0.9.5/lib/requirejs/rails/builder.rb:22:in `digest_for'
/home/birdnet/.rvm/gems/ruby-2.1.2#reczna-chks/gems/requirejs-rails-0.9.5/lib/tasks/requirejs-rails_tasks.rake:149:in `block (5 levels) in <top (required)>'
/home/birdnet/.rvm/gems/ruby-2.1.2#reczna-chks/gems/requirejs-rails-0.9.5/lib/tasks/requirejs-rails_tasks.rake:149:in `sub'
/home/birdnet/.rvm/gems/ruby-2.1.2#reczna-chks/gems/requirejs-rails-0.9.5/lib/tasks/requirejs-rails_tasks.rake:149:in `block (4 levels) in <top (required)>'
/home/birdnet/.rvm/gems/ruby-2.1.2#reczna-chks/gems/requirejs-rails-0.9.5/lib/tasks/requirejs-rails_tasks.rake:146:in `each'
/home/birdnet/.rvm/gems/ruby-2.1.2#reczna-chks/gems/requirejs-rails-0.9.5/lib/tasks/requirejs-rails_tasks.rake:146:in `block (3 levels) in <top (required)>'
Tasks: TOP => requirejs:precompile:all => requirejs:precompile:digestify_and_compress
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/home/birdnet/.rvm/rubies/ruby-2.1.2/bin/r...]
/home/birdnet/.rvm/gems/ruby-2.1.2#reczna-chks/gems/requirejs-rails-0.9.5/lib/tasks/requirejs-rails_tasks.rake:19:in `ruby_rake_task'
/home/birdnet/.rvm/gems/ruby-2.1.2#reczna-chks/gems/requirejs-rails-0.9.5/lib/tasks/requirejs-rails_tasks.rake:86:in `block (3 levels) in <top (required)>'
/home/birdnet/.rvm/gems/ruby-2.1.2#reczna-chks/bin/ruby_executable_hooks:15:in `eval'
/home/birdnet/.rvm/gems/ruby-2.1.2#reczna-chks/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => assets:precompile => requirejs:precompile:external
It seems to be a bad path in configuration, but in my opinion every path looks ok.
Can anyone help me? I'm really stuck but won't to disable precompilation on production.
Try changing the path in modules to:
- name: "lib/conditioner"
Related
I got a database to seed to test my code. When I run rake db:seed to seed the database, I get the error below.
I expected the console to be blank: this means the data has been seeded.
Error:
[19:19:41] (master) simple-partials-lab-noukod-000
// ♥ rake db:seed
/usr/local/rvm/gems/ruby-2.6.1/gems/activesupport-4.2.11.1/lib/active_support/core_ext/object/duplicable.rb:111: warning: BigDecimal.new is deprecated; use BigDecimal() method instead.
rake aborted!
ArgumentError: missing keywords: from, to
/usr/local/rvm/gems/ruby-2.6.1/gems/faker-2.2.1/lib/faker/default/date.rb:6:in `between'
/home/considerate-transform-1229/simple-partials-lab-noukod-000/db/seeds.rb:9:in `block in <top (required)>'
/home/considerate-transform-1229/simple-partials-lab-noukod-000/db/seeds.rb:8:in `times'
/home/considerate-transform-1229/simple-partials-lab-noukod-000/db/seeds.rb:8:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.6.1/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:268:in `load'
/usr/local/rvm/gems/ruby-2.6.1/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:268:in `block in load'
/usr/local/rvm/gems/ruby-2.6.1/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:240:in `load_dependency'
/usr/local/rvm/gems/ruby-2.6.1/gems/activesupport-4.2.11.1/lib/active_support/dependencies.rb:268:in `load'
/usr/local/rvm/gems/ruby-2.6.1/gems/railties-4.2.11.1/lib/rails/engine.rb:547:in `load_seed'
/usr/local/rvm/gems/ruby-2.6.1/gems/activerecord-4.2.11.1/lib/active_record/tasks/database_tasks.rb:253:in `load_seed'
/usr/local/rvm/gems/ruby-2.6.1/gems/activerecord-4.2.11.1/lib/active_record/railties/databases.rake:173:in `block (2 levels) in <top (required)>'
/usr/local/rvm/gems/ruby-2.6.1/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `eval'
/usr/local/rvm/gems/ruby-2.6.1/bin/ruby_executable_hooks:24:in `<main>'
Tasks: TOP => db:seed
(See full trace by running task with --trace)
Looks like you're using Faker with the old syntax. It recently changed to require keyword arguments rather than positional arguments.
You need to follow the updated syntax:
Faker::Date.between(from: 2.days.ago, to: Date.today) #=> "Wed, 24 Sep 2014"
Note the keywords from: and to: which specify the arguments. Order of arguments is not important, and the reverse order will work just the same:
Faker::Date.between(to: Date.today, from: 2.days.ago) #=> "Wed, 24 Sep 2014"
Additional information available in their docs: https://github.com/faker-ruby/faker/blob/master/doc/default/date.md
By executing the whenever --update-crontab command, the following error returns:
/usr/lib/ruby/vendor_ruby/whenever/cron.rb:132:in `parse_as_string': Couldn't parse: 31557600 (ArgumentError)
from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:112:in `parse_time'
from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:50:in `time_in_cron_syntax'
from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:42:in `output'
from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:36:in `block (2 levels) in output'
from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:35:in `each'
from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:35:in `block in output'
from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:34:in `each'
from /usr/lib/ruby/vendor_ruby/whenever/cron.rb:34:in `output'
from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:151:in `block (2 levels) in cron_jobs'
from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:147:in `each'
from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:147:in `block in cron_jobs'
from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:146:in `each'
from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:146:in `cron_jobs'
from /usr/lib/ruby/vendor_ruby/whenever/job_list.rb:65:in `generate_cron_output'
from /usr/lib/ruby/vendor_ruby/whenever.rb:10:in `cron'
from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:54:in `whenever_cron'
from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:106:in `updated_crontab'
from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:35:in `run'
from /usr/lib/ruby/vendor_ruby/whenever/command_line.rb:6:in `execute'
from /usr/bin/whenever:41:in `<main>'
My schedule.rb file:
every 1.year do
rake "maintenances:renew"
end
Any ideas?
If you're having problems with 1.year method, you can use the two following alternatives.
1 - Shortcuts
every :year do
rake "maintenances:renew"
end
2 - Expressions
every '0 0 1 12 *' do
rake "maintenances:renew"
end
If you want to learn more about these options, check the official documentation.
To test expressions, I recommend crontab.guru
I created a rake task for import a csv with smarter_csv gem.
Throws the following message, i added the entire error code if it helps:
rake import_csv:import_csv
Digest::Digest is deprecated; use Digest
I, [2017-03-01T11:46:08.551994 #7029] INFO -- : ** [Raven] Raven 0.14.0 configured not to send errors.
rake aborted!
NoMethodError: undefined method `close' for nil:NilClass
/home/my_user/.rvm/gems/ruby-2.1.1#my_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:223:in `ensure in process'
/home/my_user/.rvm/gems/ruby-2.1.1#my_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:223:in `process'
/home/my_user/my_app/lib/tasks/import_csv.rake:7:in `block (2 levels) in <top (required)>'
/home/my_user/.rvm/gems/ruby-2.1.1#my_app/bin/ruby_executable_hooks:15:in `eval'
/home/my_user/.rvm/gems/ruby-2.1.1#my_app/bin/ruby_executable_hooks:15:in `<main>'
Errno::ENOENT: No such file or directory # rb_sysopen - /csv_imports/pacientes.csv
/home/my_user/.rvm/gems/ruby-2.1.1#my_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:23:in `initialize'
/home/my_user/.rvm/gems/ruby-2.1.1#my_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:23:in `open'
/home/my_user/.rvm/gems/ruby-2.1.1#my_app/gems/smarter_csv-1.1.4/lib/smarter_csv/smarter_csv.rb:23:in `process'
/home/my_user/my_app/lib/tasks/import_csv.rake:7:in `block (2 levels) in <top (required)>'
/home/my_user/.rvm/gems/ruby-2.1.1#my_app/bin/ruby_executable_hooks:15:in `eval'
/home/my_user/.rvm/gems/ruby-2.1.1#my_app/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => import_csv:import_csv
(See full trace by running task with --trace)
This is the code on the rake task:
namespace :import_csv do
desc "import csv file"
task import_csv: :environment do
require 'smarter_csv'
filename = '/csv_imports/file.csv'
options = {:key_mapping => { :downcase_header => true }}
SmarterCSV.process(filename, options) do |array|
CsvImports.create( array.first )
end
end
end
This solved just witha dot. route issue.
./csv_imports/file.csv
I have a very strange issue: Sidekiq tries to establish connection to Redis in test environment.
I'm using sidekiq 3.2.2 with rspec-sidekiq 2.0.0.beta on rails 4.1.4 with ruby 2.1.2
Here is my test
require 'rails_helper'
describe FetchWorker::FetchWorker do
it 'runs in fetch queue' do
expect(subject).to be_processed_in :fetch
end
it 'not retry when it fails' do
expect(subject).to be_retryable false
end
it 'enqueues the new job' do
FactoryGirl.create(:history, running: false)
FetchWorker::FetchWorker.perform_async 'FetchWorker', true
expect(FetchWorker::FetchWorker).to have_enqueued_job('FetchWorker', true)
end # enqueue job
describe '#perform' do
let!(:settleddate) { (Time.now - 2.minutes).iso8601(10) }
let!(:lock_date) { (Time.now - 5.minutes).iso8601(10) }
context 'success' do
before do
FactoryGirl.create(:history, running: false, NEW_TRANSACTIONS: lock_date)
FactoryGirl.create(:abp_transaction, settleddate: settleddate, settledyn: 1, transactiontypeid: 1, accountid: 10966)
end
it 'perform worker' do
user = FactoryGirl.build_stubbed(:user, account_id: 10966)
worker = FetchWorker::FetchWorker.new
worker.perform
expect(user.transactions.count).to eq(1)
end # it perform worker
end # context success
context 'fail' do
it 'perform worker' do
FactoryGirl.create(:history, running: false, NEW_TRANSACTIONS: lock_date)
FactoryGirl.create(:abp_transaction, settleddate: settleddate, settledyn: 1, transactiontypeid: 1, accountid: 10966)
user = FactoryGirl.build_stubbed(:user, account_id: 10966)
worker = FetchWorker::FetchWorker.new
allow(worker).to receive(:process_transactions).and_raise('some error')
expect{ worker.perform }.to raise_error
end # it perform worker
end # context fail
end # describe perform
end # describe FetchWorker
If I try to run bundle exec rspec with working redis, I'm getting pretty nice output:
retgoat#ubuntu:/media/sf_offside/agent_system$ bundle exec rspec
[rspec-sidekiq] WARNING! Sidekiq will *NOT* process jobs in this environment. See https://github.com/philostler/rspec-sidekiq/wiki/FAQ-&-Troubleshooting
2014-08-22T11:35:52.377Z 5140 TID-4ehb4 INFO: Fetching transactions from 2014-08- 22T18:30:52.3447179170+07:00.
2014-08-22T11:35:52.394Z 5140 TID-4ehb4 INFO: Lock released.
2014-08-22T11:35:52.451Z 5140 TID-4ehb4 INFO: Fetching transactions from 2014-08- 22T18:30:52.4160675140+07:00.
Finished in 29.88 seconds (files took 17.24 seconds to load)
119 examples, 0 failures
Coverage report generated for RSpec to /media/sf_offside/agent_system/coverage. 872 / 873 LOC (99.89%) covered.
But if I try to run tests with stopped redis I'm getting this:
retgoat#ubuntu:/media/sf_offside/agent_system$ bundle exec rspec
Coverage report generated for RSpec to /media/sf_offside/agent_system/coverage. 377 / 855 LOC (44.09%) covered.
/home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis/client.rb:309:in `rescue in establish_connection': Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED) (Redis::CannotConnectError)
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis/client.rb:304:in `establish_connection'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis/client.rb:85:in `block in connect'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis/client.rb:266:in `with_reconnect'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis/client.rb:84:in `connect'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis/client.rb:326:in `ensure_connected'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis/client.rb:197:in `block in process'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis/client.rb:279:in `logging'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis/client.rb:196:in `process'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis/client.rb:102:in `call'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis.rb:784:in `block in get'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis.rb:37:in `block in synchronize'
from /home/retgoat/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis.rb:37:in `synchronize'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/redis-3.1.0/lib/redis.rb:783:in `get'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/sidetiq- 0.6.1/lib/sidetiq/schedulable.rb:65:in `get_schedulable_key'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/sidetiq-0.6.1/lib/sidetiq/schedulable.rb:45:in `recurrence'
from /media/sf_offside/agent_system/app/workers/fetch_worker.rb:6:in `<class:FetchWorker>'
from /media/sf_offside/agent_system/app/workers/fetch_worker.rb:2:in `<module:FetchWorker>'
from /media/sf_offside/agent_system/app/workers/fetch_worker.rb:1:in `<top (required)>'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:348:in `require_or_load'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:480:in `load_missing_constant'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:180:in `const_missing'
from /media/sf_offside/agent_system/spec/workers/fetch_worker_spec.rb:3:in `<top (required)>'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `block in load'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `block in load_spec_files'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `each'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in `load_spec_files'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:97:in `setup'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in `run'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/rspec-core- 3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
from /home/retgoat/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>'
from /home/retgoat/.rvm/gems/ruby-2.1.2/bin/rspec:23:in `load'
from /home/retgoat/.rvm/gems/ruby-2.1.2/bin/rspec:23:in `<main>'
from /home/retgoat/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
from /home/retgoat/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
I just have no idea why it happens.
I'm also opened a new issue in sidekiq on Github https://github.com/mperham/sidekiq/issues/1907
Could you please help with that?
Many thanks.
UPDATE
As #infused mentioned there is a bug: https://github.com/tobiassvn/sidetiq/issues/103
Here is the workaround:
recurrence { minutely(5) } unless Rails.env.test?
Worked like a charm! :)
Many thanks
The problem is that you are using sidetiq which has a bug which causes it to try to connect when it shouldn't.
For some reason, on heroku it will not allow me to import models (this is for the Bonsai ElasticSearch add-on). It's just showing connection refused. I'm not sure how to resolve this. I've searched the internet and I can't find anything that will even hint me in the right direction to solve this. I checked to make sure the server was up and manually created the index with curl. Do the initializers get launched when running a rake task?
I set the elasticsearch url in the config/initializers/bonsai.rb file:
config/initializers/bonsai.rb
if Rails.env == 'production'
ENV['ELASTICSEARCH_URL'] = ENV['BONSAI_URL']
end
Gemfile snippet
# Used for elastic search
gem 'elasticsearch-model', github: 'elasticsearch/elasticsearch-rails'
gem 'elasticsearch-rails', github: 'elasticsearch/elasticsearch-rails'
gem 'multi_json'
gem 'json'
Error
heroku run rake environment elasticsearch:import:all DIR=app/models
Running `rake environment elasticsearch:import:all DIR=app/models` attached to terminal... up, run.5751
[IMPORT] Loading models from: app/models
[IMPORT] Processing model: Firm...
rake aborted!
Connection refused - connect(2)
/app/vendor/bundle/ruby/2.0.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:80:in `perform_request'
/app/vendor/bundle/ruby/2.0.0/gems/faraday-0.9.0/lib/faraday/adapter/net_http.rb:39:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/faraday-0.9.0/lib/faraday/rack_builder.rb:139:in `build_response'
/app/vendor/bundle/ruby/2.0.0/gems/faraday-0.9.0/lib/faraday/connection.rb:377:in `run_request'
/app/vendor/bundle/ruby/2.0.0/gems/elasticsearch-transport-1.0.1/lib/elasticsearch/transport/transport/http/faraday.rb:21:in `block in perform_request'
/app/vendor/bundle/ruby/2.0.0/gems/elasticsearch-transport-1.0.1/lib/elasticsearch/transport/transport/base.rb:187:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/elasticsearch-transport-1.0.1/lib/elasticsearch/transport/transport/base.rb:187:in `perform_request'
/app/vendor/bundle/ruby/2.0.0/gems/elasticsearch-transport-1.0.1/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
/app/vendor/bundle/ruby/2.0.0/gems/elasticsearch-transport-1.0.1/lib/elasticsearch/transport/client.rb:102:in `perform_request'
/app/vendor/bundle/ruby/2.0.0/gems/elasticsearch-api-1.0.1/lib/elasticsearch/api/actions/bulk.rb:81:in `bulk'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/elasticsearch-rails-26a3ba246968/elasticsearch-model/lib/elasticsearch/model/importing.rb:78:in `block in import'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/elasticsearch-rails-26a3ba246968/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb:88:in `block in __find_in_batches'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.0/lib/active_record/relation/batches.rb:125:in `find_in_batches'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.0/lib/active_record/querying.rb:9:in `find_in_batches'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/elasticsearch-rails-26a3ba246968/elasticsearch-model/lib/elasticsearch/model/proxy.rb:80:in `method_missing'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/elasticsearch-rails-26a3ba246968/elasticsearch-model/lib/elasticsearch/model/adapters/active_record.rb:86:in `__find_in_batches'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/elasticsearch-rails-26a3ba246968/elasticsearch-model/lib/elasticsearch/model/importing.rb:77:in `import'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/elasticsearch-rails-26a3ba246968/elasticsearch-model/lib/elasticsearch/model.rb:113:in `import'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/elasticsearch-rails-26a3ba246968/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb:59:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/elasticsearch-rails-26a3ba246968/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb:99:in `block (4 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/elasticsearch-rails-26a3ba246968/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb:82:in `each'
/app/vendor/bundle/ruby/2.0.0/bundler/gems/elasticsearch-rails-26a3ba246968/elasticsearch-rails/lib/elasticsearch/rails/tasks/import.rb:82:in `block (3 levels) in <top (required)>'
Tasks: TOP => elasticsearch:import:model
(See full trace by running task with --trace)
by the way can someone create an 'elasticsearch-rails' tag since its the upcoming replacement for Tire
Elasticsearch Rails does not use the same mechanism as Tire to set its URL in production on Heroku. To have this work correctly with Bonsai search, you have to have a different url specification. Fortunately a guy has made a gem (https://rubygems.org/gems/bonsai-elasticsearch-rails) to eliminate the needless, mandatory creation of a initializer by everyone.
Simply add this gem to your gem file under your production group. The version may be subject to change since it's so new:
gem 'bonsai-elasticsearch-rails', '~> 0.0.4'
If you're more curious about what this gem actually does, the entire source is below:
require "bonsai/elasticsearch/rails/version"
puts "Starting up a new ElasticSearch client with #{ENV['BONSAI_URL']}"
Elasticsearch::Model.client = Elasticsearch::Client.new url: ENV['BONSAI_URL']
I know, simple right...