Browse Source

main controller instead of welcome

main
pvincent 1 year ago
parent
commit
765cb64d31
  1. 5
      app/controllers/application_controller.rb
  2. 12
      app/controllers/main_controller.rb
  3. 23
      app/controllers/welcome_controller.rb
  4. 2
      app/helpers/main_helper.rb
  5. 4
      app/views/layouts/application.html.erb
  6. 2
      app/views/main/about.html.erb
  7. 2
      app/views/main/home.html.erb
  8. 5
      app/views/welcome/index.html.erb
  9. 4
      config/routes.rb
  10. 13
      test/controllers/main_controller_test.rb

5
app/controllers/application_controller.rb

@ -1,2 +1,7 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
around_action do |_, action|
logger.measure_error "Took too long to complete, please review your code as asynchronous task", min_duration: 3000 do
action.call
end
end
end end

12
app/controllers/main_controller.rb

@ -0,0 +1,12 @@
class MainController < ApplicationController
def home
end
def about
logger.debug "some debugging info"
logger.info "efficient logging for dark theme"
logger.warn "a warning"
logger.error "an error"
sleep 3
end
end

23
app/controllers/welcome_controller.rb

@ -1,23 +0,0 @@
class WelcomeController < ApplicationController
def index
# logger.measure_error "Took too long to complete", min_duration: 3000 do
# logger.debug("Debugging information to aid with problem determination")
# logger.info("Informational message such as request received\nline 2\nline3")
# logger.warn("Warn about something in the system")
# logger.error("An error occurred during processing")
# logger.fatal("Oh no something really bad happened")
# logger.measure_info "Called external interface" do
# sleep 0.1 # Code to call external service ...
# end
# SemanticLogger.tagged(user: "Jack", zip_code: 12345) do
# # All log entries in this block will include the above named tags
# logger.debug("Hello World")
# end
logger.info("efficient logging for dark theme")
# raise "exception"
# end
end
end

2
app/helpers/main_helper.rb

@ -0,0 +1,2 @@
module MainHelper
end

4
app/views/layouts/application.html.erb

@ -9,6 +9,10 @@
<%= javascript_importmap_tags %> <%= javascript_importmap_tags %>
</head> </head>
<body> <body>
<nav>
<%= link_to 'home', :root %>
<%= link_to 'about', main_about_path %>
</nav>
<%= yield %> <%= yield %>
</body> </body>
</html> </html>

2
app/views/main/about.html.erb

@ -0,0 +1,2 @@
<h1>Main#about</h1>
<p>Find me in app/views/main/about.html.erb</p>

2
app/views/main/home.html.erb

@ -0,0 +1,2 @@
<h1>Main#home</h1>
<p>Find me in app/views/main/home.html.erb</p>

5
app/views/welcome/index.html.erb

@ -1,5 +0,0 @@
<h1>Welcome Aboard</h1>
<ul>
<li>Rails 7</li>
<li>Efficient Logging for dark theme</li>
</ul>

4
config/routes.rb

@ -1,3 +1,5 @@
Rails.application.routes.draw do Rails.application.routes.draw do
root "welcome#index"
root "main#home"
get "main/about"
end end

13
test/controllers/main_controller_test.rb

@ -0,0 +1,13 @@
require "test_helper"
class MainControllerTest < ActionDispatch::IntegrationTest
test "should get home" do
get main_home_url
assert_response :success
end
test "should get about" do
get main_about_url
assert_response :success
end
end
Loading…
Cancel
Save