feat: update RSS feed routes and logging

- Change route for RSS feed to use defaults for format
- Add logging to RssController#feed to track request format

These changes improve the clarity of the routing for the RSS feed
and enhance debugging capabilities by logging the request format.
The new route definition ensures that the feed responds correctly
with the default format, while the logging provides insight into
how the feed is being accessed.
This commit is contained in:
songtianlun 2025-03-05 15:18:15 +08:00
parent 4e322bd6e9
commit d39a7deea2
2 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,8 @@ class RssController < ApplicationController
def feed
@weather_arts = WeatherArt.order(created_at: :desc).includes(:image_attachment, city: [ :country, :state ]).limit(20)
Rails.logger.info "RssController#feed - Format: #{request.format}"
respond_to do |format|
format.rss { render layout: false }
format.json { render json: generate_json_feed }

View File

@ -27,7 +27,8 @@ Rails.application.routes.draw do
get "home/index"
get "sitemaps", to: "sitemaps#index"
get "sitemaps/*path", to: "sitemaps#show", format: false
get "feed", to: "rss#feed", format: "rss", as: :rss_feed
get "feed", to: "rss#feed", defaults: { format: "rss" }, as: :feed
get "rss(.:format)", to: "rss#feed", as: :rss_feed
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)