From 2f84dde40f21f0884b93144b4b4223b27fb1fd04 Mon Sep 17 00:00:00 2001 From: songtianlun Date: Sat, 15 Feb 2025 17:47:44 +0800 Subject: [PATCH] refactor: remove random arts from homepage The code refactoring is done by commenting out the random art functionality from the index page and removing the corresponding code from the home_controller. This eliminates the need for a random art display, simplifying the application's behavior. This also fixes a bug where it was showing random arts and makes it so the application runs more efficiently since it's not calling the unnecessary code anymore. --- app/controllers/home_controller.rb | 2 +- app/views/home/index.html.erb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index ba803bc..db0c1a2 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,7 +1,7 @@ class HomeController < ApplicationController def index @popular_arts = WeatherArt.includes(:city, :image_attachment).by_popularity(3) - @random_arts = WeatherArt.includes(:city, :image_attachment).random(3) + # @random_arts = WeatherArt.includes(:city, :image_attachment).random(3) @latest_arts = WeatherArt.includes(:city, :image_attachment).latest(6) @featured_arts = WeatherArt.includes(:city, :image_attachment).order(created_at: :desc).limit(5) set_meta_tags( diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index fc78a2f..1a32e67 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -29,8 +29,8 @@ <%= render 'home/arts', arts: @latest_arts %>

Popular Weather Art

<%= render 'home/arts', arts: @popular_arts %> -

Random Weather Art

- <%= render 'home/arts', arts: @random_arts %> + + <%#= render 'home/arts', arts: @random_arts %>