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 ||= []
Related
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'
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
I am still having trouble with Ruby on Rails. I run rails s (this is for my openproject app) and I get this (before it was working). I also wanted to make a note I am now using Ruby 2.0 and I still get the same error.
require 'rails/all'... 0.850s
Bundler.require... 7.700s
/home/bistro/openproject/config/application.rb:89:in `<class:Application>': uninitialized constant I18n::JS (NameError)
from /home/bistro/openproject/config/application.rb:61:in `<module:OpenProject>'
from /home/bistro/openproject/config/application.rb:60:in `<top (required)>'
from /home/bistro/.rvm/gems/ruby-1.9.3-p484/gems/railties-3.2.16/lib/rails/commands.rb:53:in `require'
from /home/bistro/.rvm/gems/ruby-1.9.3-p484/gems/railties-3.2.16/lib/rails/commands.rb:53:in `block in <top (required)>'
from /home/bistro/.rvm/gems/ruby-1.9.3-p484/gems/railties-3.2.16/lib/rails/commands.rb:50:in `tap'
from /home/bistro/.rvm/gems/ruby-1.9.3-p484/gems/railties-3.2.16/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I'm working on a Rails Ember app and I had exactly the same problem, trying to internationalize the client-side using the i18n-js gem (https://github.com/fnando/i18n-js). To give more context, I am following the instructions in this article: http://eviltrout.com/2013/11/24/i18n-in-ember.html
In my case, Rails did not find I18n::JS because it is now called SimplesIdeias::I18n (you can see it by running rake middleware from the command line). Adding the line
config.middleware.use SimplesIdeias::I18n::Middleware
in the application.rb file solved the problem for me, hope it helps.
If you happen upon this now adays. your gemfile should say something like gem 'i18n-js', ">= 3.0.0.rc11". Otherwise you will end up using version 2.0
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>'
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.