Why isn't Rails::Railstie initializing after I installed CarrierWave gem? - ruby-on-rails

Installed Carrier Wave gem successfully; added an image uploader which also works. However, when I went to rails db:migrate after changing a table, a name error popped up:
NameError: uninitialized constant Rails::Railtie. Did you mean? Rails.
Most of the other questions I've found online have to do with other uninitialized constants-- not Rails!
Here's the error called with --trace:
rails aborted!
NameError: uninitialized constant Rails::Railtie
Did you mean? Rails
/Users/graceyang/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/gems/carrierwave-1.3.1/lib/carrierwave.rb:60:in `<module:CarrierWave>'
/Users/graceyang/.rbenv/versions/2.3.5/lib/ruby/gems/2.3.0/gems/carrierwave-1.3.1/lib/carrierwave.rb:59:in `<top (required)>'
/Users/graceyang/Documents/Projects/JS Power/website/jspower/config/application.rb:2:in `require'
/Users/graceyang/Documents/Projects/JS Power/website/jspower/config/application.rb:2:in `<top (required)>'
/Users/graceyang/Documents/Projects/JS Power/website/jspower/Rakefile:4:in `require_relative'
/Users/graceyang/Documents/Projects/JS Power/website/jspower/Rakefile:4:in `<top (required)>'
None of my rails commands work anymore! I had just completed a successful rails g migration AddFieldNameToTable call before I called rails db:migrate and the error started.
*EDIT/UPDATE *
It works now with rake instead of rails db:
but if anyone can answer why, that would be great!
*EDIT/UPDATE *
Actually, still a problem... can't install things that need the rails command....I found that the project was running under Ruby 2 for some reason even though my gemfile states gem 'rails', '~> 5.0.6'

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 ||= []

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

installed heroku PGbouncer buildpack for my rails application. Console no longer has access to models or active record

I Installed PGbouncer to help with transaction pooling, and so far it seems to be helping. However, when I do heroku run console my connection does not have access to ActiveRecord or any models.
NameError: uninitialized constant ActiveRecord
from (irb):8
from /app/vendor/bundle/ruby/2.3.0/gems/countries-2.1.2/bin/console:14:in `<top (required)>'
from /app/vendor/bundle/bin/console:17:in `load'
from /app/vendor/bundle/bin/console:17:in `<main>'
irb(main):011:0> User
NameError: uninitialized constant User
from (irb):11
from /app/vendor/bundle/ruby/2.3.0/gems/countries-2.1.2/bin/console:14:in `<top (required)>'
from /app/vendor/bundle/bin/console:17:in `load'
from /app/vendor/bundle/bin/console:17:in `<main>'
Solved by instead using
heroku run rails console
Had always used heroku run console up to this point. Could be useful information for people who have this problem in the future.

uninitialized constant I18n::JS Ruby on Rails

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

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>'

Resources