undefined method `load_defaults' on rails generate migration and rails console - ruby-on-rails

I'm getting this error when I run: rails generate migration AddRoleToBuyer role:integer
The error:
/usr/lib/ruby/vendor_ruby/rails/railtie/configuration.rb:95:in `method_missing': undefined method `load_defaults' for #<Rails::Application::Configuration:0x000055e8c09a10d8> (NoMethodError)
from /home/murilo/projects/api-service/config/application.rb:24:in `<class:Application>'
from /home/murilo/projects/api-service/config/application.rb:22:in `<module:ApiService>'
from /home/murilo/projects/api-service/config/application.rb:21:in `<top (required)>'
from /home/murilo/projects/api-service/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:92:in `require'
from /home/murilo/projects/api-service/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:92:in `preload'
from /home/murilo/projects/api-service/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve'
from /home/murilo/projects/api-service/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run'
from /home/murilo/projects/api-service/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop'
from /home/murilo/projects/api-service/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run'
from /home/murilo/projects/api-service/vendor/bundle/ruby/2.5.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
from -e:1:in `<main>'
The application and rspec tests is running with no problems, but migrations not working.
EDIT: this is happening when I run rails console too.

Related

Rails generate error - 'method_missing': undefined method 'active_record'

I am running Rails 4.2.3 on OS X Yosemite 10.10.4. I currently have two apps that are working fine, however upon creating a new app and trying to use 'rails generate' I am running into the following error message:
/Library/Ruby/Gems/2.0.0/gems/railties-4.2.3/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `active_record' for #<Rails::Application::Configuration:0x007f9d11ae5ed8> (NoMethodError)
from /Users/tompickard/Documents/app/config/application.rb:24:in `<class:Application>'
from /Users/tompickard/Documents/app/config/application.rb:10:in `<module:App>'
from /Users/tompickard/Documents/app/config/application.rb:9:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.3.6/lib/spring/application.rb:82:in `require'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.3.6/lib/spring/application.rb:82:in `preload'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.3.6/lib/spring/application.rb:143:in `serve'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
I have tried various solutions to no avail.
Please let me know if you need any more information
Thanks

Rails 4.1.1 with console in production

I keep getting this error since updating to rails 4.1.1 and starting my console in production as: RAILS_ENV=production rails c
load error: /home/tristan/.rvm/rubies/ruby-2.1.1/.irbrc
NoMethodError: undefined method `split' for nil:NilClass
/home/tristan/.rvm/scripts/irbrc.rb:41:in `<top (required)>'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
/home/tristan/.rvm/rubies/ruby-2.1.1/.irbrc:11:in `<top (required)>'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `block in load'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:241:in `load'
/home/tristan/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/init.rb:236:in `run_config'
/home/tristan/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb/init.rb:19:in `setup'
/home/tristan/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/irb.rb:380:in `start'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands/console.rb:90:in `start'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands/console.rb:9:in `start'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:69:in `console'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
/home/tristan/joggle/shared/bundle/ruby/2.1.0/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
I just had this same issue. I ran 'spring stop' then 'rails c' and it corrected the error. Something got mucked up with the environment because line 41 of that irbrc.rb file refers to the ENV variable GEM_HOME, which I confirmed was actually set.
Does that fix your issue?

Rails Error: `method_missing': undefined method `register_middleware'

