■困っていること
次のエラーの解決方法がわからずに困っています。
undefined method "config" for nil:NilClass (NoMethodError)
■環境
cloud9
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
Rails 5.2.3
$ sqlite3 -version
3.7.17 2013-05-20 00:56:22 118a3b35693b134d56ebd780123b7fd6f1497668
■これまでにやっていたこと
RSpecをセットアップしたのち $ bin/rspec
を実行すると以下のエラーが出ました。
ec2-user:~/environment/InstaClone (develop_0618_RSpec) $ bin/rspec DEPRECATION WARNING: Leaving `ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer` set to false is deprecated. SQLite databases have used 't' and 'f' to serialize boolean values and must have old data converted to 1 and 0 (its native boolean serialization) before setting this flag to true. Conversion can be accomplished by setting up a rake task which runs ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 1) ExampleModel.where("boolean_column = 'f'").update_all(boolean_column: 0) for all models and all boolean columns, after which the flag must be set to true by adding the following to your application.rb file: Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true (called from instance_eval at /home/ec2-user/environment/InstaClone/vendor/bundler/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/lazy_load_hooks.rb:71) Running via Spring preloader in process 6294 No examples found. Finished in 0.00041 seconds (files took 0.22336 seconds to load) 0 examples, 0 failures
エラーの内容を読むに、"ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integerをfalseに設定するのは非推奨です"とのことだったので、
以下のサイトを参考に、application.rbに以下設定を追加してこのフラグをtrueに設定しました。
<参考サイト>
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
すると次のエラーが表示され、対応方法がわからずに悩んでいます。
ec2-user:~/environment/InstaClone (develop_0618_RSpec) $ bin/rspec /home/ec2-user/environment/InstaClone/config/application.rb:10:in `<top (required)>': undefined method `config' for nil:NilClass (NoMethodError) from /home/ec2-user/environment/InstaClone/vendor/bundler/ruby/2.6.0/gems/spring-2.0.2/lib/spring/application.rb:92:in `require' from /home/ec2-user/environment/InstaClone/vendor/bundler/ruby/2.6.0/gems/spring-2.0.2/lib/spring/application.rb:92:in `preload' from /home/ec2-user/environment/InstaClone/vendor/bundler/ruby/2.6.0/gems/spring-2.0.2/lib/spring/application.rb:153:in `serve' from /home/ec2-user/environment/InstaClone/vendor/bundler/ruby/2.6.0/gems/spring-2.0.2/lib/spring/application.rb:141:in `block in run' from /home/ec2-user/environment/InstaClone/vendor/bundler/ruby/2.6.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `loop' from /home/ec2-user/environment/InstaClone/vendor/bundler/ruby/2.6.0/gems/spring-2.0.2/lib/spring/application.rb:135:in `run' from /home/ec2-user/environment/InstaClone/vendor/bundler/ruby/2.6.0/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/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /home/ec2-user/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' from -e:1:in `<main>'
application.rbの設定方法が間違っているのでしょうか?
詳細をご存じの方、お力添え頂けますと幸いです。
宜しくお願いします。m(_ _)m
[20190620_追記]
application.rb ==== 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) #対策:DEPRECATION WARNING: Leaving `ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer`set to false is deprecated. Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true module InstaClone class Application < Rails::Application # 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.generators do |g| g.test_framework :rspec, fixtures: false, view_specs: false, helper_specs: false, routing_specs: false end end end
回答1件
あなたの回答
tips
プレビュー