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>'
Related
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 ||= []
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.
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
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.
I am completely new to ror and am following Michael Hartl's tutorial but I keep getting an error when I get to section 1.2.5. using the rails server command. When I use this command (whilst I am in my rail app directory 'first_app') I get the following error
c:\Users\rails_projects\first_app>rails server
c:/rails_projects/first_app/config/application.rb:7:in `<top (required)>': undefined method `groups' for Rails:
Module (NoMethodError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/comma
nds.rb:28:in `require'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/comma
nds.rb:28:in `block in <top (required)>'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/comma
nds.rb:27:in `tap'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.0.11/lib/rails/comma
nds.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I can't figure out what went wrong, my bundle installed fine (section 1.2.4).
If your Gemfile is not set to use rails 3.1 or greater, try updating to 3.1.