リンク内容
こちらのサイトを参考にRSpecを導入してみたのですが、それからRails g コマンドが使えなくなってしまいました。
:~/environment/bootstrap_test (master) $ rails g model Tweet text:string title:string /home/ec2-user/environment/bootstrap_test/config/application.rb:20:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError) from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:92:in `require' from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:92:in `preload' from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve' from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run' from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop' from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application.rb:135:in `run' from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>' from /home/ec2-user/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/ec2-user/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' from -e:1:in `<main>'
エラー文はこのようなもので、application.rbの記述したものがおかしかったのかな?と思いました。
application
1require_relative 'boot' 2 3require 'rails/all' 4 5# Require the gems listed in Gemfile, including any gems 6# you've limited to :test, :development, or :production. 7Bundler.require(*Rails.groups) 8 9module BootstrapTest 10 class Application < Rails::Application 11 # Initialize configuration defaults for originally generated Rails version. 12 config.load_defaults 5.1 13 14 # Settings in config/environments/* take precedence over those specified here. 15 # Application configuration should go into files in config/initializers 16 # -- all .rb files in that directory are automatically loaded. 17 end 18end 19 20config.generators do |g| 21 g.test_framework :rspec, 22 fixtures: true, 23 view_specs: false, 24 helper_specs: false, 25 routing_specs: false, 26 controller_specs: true, 27 request_specs: false 28 g.fixture_replacement :factory_bot, dir: "spec/factories" 29end 30
Gemfile
1source 'https://rubygems.org' 2 3gem 'rails', '5.1.6' 4gem 'puma', '3.9.1' 5gem 'sass-rails', '5.0.6' 6gem 'bootstrap', '~> 4.1.1' 7gem 'uglifier', '3.2.0' 8gem 'coffee-rails', '4.2.2' 9gem 'jquery-rails', '4.3.1' 10gem 'turbolinks', '5.0.1' 11gem 'jbuilder', '2.6.4' 12 13group :development, :test do 14 gem 'sqlite3', '1.3.13' 15 gem 'byebug', '9.0.6', platform: :mri 16 gem 'rspec-rails' 17 gem 'factory_bot_rails' 18 gem 'rails-controller-testing' 19end 20 21group :development do 22 gem 'web-console', '3.5.1' 23 gem 'listen', '3.1.5' 24 gem 'spring', '2.0.2' 25 gem 'spring-watcher-listen', '2.0.1' 26end 27 28# Windows環境ではtzinfo-dataというgemを含める必要があります 29gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 30
rubyバージョン-2.6.3
railsバージョン-5.1.6
当方初学者で自力ではどうにもできませんでした。どなたかご教示お願い致します。
あなたの回答
tips
プレビュー