Commit c6aba513 by Thanh Hung Pham

Display job detail

parent d3967d64
...@@ -53,6 +53,8 @@ group :development do ...@@ -53,6 +53,8 @@ group :development do
gem 'figaro' gem 'figaro'
gem 'spring' gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0' gem 'spring-watcher-listen', '~> 2.0.0'
gem 'will_paginate', '3.1.5'
gem 'bootstrap-will_paginate', '1.0.0'
end end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
......
...@@ -49,6 +49,8 @@ GEM ...@@ -49,6 +49,8 @@ GEM
bindex (0.5.0) bindex (0.5.0)
binding_of_caller (0.7.2) binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1) debug_inspector (>= 0.0.1)
bootstrap-will_paginate (1.0.0)
will_paginate
builder (3.2.3) builder (3.2.3)
byebug (9.0.6) byebug (9.0.6)
capybara (2.14.4) capybara (2.14.4)
...@@ -190,6 +192,7 @@ GEM ...@@ -190,6 +192,7 @@ GEM
websocket-extensions (0.1.2) websocket-extensions (0.1.2)
whenever (0.9.7) whenever (0.9.7)
chronic (>= 0.6.3) chronic (>= 0.6.3)
will_paginate (3.1.5)
xpath (2.1.0) xpath (2.1.0)
nokogiri (~> 1.3) nokogiri (~> 1.3)
...@@ -200,6 +203,7 @@ DEPENDENCIES ...@@ -200,6 +203,7 @@ DEPENDENCIES
bcrypt (~> 3.1.7) bcrypt (~> 3.1.7)
better_errors better_errors
binding_of_caller binding_of_caller
bootstrap-will_paginate (= 1.0.0)
byebug byebug
capybara (~> 2.13) capybara (~> 2.13)
coffee-rails (~> 4.2) coffee-rails (~> 4.2)
...@@ -210,7 +214,6 @@ DEPENDENCIES ...@@ -210,7 +214,6 @@ DEPENDENCIES
mysql2 (>= 0.3.18, < 0.5) mysql2 (>= 0.3.18, < 0.5)
puma (~> 3.7) puma (~> 3.7)
rails (~> 5.1.1) rails (~> 5.1.1)
rubyzip
sass-rails (~> 5.0) sass-rails (~> 5.0)
selenium-webdriver selenium-webdriver
spring spring
...@@ -220,6 +223,7 @@ DEPENDENCIES ...@@ -220,6 +223,7 @@ DEPENDENCIES
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
web-console (>= 3.3.0) web-console (>= 3.3.0)
whenever whenever
will_paginate (= 3.1.5)
BUNDLED WITH BUNDLED WITH
1.15.1 1.15.1
...@@ -5,6 +5,25 @@ class JobsController < ApplicationController ...@@ -5,6 +5,25 @@ class JobsController < ApplicationController
end end
def show def show
@jobs = Job.all.limit(5) unless params[:city_id].nil?
@job_count = Job.where(city_id: params[:city_id]).count
@jobs = Job.where(city_id: params[:city_id]).paginate(page: params[:page])
@search_conditions = "All jobs in #{City.find(params[:city_id]).name}"
end
unless params[:category_id].nil?
@job_ids = JobCategory.where(category_id: params[:category_id]).select(:job_id)
@job_count = Job.where(id: @job_ids).count
@jobs = Job.where(id: @job_ids).paginate(page: params[:page])
@search_conditions = "All jobs in #{Category.find(params[:category_id]).name}"
end
end
def favorite
if user_signed_in?
else
redirect_to new_user_session_path
end
end end
end end
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<%- @categories.each do |category| -%> <%- @categories.each do |category| -%>
<%- if category.job_category.count > 0 -%> <%- if category.job_category.count > 0 -%>
<div class="col-md-3"> <div class="col-md-3">
<%= category.name %> <%= link_to category.name, jobs_show_path(category_id: category.id) %>
(<%= pluralize(category.job_category.count, 'job') %>) (<%= pluralize(category.job_category.count, 'job') %>)
</div> </div>
<%- end -%> <%- end -%>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<%- get_city_by_area(area).each do |city| -%> <%- get_city_by_area(area).each do |city| -%>
<%- if city.job.count > 0 -%> <%- if city.job.count > 0 -%>
<div class="col-md-4"> <div class="col-md-4">
<%= link_to city.name, jobs_show_path(city.id) %> <%= link_to city.name, jobs_show_path(city_id: city.id) %>
(<%= pluralize(city.job.count, 'job') %>) (<%= pluralize(city.job.count, 'job') %>)
</div> </div>
<%- end -%> <%- end -%>
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</div> </div>
<div class="row"> <div class="row">
Paging top <%= will_paginate %>
</div> </div>
<%- @jobs.each do |job| -%> <%- @jobs.each do |job| -%>
...@@ -29,12 +29,12 @@ ...@@ -29,12 +29,12 @@
<%= job.salary %> <%= job.salary %>
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<%= link_to 'Favorite', jobs_favorite_path %> <%= link_to 'Favorite', jobs_favorite_path(job_id: job.id) %>
</div> </div>
</div> </div>
<%- end -%> <%- end -%>
<div class="row"> <div class="row">
Paging bottom <%= will_paginate %>
</div> </div>
</div> </div>
...@@ -4,8 +4,10 @@ Rails.application.routes.draw do ...@@ -4,8 +4,10 @@ Rails.application.routes.draw do
get 'static_pages/home' get 'static_pages/home'
get '/cities', to: 'cities#show' get '/cities', to: 'cities#show'
get '/categories', to: 'categories#show' get '/categories', to: 'categories#show'
get 'jobs/applied_jobs'
get 'jobs/show/' get 'jobs/applied_jobs', to: 'jobs#applied_jobs'
get 'jobs/show/', to: 'jobs#show'
get 'jobs/favorite', to: 'jobs#favorite'
resource :cities resource :cities
devise_scope :user do devise_scope :user do
......
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