前提・実現したいこと
http://localhost:3000/にアクセスできるようにしたいです。
発生している問題・エラーメッセージ
wrong number of arguments (given 2, expected 0)
Extracted source (around line #27):
db = SQLite3::Database.new(
config[:database].to_s,
:results_as_hash => true
)
試したこと
補足情報(FW/ツールのバージョンなど)
Rails 5.0.7.2
sqlite3:3.35.5
ruby 2.7.3p183
全然初心者ですが、直す方法がわからなくて、助けていただけませんか。
ご提示のコードは、どのファイルに書かれていたものでしょうか?
rails server→http://localhost:3000/を入力→フロント画面上記のエラーが出ました。
画面の下に下記のメッセージも表示します。
activerecord (5.0.7.2) lib/active_record/connection_adapters/sqlite3_adapter.rb:27:in `initialize'
activerecord (5.0.7.2) lib/active_record/connection_adapters/sqlite3_adapter.rb:27:in `new'
activerecord (5.0.7.2) lib/active_record/connection_adapters/sqlite3_adapter.rb:27:in `sqlite3_connection'
activerecord (5.0.7.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:729:in `new_connection'
activerecord (5.0.7.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:773:in `checkout_new_connection'
activerecord (5.0.7.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:752:in `try_to_checkout_new_connection'
activerecord (5.0.7.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:713:in `acquire_connection'
activerecord (5.0.7.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:490:in `checkout'
activerecord (5.0.7.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `connection'
activerecord (5.0.7.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:883:in `retrieve_connection'
activerecord (5.0.7.2) lib/active_record/connection_handling.rb:128:in `retrieve_connection'
activerecord (5.0.7.2) lib/active_record/connection_handling.rb:91:in `connection'
activerecord (5.0.7.2) lib/active_record/migration.rb:559:in `connection'
activerecord (5.0.7.2) lib/active_record/migration.rb:546:in `call'
actionpack (5.0.7.2) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.7.2) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.7.2) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.7.2) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.7.2) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
actionpack (5.0.7.2) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.7.2) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.0.7.2) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.0.7.2) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.7.2) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.7.2) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.7.2) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.0.7.2) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.7.2) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.0.7.2) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.0.7.2) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.7.2) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.7.2) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.7.2) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
railties (5.0.7.2) lib/rails/engine.rb:522:in `call'
puma (3.12.6) lib/puma/configuration.rb:227:in `call'
puma (3.12.6) lib/puma/server.rb:706:in `handle_request'
puma (3.12.6) lib/puma/server.rb:476:in `process_client'
puma (3.12.6) lib/puma/server.rb:334:in `block in run'
puma (3.12.6) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
VSCODEで、ご提示のコードを検索しても出ないですね
config/database.ymlはどのようになっていますか?
Extracted source (around line #27):→なので、下記三つだと思います。
activerecord (5.0.7.2) lib/active_record/connection_adapters/sqlite3_adapter.rb:27:in `initialize'
activerecord (5.0.7.2) lib/active_record/connection_adapters/sqlite3_adapter.rb:27:in `new'
activerecord (5.0.7.2) lib/active_record/connection_adapters/sqlite3_adapter.rb:27:in `sqlite3_connection'
config/database.ymlは下記通りです。
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
#
default: &default
adapter: sqlite3
pool: 5
timeout: 5000
development:
<<: *default
database: db/development.sqlite3
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: db/test.sqlite3
production:
<<: *default
database: db/production.sqlite3
gem 'sqlite3'はGemfileに書き込んでありますか?
質問は編集できます。
原則質問本文に追記してください。