Commit b69b8f5c by Ngô Trung Hưng

..

parent 1b9c0666
Pipeline #1004 failed with stages
in 0 seconds
......@@ -2,12 +2,25 @@
# Home page
class HomeController < ApplicationController
before_action :load_data_dropdown
def index
@industries = Industry.order(name: :asc).all
@job_count = Job.count
@cities = City.all_cities
@lasted_jobs = Job.order(created_at: :desc).limit(Job::NUMBER_LASTED_JOB)
@top_cities = City.top_cities(9)
@top_industries = Industry.top_industries(9)
end
def search
@search = Job.search do
keywords(params[:key])
paginate :page => params[:page], per_page: 5
end
@keyword = params[:key]
end
def load_data_dropdown
@industries = Industry.order(name: :asc).all
@cities = City.select(:id, :name)
end
end
......@@ -3,13 +3,6 @@
# Job controller
class JobController < ApplicationController
before_action :load_data_dropdown, only: :index
# after_action :add_job_to_history, only: :detail
def search
@search = Job.search do
keywords(params[:q])
end
end
def add_job_to_history
current_user.histories.create(session[:params_job_id]) if user_signed_in?
......
......@@ -9,4 +9,8 @@ class Company < ApplicationRecord
def convert_to_slug
self.slug = Slug.to_slug("#{name} #{rand(10000)}")
end
searchable do
text :name, default_boost: 2
text :address
end
end
......@@ -17,7 +17,6 @@ class Job < ApplicationRecord
has_many :histories
has_many :favorites
searchable do
text :name, default_boost: 2
text :description
text :name
end
end
......@@ -23,11 +23,10 @@
<h4 class="show_total_job"><%= t('pages.banner.slogan_3', job_count: @job_count) %></h4>
<% end %>
</div>
<%= form_with url: search_path, method: :get, local: true do |f| %>
<%= form_with url: search_path, method: :get, local: true, skip_enforcing_utf8: true do |f| %>
<div class="filter_box">
<div class="search_input">
<%= f.text_field :q, class: 'custom_input_search' %>
<%= f.text_field :key, class: 'custom_input_search', placeholder: t('pages.banner.search_placeholder') %>
</div>
<div class="search_industries">
<div class="icon_list">
......
<% provide(:title ,"#{t('pages.detail.br_title')}") %>
<%= render 'home/banner_and_search' %>
<div class="padding_index"></div>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="breadcrumb_total_search">
<span class="breadcrumb-item active">
<div style="word-wrap: break-word;">
<%= t('pages.result.result_find', job: @search.total, key: @keyword).html_safe if @search.total.positive? %>
<%= t('pages.result.no_result_find', key: @keyword).html_safe if @search.total.zero? %>
</div>
</span>
</div>
</div>
<div class="col-lg-12">
<div class="breadcrumb_total_search_pagination_jobs">
<div class="pagination_jobs">
<div id="paginator">
<%= paginate @search.hits %>
</div>
</div>
</div>
</div>
</div>
</div>
<%= render 'job/modal_login' %>
<% @search.each_hit_with_result do |hit, post| %>
<%= render 'job/block_info_job', data: post %>
<% end %>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="breadcrumb_total_search_pagination_jobs">
<div class="pagination_jobs">
<div class="paginator">
<%= paginate @search.hits %>
</div>
</div>
</div>
</div>
</div>
</div>
<%= render 'shared/scroll_top' %>
......@@ -11,7 +11,7 @@
<%= t('pages.result.result_find', job: @data.total_count, key: @keyword).html_safe %>
</div>
<% else %>
<%= t('pages.result.no_result_find', key: @keyword).html_safe %>
<%= t('pages.result.no_result_find', key: @keyword).html_safe %>
<% end %>
</span>
</div>
......
<% @search.each_hit_with_result do |hit, post| %>
<h2><%= h post.name %></h2>
<h2><%= h post.industries.first.name %></h2>
<p><%= h truncate(post.level, length: 100) %></p>
<% end %>
\ No newline at end of file
......@@ -33,7 +33,7 @@ en:
slogan: 'VENJOB HUMAN RESOURCE PLATFORM'
slogan_2: 'Instantly discover the best jobs on VenJob'
slogan_3: 'Instantly discover %{job_count} the best jobs on VenJob'
search_placeholder: 'Input title, companies, locations...'
search_placeholder: 'Input name jobs . . .'
btn_text_search: 'Find Job'
all_industries: 'All industries'
all_locations: 'All locations'
......
......@@ -33,7 +33,7 @@ vi:
slogan: 'NỀN TẢNG TUYỂN DỤNG NHÂN SỰ VENJOB'
slogan_2: 'Khám phá ngay những việc làm tốt nhất trên VenJob'
slogan_3: "Khám phá ngay %{job_count} việc làm tốt nhất trên VenJob"
search_placeholder: 'Nhập tiêu đề, công ty, địa điểm...'
search_placeholder: 'Nhập tên công việc. . .'
btn_text_search: 'Tìm việc'
all_industries: 'Tất cả nghành nghề'
all_locations: 'Tất cả đỉa điểm'
......
......@@ -6,7 +6,7 @@ Rails.application.routes.draw do
devise_for :users, controllers: { registrations: 'registrations' }
root 'home#index'
get 'search', to: 'job#search', as: :search
get 'search', to: 'home#search', as: :search
get 'register/:code', to: 'users#confirm_sign_up', as: :confirm_sign_up
get 'industries', to: 'industry#index', as: :industry_index
......
4373
\ No newline at end of file
4204
\ No newline at end of file
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