Commit 044c9439 by Xuan Trung Le

config kiminari view and settings.yml

parent a9dbeb91
...@@ -11,21 +11,21 @@ class JobsController < ApplicationController ...@@ -11,21 +11,21 @@ class JobsController < ApplicationController
def city def city
city = City.find(params[:city_id]) city = City.find(params[:city_id])
@jobs = city.jobs.includes(:company).page(params[:page]).per(Settings.pagination.job_per_page) @jobs = city.jobs.includes(:company).page(params[:page])
@result = "jobs/City/#{city.name}" @result = "jobs/City/#{city.name}"
render template: "jobs/job_lists" render template: "jobs/job_lists"
end end
def industry def industry
industry = Industry.find(params[:industry_id]) industry = Industry.find(params[:industry_id])
@jobs = industry.jobs.includes(:company).page(params[:page]).per(Settings.pagination.job_per_page) @jobs = industry.jobs.includes(:company).page(params[:page])
@result = "jobs/Industry/#{industry.name}" @result = "jobs/Industry/#{industry.name}"
render template: "jobs/job_lists" render template: "jobs/job_lists"
end end
def company def company
company = Company.find(params[:company_id]) company = Company.find(params[:company_id])
@jobs = company.jobs.page(params[:page]).per(Settings.pagination.job_per_page) @jobs = company.jobs.page(params[:page])
@result = "jobs/Company/#{company.name}" @result = "jobs/Company/#{company.name}"
render template: "jobs/job_lists" render template: "jobs/job_lists"
end end
......
class Settings < Settingslogic class Settings < Settingslogic
source "#{Rails.root}/config/application.yml" source "#{Rails.root}/config/settings.yml"
namespace Rails.env namespace Rails.env
end end
<li class="page-item">
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, remote: remote, class: 'page-link' %>
</li>
<li class='page-item disabled'>
<%= link_to raw(t 'views.pagination.truncate'), '#', class: 'page-link' %>
</li>
<li class="page-item">
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, remote: remote, class: 'page-link' %>
</li>
<li class="page-item">
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, rel: 'next', remote: remote, class: 'page-link' %>
</li>
<% if page.current? %>
<li class="page-item active">
<%= content_tag :a, page, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link' %>
</li>
<% else %>
<li class="page-item">
<%= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)), class: 'page-link' %>
</li>
<% end %>
<%= paginator.render do %>
<nav>
<ul class="pagination">
<%= first_page_tag unless current_page.first? %>
<%= prev_page_tag unless current_page.first? %>
<% each_page do |page| %>
<% if page.left_outer? || page.right_outer? || page.inside_window? %>
<%= page_tag page %>
<% elsif !page.was_truncated? -%>
<%= gap_tag %>
<% end %>
<% end %>
<%= next_page_tag unless current_page.last? %>
<%= last_page_tag unless current_page.last? %>
</ul>
</nav>
<% end %>
<li class="page-item">
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, rel: 'prev', remote: remote, class: 'page-link' %>
</li>
# frozen_string_literal: true
Kaminari.configure do |config|
config.default_per_page = 20
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
# config.params_on_first_page = false
end
defaults: &defaults
top:
job_per_page: 5
industry_per_page: 9
city_per_page: 9
development:
<<: *defaults
test:
<<: *defaults
production:
<<: *defaults
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