Commit c5eb1f47 by Ngô Trung Hưng

..

parent c4c3b235
Pipeline #810 failed with stages
in 0 seconds
......@@ -2,26 +2,11 @@
# Job controller
class JobController < ApplicationController
before_action :load_data_dropdown, only: %i[find_jobs_by_industry find_jobs_by_city find_jobs_by_company]
before_action :load_data_dropdown, only: :index
def find_jobs_by_city
city = City.find(params[:key_city])
result(city)
end
def find_jobs_by_industry
industry = Industry.find(params[:key_industry])
result(industry)
end
def find_jobs_by_company
company = Company.find(params[:key_company])
result(company)
end
def find_jobs
d = params[:model].capitalize
obj = .find(params[:id])
def index
model = Object.const_get(params[:model].capitalize)
obj = model.find(params[:id])
result(obj)
end
......
module Slug
def to_slug(str)
str = str.to_s.strip.downcase
accents = {
%w[à á ạ ả ã â ầ ấ ậ ẩ ẫ ă ằ ắ ặ ẳ ẵ] => 'a',
%w[è é ẹ ẻ ẽ ê ề ế ệ ể ễ] => 'e',
%w[ì í ị ỉ ĩ] => 'i',
%w[ò ó ọ ỏ õ ô ồ ố ộ ổ ỗ ơ ờ ớ ợ ở ỡ] => 'o',
%w[ù ú ụ ủ ũ ư ừ ứ ự ử ữ] => 'u',
%w[ỳ ý ỵ ỷ ỹ] => 'y',
%w[đ] => 'd'
}
accents.each do |ac, rep|
ac.each do |s|
str = str.tr(s, rep)
end
end
str = str.gsub(/[^a-zA-Z0-9 ]/, '')
str = str.gsub(/[ ]+/, ' ')
str.tr(' ', '-')
end
end
\ No newline at end of file
......@@ -2,7 +2,7 @@
<div class="col-lg-3 col-md-4">
<div class="box_cityjobs">
<div class="box_cityjobs_name">
<%= link_to city.name, "/jobs/city/#{city.id}", class: 'cityjobs_link' %>
<%= link_to city.name, jobs_path(model: 'city', id: city.id), class: 'cityjobs_link' %>
</div>
<div class="box_cityjobs_count">
<span><%= city.jobs.count %> Công việc</span>
......
......@@ -9,10 +9,10 @@
<div class="box_info_city">
<div class="ct_name">
<!-- <%= link_to city.name, "/jobs/city/#{city.id}" ,class: 'link_ct' %> -->
<%= link_to city.name, "/jobs/city/#{city.id}" ,class: 'link_ct' %>
<%= link_to city.name, jobs_path(model: 'city', id: city.id),class: 'link_ct' %>
</div>
<div class="ct_jobs_count">
<%= link_to "#{city.jobs.count} công việc", "/jobs/city/#{city.id}" ,class: 'link_ct' %>
<%= link_to "#{city.jobs.count} công việc", jobs_path(model: 'city', id: city.id),class: 'link_ct' %>
</div>
</div>
</div>
......
......@@ -8,10 +8,10 @@
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
<div class="box_info_city">
<div class="ct_name">
<%= link_to industry.name, "/jobs/industry/#{industry.id}", class: 'link_ct' %>
<%= link_to industry.name, jobs_path(model: 'industry', id: industry.id), class: 'link_ct' %>
</div>
<div class="ct_jobs_count">
<%= link_to "#{industry.jobs.count} công việc", "/jobs/industry/#{industry.id}", class: 'link_ct' %>
<%= link_to "#{industry.jobs.count} công việc", jobs_path(model: 'industry', id: industry.id), class: 'link_ct' %>
</div>
</div>
</div>
......
<div class="col-lg-3 col-md-4">
<div class="box_cityjobs">
<div class="box_cityjobs_name">
<%= link_to industry.name, "/jobs/industry/#{industry.id}", class: 'cityjobs_link' %>
<%= link_to industry.name, jobs_path(model: 'industry', id: industry.id), class: 'cityjobs_link' %>
</div>
<div class="box_cityjobs_count">
<span><%= industry.jobs.count %> Công việc</span>
......
......@@ -6,6 +6,5 @@ Rails.application.routes.draw do
get 'city/index'
# Search
get 'jobs/:model/:id', to: 'job#find_jobs'
get 'jobs/:model/:id', to: 'job#index', as: :jobs
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