change logic N+1 query

parent b34ebf96
class CitiesController < ApplicationController
VIETNAM = 1
FOREIGN = 0
def index
@cities_vietnam = City.location(1)
@cities_international = City.location(0)
@cities_vietnam = City.location(VIETNAM)
@cities_international = City.location(FOREIGN)
end
end
......@@ -16,7 +16,7 @@ class Job < ApplicationRecord
has_many :histories
has_many :users, through: :histories
scope :limit_job, -> { limit(5).order(created_at: :desc) }
scope :limit_job, -> { includes(:cities, :company).order(created_at: :desc).limit(5) }
scope :all_job, -> { all.order(created_at: :desc) }
def convert_job
......
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