Rails 5.2.2 Web控制台未显示

时间:2019-01-18 12:41:49

标签: ruby-on-rails web-console

尽管我已尝试将<%= console%>放置在application.htm.erb的正文中,但是无论如何我都无法使Web控制台出现在任何页面上。

我正在使用Rails v5.2.2和Web控制台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)

2 个答案:

答案 0 :(得分:0)

日志说,不允许80.107.134.220。 因此,如果您的应用程序可以在开发环境中运行,请将其添加到 development.rb

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

答案 1 :(得分:0)

在您的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