sunspot_solr error on heroku? - ruby-on-rails

I'm using 'sunspot_rails', '~> 2.0.0.pre.120415' for Solr search in my rails app and deploy it on heroku (two separate application).
It's working fine on one application but throw error on other.
I have checked the heroku environment and found that -
one app is on cedar stack and ruby version is 1.9.2p290. (Working fine)
other one is on bamboo stack and ruby version is 1.9.2p180 (throw error)
So, Is this the ruby version problem or heroku stack problem ?
Ruby version on development environment is 1.9.2p290.
Error
$ heroku run rake sunspot:reindex
Running rake sunspot:reindex attached to terminal... up, run.8567
rake aborted!
uninitialized constant Sunspot::Adapters::Registry::Forwardable
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:310:in `<class:Registry>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:309:in `<module:Adapters>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:34:in `<module:Sunspot>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot/adapters.rb:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:18:in `block in <top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:15:in `each'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot-2.0.0.pre.120925/lib/sunspot.rb:15:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot_rails-2.0.0.pre.120925/lib/sunspot/rails.rb:1:in `<top (required)>'
/app/.bundle/gems/ruby/1.9.1/gems/sunspot_rails-2.0.0.pre.120925/lib/sunspot_rails.rb:6:in `<top (required)>'
/app/config/application.rb:7:in `<top (required)>'
/app/Rakefile:4:in `require'
/app/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

To be even more clear, at the top of adapters.rb (sunspot/lib/sunspot/adapters.rb), add the following line:
require 'forwardable'
module Sunspot
#
# Sunspot works by saving references to the primary key (or natural ID) of

I have found the solution.
Actually it's a environment problem on heroku.On local system the ruby version is ruby 1.9.2p290 and on heroku is ruby 1.9.2p180. Ruby 1.9.2p180 doesn't include 'Forwardable' module. So I just need to include 'Forwardable' module in my application.

Related

uninitialized class variable ##schemes in URI

I am trying to migrate schemas but when I do the following logs are shown :
$ rails db:migrate
rails aborted!
NameError: uninitialized class variable ##schemes in URI
Did you mean? scheme_list
D:/Projects/lms-2021/config/application.rb:3:in `require'
D:/Projects/lms-2021/config/application.rb:3:in `<top (required)>'
D:/Projects/lms-2021/Rakefile:4:in `require_relative'
D:/Projects/lms-2021/Rakefile:4:in `<top (required)>'
bin/rails:9:in `require'
bin/rails:9:in `<main>'
(See full trace by running task with --trace)
how to fix this?
windows 10 pro
git bash terminal
rails v 5.1.7
ruby v 3.1.2
For those who don't read comments... installing or updating(if not installed) gem 'globalid' helped for me.
add gem 'globalid', '~> 1.0' and then bundle install
It would be great if you could share the code of your migration that you're running and the code of URI as well. Apparently, the class variable ##schemes in URI is not initialized.
you can initialize it using (or equals) || =
for example, if ##schemes is an array you can do something like that:
##schemes ||= []

rake aborted! NameError: uninitialized constant ActiveRecord::VERSION error while using rake db:migrate

I am new to ruby on rails. I want to re-create a production setup on my local system for development purposes.I seem to have run into a problem during migration of database.
I am using Ubuntu 18.04 OS. I have installed mysql-server, ruby 2.3.2 , rails 5.0, libmysqld-dev and mysql2 gem successfully. I was able to create a database and import the SQL file for table creation. To do pending migration, I executed rake db:migrate. I am getting the following error.
rake aborted!NameError: uninitialized constant ActiveRecord::VERSION
/home/raj/.rvm/gems/ruby-2.3.2/gems/activerecord-session_store-1.1.1/lib/action_dispatch/session/active_record_store.rb:151:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/gems/activerecord-session_store-1.1.1/lib/active_record/session_store.rb:2:in `require'
/home/raj/.rvm/gems/ruby-2.3.2/gems/activerecord-session_store-1.1.1/lib/active_record/session_store.rb:2:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/gems/activerecord-session_store-1.1.1/lib/activerecord/session_store.rb:1:in `require'
/home/raj/.rvm/gems/ruby-2.3.2/gems/activerecord-session_store-1.1.1/lib/activerecord/session_store.rb:1:in `<top (required)>'
/home/raj/IRIS/config/application.rb:7:in `<top (required)>'
/home/raj/IRIS/Rakefile:4:in `require'
/home/raj/IRIS/Rakefile:4:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/bin/ruby_executable_hooks:24:in `eval'
/home/raj/.rvm/gems/ruby-2.3.2/bin/ruby_executable_hooks:24:in `<main>'
LoadError: cannot load such file -- activerecord-session_store
/home/raj/IRIS/config/application.rb:7:in `<top (required)>'
/home/raj/IRIS/Rakefile:4:in `require'
/home/raj/IRIS/Rakefile:4:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/home/raj/.rvm/gems/ruby-2.3.2/bin/ruby_executable_hooks:24:in `eval'
/home/raj/.rvm/gems/ruby-2.3.2/bin/ruby_executable_hooks:24:in `<main>'
(See full trace by running task with --trace)
Regarding the error in active_record_store.rb line number 151, the code is as follows:
if ActiveRecord::VERSION::MAJOR == 4
require 'action_dispatch/session/legacy_support'
ActionDispatch::Session::ActiveRecordStore.send(:include, ActionDispatch::Session::LegacySupport)
end
During RVM installation rails latest version was also installed somehow. Removing all the gems and doing bundle install worked.
Try running the below mentioned command
gem install activerecord
Hope this helps.
Can you add this to the top of active_record_store.rb to see if it works?
require 'active_record/version'

