Commit c6aba513 by Thanh Hung Pham

Display job detail

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