Commit f1070925 by Tô Ngọc Ánh

refactor code

parent afb60e6e
......@@ -16,7 +16,7 @@ class JobsController < ApplicationController
def results(object)
@keyword = object.try(:name) || object.try(:city)
@jobs = object.jobs.all.page(params[:page]).per(20)
@jobs = object.jobs.all.includes(:company, :locations, :industries).page(params[:page])
@locations = Location.select(:id, :city)
@industries = Industry.select(:id, :name)
render 'job_list'
......
......@@ -8,8 +8,8 @@
<% job.locations.each do |location| %>
<%= location.city %>
<% end %>
<strong>Salary: </strong><%= job.salary %>
</p>
<p><strong>Salary: </strong><%= job.salary %></p>
</div>
</div>
</div>
......@@ -7,9 +7,9 @@
<% job.locations.each do |location| %>
<%= location.city %>
<% end %>
<strong>Salary: </strong><%= job.salary %>
</p>
<p class='card-text'><%= strip_tags(job.description).truncate_words(40) %></p>
<p><strong>Salary: </strong><%= job.salary %></p>
<p class='card-text'><%= strip_tags(job.description).truncate(250) %></p>
</div>
<div class='btn-favorite p-2'>
<%= link_to 'Favorite', '#', class: 'btn btn-outline-danger btn-lg' %>
......
......@@ -7,8 +7,8 @@
</div>
<hr>
<div class='content'>
<%= paginate @jobs, window: 3 %>
<%= paginate @jobs %>
<%= render partial: 'jobs/job', collection: @jobs %>
<%= paginate @jobs, window: 3 %>
<%= paginate @jobs %>
</div>
</div>
# frozen_string_literal: true
Kaminari.configure do |config|
config.default_per_page = 20
# config.max_per_page = nil
config.window = 3
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
# config.max_pages = nil
# config.params_on_first_page = false
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