create paginate by kaminari

parent df25189d
...@@ -33,7 +33,7 @@ gem 'whenever', require: false ...@@ -33,7 +33,7 @@ gem 'whenever', require: false
gem 'rubocop', '~> 0.88.0', require: false gem 'rubocop', '~> 0.88.0', require: false
# Use Capistrano for deployment # Use Capistrano for deployment
# gem 'capistrano-rails', group: :development # gem 'capistrano-rails', group: :development
gem 'will_paginate', '3.3.0' gem 'kaminari'
# Reduces boot times through caching; required in config/boot.rb # Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false gem 'bootsnap', '>= 1.1.0', require: false
......
...@@ -91,6 +91,18 @@ GEM ...@@ -91,6 +91,18 @@ GEM
io-like (0.3.1) io-like (0.3.1)
jbuilder (2.10.0) jbuilder (2.10.0)
activesupport (>= 5.0.0) activesupport (>= 5.0.0)
kaminari (1.2.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.1)
kaminari-activerecord (= 1.2.1)
kaminari-core (= 1.2.1)
kaminari-actionview (1.2.1)
actionview
kaminari-core (= 1.2.1)
kaminari-activerecord (1.2.1)
activerecord
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
listen (3.1.5) listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4) rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7) rb-inotify (~> 0.9, >= 0.9.7)
...@@ -234,7 +246,6 @@ GEM ...@@ -234,7 +246,6 @@ GEM
websocket-extensions (0.1.5) websocket-extensions (0.1.5)
whenever (1.0.0) whenever (1.0.0)
chronic (>= 0.6.3) chronic (>= 0.6.3)
will_paginate (3.3.0)
xpath (3.2.0) xpath (3.2.0)
nokogiri (~> 1.8) nokogiri (~> 1.8)
...@@ -248,6 +259,7 @@ DEPENDENCIES ...@@ -248,6 +259,7 @@ DEPENDENCIES
chromedriver-helper chromedriver-helper
coffee-rails (~> 4.2) coffee-rails (~> 4.2)
jbuilder (~> 2.5) jbuilder (~> 2.5)
kaminari
listen (>= 3.0.5, < 3.2) listen (>= 3.0.5, < 3.2)
mechanize (~> 2.7.6) mechanize (~> 2.7.6)
mysql2 (~> 0.5.3) mysql2 (~> 0.5.3)
...@@ -264,7 +276,6 @@ DEPENDENCIES ...@@ -264,7 +276,6 @@ DEPENDENCIES
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
web-console (>= 3.3.0) web-console (>= 3.3.0)
whenever whenever
will_paginate (= 3.3.0)
RUBY VERSION RUBY VERSION
ruby 2.6.6p146 ruby 2.6.6p146
......
...@@ -7,3 +7,4 @@ ...@@ -7,3 +7,4 @@
padding: 5px; padding: 5px;
} }
class JobsController < ApplicationController class JobsController < ApplicationController
def index def index
@total_job = Job.count
@jobs_list = Job.all_job
@cities = City.all @cities = City.all
@industries = Industry.all @industries = Industry.all
@total_job = Job.count
@jobs_list = Job.all_job.page(params[:page]).per(20)
end end
end end
class IndustryJob < ApplicationRecord class IndustryJob < ApplicationRecord
belongs_to :industry belongs_to :industry
belongs_to :job belongs_to :job
end end
...@@ -7,7 +7,13 @@ ...@@ -7,7 +7,13 @@
<div class="col-4"><strong>Total: <%= @total_job %> jobs</strong></div> <div class="col-4"><strong>Total: <%= @total_job %> jobs</strong></div>
<div class="col-4"><strong>Result for: ... jobs</strong></div> <div class="col-4"><strong>Result for: ... jobs</strong></div>
</div> </div>
<div class="paginate-jobs">
<%= paginate @jobs_list, left: 3, right: 3 %>
</div>
<div class="job-list"> <div class="job-list">
<%= render partial: "job", collection: @jobs_list, as: :job %> <%= render partial: "job", collection: @jobs_list, as: :job %>
</div> </div>
<div class="paginate-jobs">
<%= paginate @jobs_list, left: 3, right: 3 %>
</div>
</div> </div>
<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, data: { remote: remote }, rel: page.rel, class: 'page-link' %>
</li>
<% else %>
<li class="page-item">
<%= link_to page, url, remote: remote, rel: page.rel, 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>
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
<div class="total-job">Having <%= @total_jobs %> jobs for you!</div> <div class="total-job">Having <%= @total_jobs %> jobs for you!</div>
</div> </div>
</div> </div>
<div class="container"> <div class="container">
<div class="search-bar"> <div class="search-bar">
<%= render 'layouts/search_bar' %> <%= render 'layouts/search_bar' %>
......
...@@ -53,7 +53,6 @@ class CSVImporter ...@@ -53,7 +53,6 @@ class CSVImporter
description_job = "#{row["description"]} #{row["requirement"]}" description_job = "#{row["description"]} #{row["requirement"]}"
level = row["level"] level = row["level"]
salary = row["salary"] salary = row["salary"]
job = Job.find_or_create_by!(title: title_job, job = Job.find_or_create_by!(title: title_job,
description: description_job, description: description_job,
level: level, level: level,
......
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