Commit eb37ee3e by Ngô Trung Hưng

create ID2

parent a35aba16
Pipeline #769 canceled with stages
in 0 seconds
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
class CityController < ApplicationController
def index
@list_cities_domestic = City.domestic
@list_cities_international = City.international
end
end
module CityHelper
end
...@@ -4,4 +4,12 @@ ...@@ -4,4 +4,12 @@
class City < ApplicationRecord class City < ApplicationRecord
has_many :city_jobs has_many :city_jobs
has_many :jobs, through: :city_jobs has_many :jobs, through: :city_jobs
scope :domestic, ->{ where(area: 1)}
scope :international, ->{ where(area: 0)}
scope :top_cities, ->(number) do joins(:jobs)
.group(:city_id)
.order(Arel.sql('count(jobs.id) DESC'))
.take(number)
end
end end
<div class="box_cityjobs">
<div class="box_cityjobs_name">
<%= link_to city.name, '#',class: 'cityjobs_link' %>
</div>
<div class="box_cityjobs_count">
<span><%= city.jobs.count %> Công việc</span>
</div>
</div>
\ No newline at end of file
<% provide(:title,'Top thành phố') %>
<div class="container">
<div class="box_option_location">
<div class="icon_box_option_location">
<span class="kl_icon_box_option_location">
<i class="fas fa-search-location"></i>
</span>
</div>
<div class="row">
<div class="col-lg-12">
<div class="box_option_location_header">
<span>Bạn muốn tìm việc trong hay ngoài nước?</span>
</div>
</div>
<div class="col-lg-6">
<button class="btn_option_location btn_option_location-vn">Việt Nam</button>
</div>
<div class="col-lg-6">
<button class="btn_option_location btn_option_location-qt">Nước ngoài</button>
</div>
</div>
</div>
</div>
<!-- Main -->
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="title_list_city title_list_city_vn">
<span>Các tỉnh, thành phố thuôc Việt Nam</span>
</div>
</div>
<div class="container">
<div class="row">
<% @list_cities_domestic.each do |city| %>
<% unless city.jobs.count < 1 %>
<div class="col-lg-3 col-md-4">
<%= render 'block_city_jobs', city: city %>
</div>
<% end %>
<% end %>
</div>
</div>
<div class="col-lg-12">
<div class="title_list_city title_list_city_qt">
<span>Quốc tế</span>
</div>
</div>
<div class="container">
<div class="row">
<% @list_cities_international.each do |city| %>
<% unless city.jobs.count < 1 %>
<div class="col-lg-3 col-md-4">
<%= render 'block_city_jobs', city: city %>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
</div>
Rails.application.routes.draw do Rails.application.routes.draw do
get 'city/index'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end end
require 'test_helper'
class CityControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get city_index_url
assert_response :success
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