Commit 2874f419 by nnnghia98

render partial indsutries

parent f4629fed
...@@ -109,3 +109,11 @@ footer { ...@@ -109,3 +109,11 @@ footer {
html { html {
scroll-behavior: smooth; scroll-behavior: smooth;
} }
/* banner */
.banner {
img {
width: 75%;
}
}
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
class TopsController < ApplicationController 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.all @industries = Industry.industry_order.take(Settings.top.city.limit)
@jobs = Job.page(params[:page]).per(Settings.job.per_page) @jobs = Job.page(params[:page]).per(Settings.job.per_page)
end end
end end
...@@ -15,4 +15,12 @@ ...@@ -15,4 +15,12 @@
class Industry < ApplicationRecord class Industry < ApplicationRecord
has_many :industry_jobs has_many :industry_jobs
has_many :jobs, through: :industry_jobs has_many :jobs, through: :industry_jobs
def job_count
@job_count ||= jobs.count
end
def self.industry_order
@industry_order ||= all.sort_by(&:job_count).reverse
end
end end
<div class="col-show"><%= industry.name %></div> <div class="col-md-3">
<div class="col-show">
<%= industry.name %> (<%= (industry.job_count) %>)
</div>
</div>
...@@ -3,4 +3,3 @@ ...@@ -3,4 +3,3 @@
<%= render partial: "industries/industry", collection: @industries %> <%= render partial: "industries/industry", collection: @industries %>
</div> </div>
</div> </div>
<%= paginate @industries %>
<h3>Top industries</h3>
<div class="container">
<div class="row row-cols-5">
<%= render partial: "industries/industry", collection: @industries %>
</div>
<%= link_to "All industries", industries_path, class: "btn btn-lg btn-primary" %>
</div>
...@@ -23,13 +23,6 @@ ...@@ -23,13 +23,6 @@
</div> </div>
<div class="top_industries"> <div class="top_industries">
<h3>Top industries</h3> <%= render partial: "shared/top_industries"%>
<div class="container">
<div class="row row-cols-5">
<%= render partial: "industries/industry", collection: @industries %>
</div>
</div>
<%= paginate @industries %>
</div> </div>
</div> </div>
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