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.
This commit is contained in:
songtianlun 2025-02-15 17:47:44 +08:00
parent abdb40e4bf
commit 2f84dde40f
2 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
class HomeController < ApplicationController class HomeController < ApplicationController
def index def index
@popular_arts = WeatherArt.includes(:city, :image_attachment).by_popularity(3) @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) @latest_arts = WeatherArt.includes(:city, :image_attachment).latest(6)
@featured_arts = WeatherArt.includes(:city, :image_attachment).order(created_at: :desc).limit(5) @featured_arts = WeatherArt.includes(:city, :image_attachment).order(created_at: :desc).limit(5)
set_meta_tags( set_meta_tags(

View File

@ -29,8 +29,8 @@
<%= render 'home/arts', arts: @latest_arts %> <%= render 'home/arts', arts: @latest_arts %>
<h2 class="text-3xl font-display font-bold text-center">Popular Weather Art</h2> <h2 class="text-3xl font-display font-bold text-center">Popular Weather Art</h2>
<%= render 'home/arts', arts: @popular_arts %> <%= render 'home/arts', arts: @popular_arts %>
<h2 class="text-3xl font-display font-bold text-center">Random Weather Art</h2> <!-- <h2 class="text-3xl font-display font-bold text-center">Random Weather Art</h2>-->
<%= render 'home/arts', arts: @random_arts %> <%#= render 'home/arts', arts: @random_arts %>
</section> </section>
</div> </div>
<div class="text-center mt-12 mb-12"> <div class="text-center mt-12 mb-12">