diff --git a/app/models/weather_art.rb b/app/models/weather_art.rb index 2156576..1eea6e5 100644 --- a/app/models/weather_art.rb +++ b/app/models/weather_art.rb @@ -12,11 +12,11 @@ class WeatherArt < ApplicationRecord validates :weather_date, presence: true validates :city_id, presence: true - scope :latest, ->(limit: 100) { + scope :latest, ->(limit = 100) { order(created_at: :desc).limit(limit) } - scope :by_popularity, ->(limit: 100) { + scope :by_popularity, ->(limit = 100) { if ActiveRecord::Base.connection.adapter_name.downcase == "sqlite" joins("LEFT JOIN ahoy_events ON json_extract(ahoy_events.properties, '$.weather_art_id') = weather_arts.id AND json_extract(ahoy_events.properties, '$.event_type') = 'weather_art_view'")