Skip to content

Commit

Permalink
enable web console as a development option
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyThiessen committed Jan 13, 2025
1 parent d11b67d commit a07b8d5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/console_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# frozen_string_literal: true

# On webpage console for dev environments
class ConsoleController < ApplicationController
def show; end
end
5 changes: 5 additions & 0 deletions app/views/console/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h1>Rails Console</h1>
<!-- We don't want to double render the console -->
<% if Rails.configuration.enable_web_console == false %>
<%= console %>
<% end %>
4 changes: 4 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,9 @@
<% end %>
<% end %>
<% end %>

<% if Rails.env.development? and Rails.configuration.enable_web_console == true %>
<%= console %>
<% end %>
</body>
</html>
2 changes: 2 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
]
}

config.enable_web_console = false

# Create a new production log file [daily, weekly, monthly,..]
# if ENV['RAILS_DAILY_LOG_ROTATION'].present?
# logger = ActiveSupport::Logger.new(config.default_log_file, 'daily')
Expand Down
2 changes: 2 additions & 0 deletions config/routes/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
get '/rails/info/routes' => 'rails/info#routes'
get '/rails/info' => 'rails/info#index'

get '/console', to: 'console#show'

mount Lookbook::Engine, at: '/rails/lookbook'
end

0 comments on commit a07b8d5

Please sign in to comment.