change logic city

parent 3e39495d
Pipeline #844 failed with stages
in 0 seconds
class CitiesController < ApplicationController class CitiesController < ApplicationController
def index def index
@cities_vietnam = City.vietnam @cities_vietnam = City.location(1)
@cities_international = City.international @cities_international = City.location(0)
end end
end end
...@@ -3,6 +3,5 @@ class City < ApplicationRecord ...@@ -3,6 +3,5 @@ class City < ApplicationRecord
has_many :jobs, through: :city_jobs has_many :jobs, through: :city_jobs
scope :top_city, -> { joins(:jobs).group(:city_id).order('count(job_id) DESC').limit(9) } scope :top_city, -> { joins(:jobs).group(:city_id).order('count(job_id) DESC').limit(9) }
scope :vietnam, -> { joins(:jobs).group(:city_id).order('count(job_id) DESC').where(location: 1) } scope :location, ->(number) { joins(:jobs).group(:city_id).order('count(job_id) DESC').where(location: number) }
scope :international, -> { joins(:jobs).group(:city_id).order('count(job_id) DESC').where(location: 0) }
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment