diff --git a/app/models/weather_art.rb b/app/models/weather_art.rb index 175b7c4..f624037 100644 --- a/app/models/weather_art.rb +++ b/app/models/weather_art.rb @@ -34,13 +34,13 @@ class WeatherArt < ApplicationRecord scope :random, ->(limit = 3) { if ActiveRecord::Base.connection.adapter_name.downcase == "postgresql" # PostgreSQL 优化版本 - order(Arel.sql('RANDOM()')).limit(limit) + order(Arel.sql("RANDOM()")).limit(limit) elsif ActiveRecord::Base.connection.adapter_name.downcase == "mysql2" # MySQL 优化版本 - order(Arel.sql('RAND()')).limit(limit) + order(Arel.sql("RAND()")).limit(limit) else # SQLite 或其他数据库的通用版本 - order(Arel.sql('RANDOM()')).limit(limit) + order(Arel.sql("RANDOM()")).limit(limit) end } diff --git a/app/views/cities/index.html.erb b/app/views/cities/index.html.erb index 425138f..3706f00 100644 --- a/app/views/cities/index.html.erb +++ b/app/views/cities/index.html.erb @@ -93,7 +93,7 @@
<% @current_region.countries.order(:name).each do |country| %>