Commit 0003b462 by nnnghia98

render latest_jobs

parent f455b99f
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
class IndustriesController < ApplicationController class IndustriesController < ApplicationController
def index def index
@industries = Industry.page(params[:page]).per(Settings.col.page.per) @industries = Industry.all
end end
end end
...@@ -2,6 +2,6 @@ class TopsController < ApplicationController ...@@ -2,6 +2,6 @@ class TopsController < ApplicationController
def index def index
@vn_cities = City.city_order.take(Settings.top.city.limit) @vn_cities = City.city_order.take(Settings.top.city.limit)
@industries = Industry.industry_order.take(Settings.top.city.limit) @industries = Industry.industry_order.take(Settings.top.city.limit)
@jobs = Job.page(params[:page]).per(Settings.job.per_page) @jobs = Job.latest_jobs.take(Settings.top.job.limit)
end end
end end
...@@ -36,4 +36,8 @@ class Job < ApplicationRecord ...@@ -36,4 +36,8 @@ class Job < ApplicationRecord
has_many :industry_jobs has_many :industry_jobs
has_many :industries, through: :industry_jobs has_many :industries, through: :industry_jobs
def self.latest_jobs
@latest_jobs ||= Job.order(updated_at: :desc)
end
end end
<div class="col-md-3"> <div class="col-md-3">
<div class="col-show"> <div class="col-show">
<%= city.name %> (<%= (city.job_count) %>) <%= link_to city.name, jobs_path %> (<%= (city.job_count) %>)
</div> </div>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="col-show"> <div class="col-show">
<%= industry.name %> (<%= (industry.job_count) %>) <%= link_to industry.name, jobs_path %> (<%= (industry.job_count) %>)
</div> </div>
</div> </div>
<div class="box">
<div class="job_data">
<dl class="job_data_row">
<dt>Title</dt>
<dd><%= latest_jobs.title %></dd>
</dl>
<dl class="job_data_row">
<dt>Short description</dt>
<dd><%= truncate(latest_jobs.short_des, length: 250) %></dd>
</dl>
<dl class="job_data_row">
<dt>Salary</dt>
<dd><%= latest_jobs.salary %></dd>
</dl>
<dl class="job_data_row">
<dt>Location</dt>
<dd><%= latest_jobs.cities.first.name %></dd>
</dl>
</div>
</div>
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
<div class="row row-cols-4"> <div class="row row-cols-4">
<%= render partial: "cities/city", collection: @vn_cities %> <%= render partial: "cities/city", collection: @vn_cities %>
</div> </div>
<%= link_to "All cities", cities_path, class: "btn btn-lg btn-info" %> <%= link_to "All cities", cities_path, class: "btn btn-info" %>
</div> </div>
...@@ -4,5 +4,5 @@ ...@@ -4,5 +4,5 @@
<div class="row row-cols-5"> <div class="row row-cols-5">
<%= render partial: "industries/industry", collection: @industries %> <%= render partial: "industries/industry", collection: @industries %>
</div> </div>
<%= link_to "All industries", industries_path, class: "btn btn-lg btn-info" %> <%= link_to "All industries", industries_path, class: "btn btn-info" %>
</div> </div>
...@@ -13,9 +13,8 @@ ...@@ -13,9 +13,8 @@
<h3>Latest jobs</h3> <h3>Latest jobs</h3>
<div> <div>
<%= render partial: "jobs/job", collection: @jobs %> <%= render partial: "shared/latest_jobs", collection: @jobs %>
</div> </div>
<%= paginate @jobs %>
</div> </div>
<div class="top_cities"> <div class="top_cities">
......
...@@ -7,3 +7,5 @@ csv: ...@@ -7,3 +7,5 @@ csv:
top: top:
city: city:
limit: 9 limit: 9
job:
limit: 5
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