我试图关注rails教程并设法运行bundle install。但是,在运行rails s时,我收到以下错误。
Users/abc/.rvm/gems/ruby-2.4.1@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `load_defaults' for #<Rails::Application::Configuration:0x007fc29e53d7a8> (NoMethodError)
from /Users/abc/Desktop/Rails_Projects/sample_app/config/application.rb:12:in `<class:Application>'
from /Users/abc/Desktop/Rails_Projects/sample_app/config/application.rb:10:in `<module:SampleApp>'
from /Users/abc/Desktop/Rails_Projects/sample_app/config/application.rb:9:in `<top (required)>'
from /Users/abc/.rvm/gems/ruby-2.4.1@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/commands.rb:74:in `require'
from /Users/abc/.rvm/gems/ruby-2.4.1@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/commands.rb:74:in `block in <top (required)>'
from /Users/abc/.rvm/gems/ruby-2.4.1@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/commands.rb:71:in `tap'
from /Users/abc/.rvm/gems/ruby-2.4.1@railstutorial_rails_4_0/gems/railties-4.0.8/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:9:in `require'
from bin/rails:9:in `<main>'
这是我的宝石文件
source 'https://rubygems.org'
ruby '2.4.1'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.8'
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.3'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
提前致谢
编辑:
这是我的config / application.rb文件。我注意到错误发生在
&#39; config.load_defaults 5.1&#39;。我已经阅读了另一个建议删除此行的答案,但这会给我带来更多问题。
require_relative 'boot'
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module MhApp
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.1
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
end
end
答案 0 :(得分:0)
试试这个gem install bundler
然后运行
bundle install
答案 1 :(得分:0)
你必须更改你的rails版本,当你创建一个它在rails 5.1版本中创建的新应用程序(可能)首先检查你的rails版本并在gem文件中更新它。
使用此命令检查您的rails版本rails -v
然后在gem文件中更新您的版本,然后您必须提供bundle install
希望这会对你有所帮助。