Показать полную ошибку в браузере в Ruby on Rails - PullRequest
1 голос
/ 27 апреля 2019

Я начал учиться Rails сегодня. Я слежу за онлайн-учебником. Я получаю ошибку. В учебнике при возникновении ошибки причина ошибки отображается в браузере. Но я просто получаю это сообщение:

We're sorry, but something went wrong. If you are the application owner check the logs for more information.

Как сделать так, чтобы Rails отображал отображение фактического error, например, как Django отображает ошибку, когда debug = True в settings.py файле?

development.rb

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  config.assets.raise_runtime_errors = true

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
end

журнал

/usr/lib/ruby/vendor_ruby/rails/app_rails_loader.rb:39: warning: Insecure world writable dir /usr/lib/jvm/java-8-openjdk-amd64/bin in PATH, mode 040777
Array values in the parameter to `Gem.paths=` are deprecated.
Please use a String or nil.
An Array ({"GEM_PATH"=>["/var/lib/gems/2.5.0", "/home/laxman/.gem/ruby/2.5.0", "/usr/lib/x86_64-linux-gnu/rubygems-integration/2.5.0", "/usr/share/rubygems-integration/2.5.0", "/usr/share/rubygems-integration/all"]}) was passed in from bin/rails:3:in `load'
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
/usr/lib/ruby/vendor_ruby/sprockets/digest_utils.rb:47: warning: constant ::Fixnum is deprecated
/usr/lib/ruby/vendor_ruby/sprockets/digest_utils.rb:51: warning: constant ::Bignum is deprecated
/usr/lib/ruby/vendor_ruby/sprockets/processor_utils.rb:110: warning: constant ::Fixnum is deprecated
/usr/lib/ruby/vendor_ruby/sprockets/processor_utils.rb:111: warning: constant ::Bignum is deprecated
=> Booting WEBrick
=> Rails 4.2.10 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2019-04-27 16:46:06] INFO  WEBrick 1.4.2
[2019-04-27 16:46:06] INFO  ruby 2.5.1 (2018-03-29) [x86_64-linux-gnu]
[2019-04-27 16:46:06] INFO  WEBrick::HTTPServer#start: pid=2467 port=3000


Started GET "/" for 127.0.0.1 at 2019-04-27 16:46:10 +0530
  ActiveRecord::SchemaMigration Load (0.1ms)  SELECT "schema_migrations".* FROM "schema_migrations"

config.ru

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run Rails.application

application.rb

require File.expand_path('../boot', __FILE__)

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 Proj
  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.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de

    # Do not swallow errors in after_commit/after_rollback callbacks.
    config.active_record.raise_in_transactional_callbacks = true
  end
end

1 Ответ

1 голос
/ 29 апреля 2019

После просмотра полной заявки вы опубликовали мне удалось воспроизвести проблему.

Эта проблема была сообщена ранее ,в других сообщениях StackOverflow, но я повторю это здесь:

Вам необходимо обновить гем web-console до версии 3.0+;в частности из-за этого исправления для запуска сервера rails в виртуальной машине / контейнере за прокси-сервером.

Другими словами, вам необходимо обновить эту строку в вашем Gemfile до:

gem 'web-console', '~> 3.0'

и затем выполните bundle install.

В связанной заметке вы, кажется, используете много устаревших версий программного обеспечения в вашем проекте (например, rails version 4.2).Подобные проблемы обычно можно смягчить, обновляя ваши зависимости.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...