today_ai_weather/app/controllers/arts_controller.rb
songtianlun bafb90f5fb style: format code style in Gemfile and controllers
- Adjust spacing around the quotes in the Gemfile
- Standardize spacing in the arts_controller for improved readability
- Modify routes file for consistent array formatting

These changes enhance the consistency of code style across the project without altering any functionality or behavior.
2025-01-23 17:33:01 +08:00

22 lines
684 B
Ruby

class ArtsController < ApplicationController
def index
@regions = Region.all
@current_region = Region.find(params[:region]) if params[:region].present?
@weather_arts = WeatherArt.includes(city: [ :country, { country: :region } ])
if @current_region
@weather_arts = @weather_arts.joins(city: :country)
.where(countries: { region_id: @current_region.id })
end
@weather_arts = if params[:sort] == "oldest"
@weather_arts.order(created_at: :asc)
else
@weather_arts.order(created_at: :desc)
end
@weather_arts = @weather_arts.page(params[:page]).per(10)
end
end