Active storage installation does not work

I have a Rails application for which I wanna install the gem active storage so that I can save photos on my application and interact with them. Despite that, I input in the console
rails active_storage: install
and I get the following error:
rails aborted!
LoadError: cannot load such file -- active_storage
C:/Users/andri/Desktop/hoagieShop/hoagieShop/config/application.rb:4:in `require'
C:/Users/andri/Desktop/hoagieShop/hoagieShop/config/application.rb:4:in `<top (required)>'
C:/Users/andri/Desktop/hoagieShop/hoagieShop/Rakefile:4:in `require_relative'
C:/Users/andri/Desktop/hoagieShop/hoagieShop/Rakefile:4:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
(See full trace by running task with --trace)
Does anyone understand why? I tried the solution provided here: rails active_storage:install IS NOT WORKING but it did not work.
in terminal/app folder
reset db
rake db:reset
migrate db
rake db:migrate
update the gem file
bundle install

Confirm that will_paginate has loaded

To solve my problem, which is discussed in Why do I get “undefined method 'paginate'” error in production? I'm running
bundle exec rails runner -e production 'WillPaginate'
on the server like suggested in this github issue:
https://github.com/mislav/will_paginate/issues/308#issuecomment-17167158
Question: If I don't get any output, is that the confirmation, that will_paginate is running correctly?
I'm using: Ruby 2.0.0p247, Rails 4.0.0, Ubuntu 12.10 LTS, Unicorn, Capistrano
You're correct: if you see no output, that means that Ruby was able to resolve the constant, which means that will_paginate is loaded correctly in your production environment.
If it isn't, you'll see an "uninitialized constant" error, like so:
/home/ash/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/railties-4.0.0/lib/rails/commands/runner.rb:53:in `eval': uninitialized constant WillPaginate (NameError)
from /home/ash/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/railties-4.0.0/lib/rails/commands/runner.rb:53:in `eval'
from /home/ash/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/railties-4.0.0/lib/rails/commands/runner.rb:53:in `<top (required)>'
from /home/ash/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/railties-4.0.0/lib/rails/commands.rb:86:in `require'
from /home/ash/.rbenv/versions/2.1.0-preview1/lib/ruby/gems/2.1.0/gems/railties-4.0.0/lib/rails/commands.rb:86:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

Error after upgrade from rails 3.1 to 3.2.6

I set myself the task of upgrading my app from rails 3.1 to rails 3.2.6 on my local mac book air lion dev environment. I followed this guide and ruby is upgraded, and all of my gems seemed to install and rails -v gives the answer of rails 3.2.6. If I run any rails commands though, e.g. rails c to start the console, I get this:
MacBook-Air:myapp bob$ rails c
/Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/pubnub-ruby-0.0.9/lib/pubnub-ruby.rb:1:in `require': cannot load such file -- ./pubnub.rb (LoadError)
from /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/pubnub-ruby-0.0.9/lib/pubnub-ruby.rb:1:in `<top (required)>'
from /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `require'
from /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/bundler-1.0.21/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `each'
from /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/bundler-1.0.21/lib/bundler/runtime.rb:66:in `block in require'
from /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `each'
from /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/bundler-1.0.21/lib/bundler/runtime.rb:55:in `require'
from /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /Users/bob/work/myapp/config/application.rb:13:in `<top (required)>'
from /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/railties-3.2.6/lib/rails/commands.rb:39:in `require'
from /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/railties-3.2.6/lib/rails/commands.rb:39:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Yes I do use pubnub in my app - it's always been working fine so I don't suspect it necessarily is the problem.
The application.rb line 13 (might be not be relevant) is
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
I do precompile assets before deploying.
The /Users/bob/.rvm/gems/ruby-1.9.3-p0#rails32/gems/pubnub-ruby-0.0.9/lib/pubnub-ruby.rb:1 file is present and I opened it fine.
Does anyone know whats going on / is it pubnub specific or something else? I'm not sure how to troubleshoot further and googling hasn't brought anything up so far.
Thanks,
Dave
I don't see the file pubnub-ruby.rb in the repo for that gem. Try running $ bundle install or $ gem update pubnub-ruby.

Resources