Không chạy được server!

C:\Users\devil\Desktop\RoR\blog>rails s

=> Booting WEBrick => Rails 4.2.6 application starting in development on http://localhost:3000 => Run rails server -h for more startup options => Ctrl-C to shutdown server [2016-07-15 11:23:46] INFO WEBrick 1.3.1 [2016-07-15 11:23:46] INFO ruby 2.3.0 (2015-12-25) [x64-mingw32] [2016-07-15 11:23:46] INFO WEBrick::HTTPServer#start: pid=4496 port=3000

Started GET "/" for ::1 at 2016-07-15 11:23:58 +0700

LoadError (Could not load 'active_record/connection_adapters/sqlite3_adapter'. Make sure that the adapter in config/database.yml is valid. If you use an adapter other than 'mysql', 'mysql2', 'postgresql' or 'sqlite3' add the necessary adapter gem to the Gemfile.): activesupport (4.2.6) lib/active_support/dependencies.rb:274:in require' activesupport (4.2.6) lib/active_support/dependencies.rb:274:inblock in require' activesupport (4.2.6) lib/active_support/dependencies.rb:240:in load_dependency' activesupport (4.2.6) lib/active_support/dependencies.rb:274:inrequire' activerecord (4.2.6) lib/active_record/connection_adapters/sqlite3_adapter.rb:6:in <top (required)>' activesupport (4.2.6) lib/active_support/dependencies.rb:274:inrequire' activesupport (4.2.6) lib/active_support/dependencies.rb:274:in block in require' activesupport (4.2.6) lib/active_support/dependencies.rb:240:inload_dependency' activesupport (4.2.6) lib/active_support/dependencies.rb:274:in require' activerecord (4.2.6) lib/active_record/connection_adapters/connection_specification.rb:175:inspec' activerecord (4.2.6) lib/active_record/connection_handling.rb:50:in establish_connection' activerecord (4.2.6) lib/active_record/railtie.rb:120:inblock (2 levels) in <class:Railtie>' activesupport (4.2.6) lib/active_support/lazy_load_hooks.rb:38:in instance_eval' activesupport (4.2.6) lib/active_support/lazy_load_hooks.rb:38:inexecute_hook' activesupport (4.2.6) lib/active_support/lazy_load_hooks.rb:45:in block in run_load_hooks' activesupport (4.2.6) lib/active_support/lazy_load_hooks.rb:44:ineach' activesupport (4.2.6) lib/active_support/lazy_load_hooks.rb:44:in run_load_hooks' activerecord (4.2.6) lib/active_record/base.rb:315:in<module:ActiveRecord>' activerecord (4.2.6) lib/active_record/base.rb:26:in <top (required)>' activesupport (4.2.6) lib/active_support/dependencies.rb:274:inrequire' activesupport (4.2.6) lib/active_support/dependencies.rb:274:in block in require' activesupport (4.2.6) lib/active_support/dependencies.rb:240:inload_dependency' activesupport (4.2.6) lib/active_support/dependencies.rb:274:in require' activerecord (4.2.6) lib/active_record/migration.rb:383:inconnection' activerecord (4.2.6) lib/active_record/migration.rb:370:in call' actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call' activesupport (4.2.6) lib/active_support/callbacks.rb:88:in __run_callbacks__' activesupport (4.2.6) lib/active_support/callbacks.rb:778:in_run_call_callbacks' activesupport (4.2.6) lib/active_support/callbacks.rb:81:in run_callbacks' actionpack (4.2.6) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (4.2.6) lib/action_dispatch/middleware/reloader.rb:73:in call' actionpack (4.2.6) lib/action_dispatch/middleware/remote_ip.rb:78:incall' actionpack (4.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:17:in call' web-console (2.3.0) lib/web_console/middleware.rb:28:inblock in call' web-console (2.3.0) lib/web_console/middleware.rb:18:in catch' web-console (2.3.0) lib/web_console/middleware.rb:18:incall' actionpack (4.2.6) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.2.6) lib/rails/rack/logger.rb:38:incall_app' railties (4.2.6) lib/rails/rack/logger.rb:20:in block in call' activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:inblock in tagged' activesupport (4.2.6) lib/active_support/tagged_logging.rb:26:in tagged' activesupport (4.2.6) lib/active_support/tagged_logging.rb:68:intagged' railties (4.2.6) lib/rails/rack/logger.rb:20:in call' actionpack (4.2.6) lib/action_dispatch/middleware/request_id.rb:21:incall' rack (1.6.4) lib/rack/methodoverride.rb:22:in call' rack (1.6.4) lib/rack/runtime.rb:18:incall' activesupport (4.2.6) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in call' rack (1.6.4) lib/rack/lock.rb:17:incall' actionpack (4.2.6) lib/action_dispatch/middleware/static.rb:120:in call' rack (1.6.4) lib/rack/sendfile.rb:113:incall' railties (4.2.6) lib/rails/engine.rb:518:in call' railties (4.2.6) lib/rails/application.rb:165:incall' rack (1.6.4) lib/rack/lock.rb:17:in call' rack (1.6.4) lib/rack/content_length.rb:15:incall' rack (1.6.4) lib/rack/handler/webrick.rb:88:in service' C:/Ruby23-x64/lib/ruby/2.3.0/webrick/httpserver.rb:140:inservice' C:/Ruby23-x64/lib/ruby/2.3.0/webrick/httpserver.rb:96:in run' C:/Ruby23-x64/lib/ruby/2.3.0/webrick/server.rb:296:inblock in start_thread'

Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_source.erb (1.0ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (2.0ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.0ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/actionpack-4.2.6/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (533.0ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_markup.html.erb (0.0ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_inner_console_markup.html.erb within layouts/inlined_string (0.0ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/_prompt_box_markup.html.erb within layouts/inlined_string (0.0ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/style.css.erb within layouts/inlined_string (0.0ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/console.js.erb within layouts/javascript (458.4ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/main.js.erb within layouts/javascript (1.0ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/error_page.js.erb within layouts/javascript (0.0ms) Rendered C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/web-console-2.3.0/lib/web_console/templates/index.html.erb (1088.7ms)

Khi mình chạy server thì nó hiện lỗi như trên, làm cách nào để khắc phục, mình xin cảm ơn!

Được hỏi 2 năm trước
Bình chọn bởi: Hà Anh, Huyền SuBy, Trần Diễm, Hải Phạm, Lê Anh, Tony Huynh, Vũ Huy Hoàng, Bảo Davis, Tuấn Anh, Vũ Văn Tuấn, Nguyen Lam, Bơ Heoboo, Phạm Vũ

Trước tiên bạn cần kiểm tra xem ứng dụng Rails đang sử dụng database adapter nào. Bạn có thể kiểm tra trong tập tin /config/database.yml.

Thường thì khi dev bạn sẽ cần sử dụng hai môi trường test và development. Do đó trong tập tin database.yml bạn cần kiểm tra hai mục dưới đây:

development:
  adapter: postgresql
  encoding: unicode
  database: myapp_development
  pool: 5
  username: myapp
  password: password1

test:
  adapter: postgresql
  encoding: unicode
  database: myapp_test
  pool: 5
  username: myapp
  password: password1

Ở trên mình sử dụng postgresql là database adapter. Trường hợp của bạn nếu đang sử dụng SQLite thì bạn cần cài đặt Gem tương ứng cho Rails. Trong tập tin Gemfile bạn thêm dòng dưới đây:

gem 'sqlite3', '1.3.4

Sau đó cài đặt gem bằng câu lệnh:

$ bundle install

Và chạy rail WEBrick.

Trả lời 18 giờ trước

Thêm Trả Lời