Rails 5.2.2 web控制台不显示

Rails 5.2.2 web console does not show up

尽管我已将 <%= console %> 放入 application.htm.erb.

中,但无论我尝试什么,我都无法使 Web 控制台出现在任何页面上

我正在使用 Rails v5.2.2 和网络控制台 v3.7。

我尝试了不同版本的 rails/web 控制台,但没有成功。

有什么想法吗?

我的 Gemfile

source 'https://rubygems.org'

gem 'rails',        '5.2.2'
gem 'puma',         '3.9.1'

# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'  

.......

group :development, :test do
  gem 'sqlite3', '1.3.13'
  gem 'byebug',  '9.0.6', platform: :mri
end

group :development do
  gem 'web-console'
  gem 'listen',                '3.1.5'
  gem 'spring',                '2.0.2'
  gem 'spring-watcher-listen', '2.0.1'
end

group :production do
  gem 'pg', '0.20.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
#gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

日志

Started GET "/users" for 80.107.134.220 at 2019-01-18 13:21:45 +0000
Cannot render console from 80.107.134.220! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by UsersController#index as HTML
  User Load (0.2ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ?  [["id", 1], ["LIMIT", 1]]
  Rendering users/index.html.erb within layouts/application
  User Load (0.2ms)  SELECT "users".* FROM "users" ORDER BY fullname asc
  Rendered users/index.html.erb within layouts/application (4.9ms)
  Setting Exists (0.2ms)  SELECT  1 AS one FROM "settings" LIMIT ?  [["LIMIT", 1]]
  Setting Load (0.2ms)  SELECT  "settings".* FROM "settings" ORDER BY "settings"."id" ASC LIMIT ?  [["LIMIT", 1]]
  Tgroup Load (0.1ms)  SELECT "tgroups".* FROM "tgroups"
  Rendered layouts/_navigation.html.erb (2.3ms)
  Rendered layouts/_footer.html.erb (0.4ms)
Completed 200 OK in 68ms (Views: 64.5ms | ActiveRecord: 0.8ms)


Started GET "/settings" for 80.107.134.220 at 2019-01-18 13:21:47 +0000
Cannot render console from 80.107.134.220! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by PagesController#settings as HTML
  User Load (0.2ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ?  [["id", 1], ["LIMIT", 1]]
  Setting Exists (0.1ms)  SELECT  1 AS one FROM "settings" LIMIT ?  [["LIMIT", 1]]
  Setting Load (0.1ms)  SELECT  "settings".* FROM "settings" ORDER BY "settings"."id" ASC LIMIT ?  [["LIMIT", 1]]
  Rendering pages/settings.html.erb within layouts/application
  Rendered pages/settings.html.erb within layouts/application (1.7ms)
  CACHE Setting Exists (0.0ms)  SELECT  1 AS one FROM "settings" LIMIT ?  [["LIMIT", 1]]
  CACHE Setting Load (0.0ms)  SELECT  "settings".* FROM "settings" ORDER BY "settings"."id" ASC LIMIT ?  [["LIMIT", 1]]
  Tgroup Load (0.2ms)  SELECT "tgroups".* FROM "tgroups"
  Rendered layouts/_navigation.html.erb (2.3ms)
  Rendered layouts/_footer.html.erb (0.3ms)
Completed 200 OK in 53ms (Views: 48.2ms | ActiveRecord: 0.7ms)

日志显示,不允许使用 80.107.134.220。 因此,如果您的应用程序在开发环境中工作,请将其添加到 development.rb

class Application < Rails::Application
  config.web_console.whitelisted_ips = '80.107.134.220'
end

在您的 config/environments/development.rb 中,添加

config.web_console.permissions = [some CIDR blocks or IP addresses]

https://github.com/rails/web-console/blob/master/README.markdown#configuration