On Rails, I'm trying to rake a new task I just created and it's giving me an undefined method error:
syck has been removed, psych is used instead
rake aborted!
NoMethodError: undefined method `register_middleware' for #<Faraday::Connection:0x007f8773f41288>
/Library/Ruby/Gems/2.0.0/gems/faraday-0.9.0/lib/faraday.rb:99:in `method_missing'
/Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced/client.rb:41:in `build_conn'
/Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced/client.rb:30:in `initialize'
/Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced.rb:29:in `new'
/Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced.rb:29:in `configure'
/Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced.rb:86:in `<module:Balanced>'
/Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced.rb:11:in `<top (required)>'
/Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `require'
/Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `each'
/Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `block in require'
/Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `each'
/Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `require'
/Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
/Users/Stephanie/Desktop/Pixiboard/config/application.rb:8:in `<top (required)>'
/Users/Stephanie/Desktop/Pixiboard/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)
I also get a similar error when trying to run the command "rails console" (to see if there's anything wrong with my task):
syck has been removed, psych is used instead
/Library/Ruby/Gems/2.0.0/gems/faraday-0.9.0/lib/faraday.rb:99:in `method_missing': undefined method `register_middleware' for #<Faraday::Connection:0x007f986c506700> (NoMethodError)
from /Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced/client.rb:41:in `build_conn'
from /Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced/client.rb:30:in `initialize'
from /Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced.rb:29:in `new'
from /Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced.rb:29:in `configure'
from /Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced.rb:86:in `<module:Balanced>'
from /Library/Ruby/Gems/2.0.0/gems/balanced-0.8.1/lib/balanced.rb:11:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:72:in `block in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:61:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler.rb:132:in `require'
from /Users/Stephanie/Desktop/Pixiboard/config/application.rb:8:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/railties-3.2.12/lib/rails/commands.rb:39:in `require'
from /Library/Ruby/Gems/2.0.0/gems/railties-3.2.12/lib/rails/commands.rb:39:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Can anyone help me on what to do?
(I'm on Rails 3.2.12)
balanced-ruby is not yet compatible with faraday 0.9.0. See more balanced-ruby/issues/173
and try to use faraday 0.8.6 in your Gemfile:
gem 'faraday', '~> 0.8.6'

bundle console fails w/ uninitialized constant Rails

I have create a new Rails engine using the rails plugin new Foobar --full --mountable command. When running bundle console I get uninitialized constant Rails Why is this?
Resolving dependencies...
Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/Users/kyledecot/Desktop/Foobar/lib/foobar/engine.rb:2:in `<module:Foobar>': uninitialized constant Rails (NameError)
from /Users/kyledecot/Desktop/Foobar/lib/foobar/engine.rb:1:in `<top (required)>'
from /Users/kyledecot/Desktop/Foobar/lib/foobar.rb:1:in `require'
from /Users/kyledecot/Desktop/Foobar/lib/foobar.rb:1:in `<top (required)>'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `require'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `each'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:72:in `block in require'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `each'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/runtime.rb:61:in `require'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler.rb:131:in `require'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/cli.rb:664:in `console'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/vendor/thor/command.rb:27:in `run'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_command'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/vendor/thor.rb:363:in `dispatch'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/vendor/thor/base.rb:438:in `start'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/cli.rb:10:in `start'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/bin/bundle:22:in `block in <top (required)>'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/lib/bundler/friendly_errors.rb:5:in `with_friendly_errors'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/gems/bundler-1.5.1/bin/bundle:22:in `<top (required)>'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/bin/bundle:23:in `load'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#global/bin/bundle:23:in `<main>'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#foobar/bin/ruby_executable_hooks:15:in `eval'
from /Users/kyledecot/.rvm/gems/ruby-2.0.0-p353#foobar/bin/ruby_executable_hooks:15:in `<main>'
Adding require 'rails' in Foobar/lib/foobar/engine.rb file worked for me. I got my answer from here.

script/server is not working. When the command is executed, it is showing the following error

/home/vinay/mynewapp/vendor/rails/railties/lib/rails/gem_dependency.rb:21:in `add_frozen_gem_path': undefined method `source_index' for Gem:Module (NoMethodError)
from /home/vinay/mynewapp/config/boot.rb:47:in `load_initializer'
from /home/vinay/mynewapp/config/boot.rb:38:in `run'
from /home/vinay/mynewapp/config/boot.rb:11:in `boot!'
from /home/vinay/mynewapp/config/boot.rb:114:in `<top (required)>'
from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:in `require'
from /usr/local/lib/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:45:in `require'
from script/server:2:in `<main>'
Did you try rails server instead?
Shorter versions: rails s or even r s

Resources