Commit 0226f7a2 by Thanh Hung Pham

Fix comment - change path

parent b6201f91
class CategoriesController < ApplicationController class CategoriesController < ApplicationController
def show def index
@categories = Category.all @categories = Category.all
end end
def show
@job_ids = JobCategory.where(category_id: params[:id]).select(:job_id)
@job_count = Job.where(id: @job_ids).count
@jobs = Job.where(id: @job_ids).page params[:page]
@search_conditions = "All jobs in #{Category.find(params[:id]).name}"
render 'jobs/index.html.erb'
end
end end
class CitiesController < ApplicationController class CitiesController < ApplicationController
def show def index
@areas = Area.all @areas = Area.all
end end
def show
@job_count = Job.all_jobs_in_city_id(params[:id]).count
@jobs = Job.where(city_id: params[:id]).page params[:page]
@search_conditions = "All jobs in #{City.find(params[:id]).name}"
render 'jobs/index.html.erb'
end
end end
class CompaniesController < ApplicationController
def show
@job_count = Job.all_jobs_in_company_id(params[:id]).count
@jobs = Job.where(company_id: params[:id]).page params[:page]
@search_conditions = "All jobs in #{Company.find(params[:id]).name}"
render 'jobs/index.html.erb'
end
end
...@@ -3,7 +3,7 @@ class JobsController < ApplicationController ...@@ -3,7 +3,7 @@ class JobsController < ApplicationController
@applied_jobs = current_user.applies @applied_jobs = current_user.applies
end end
def detail def show
@job = Job.find(params[:id]) @job = Job.find(params[:id])
@history = History.find_or_create_by(user: current_user, job: @job) @history = History.find_or_create_by(user: current_user, job: @job)
@history.touch(:updated_at) @history.touch(:updated_at)
...@@ -47,25 +47,7 @@ class JobsController < ApplicationController ...@@ -47,25 +47,7 @@ class JobsController < ApplicationController
end end
def show def index
if params[:city_id].present?
@job_count = Job.all_jobs_in_city_id(params[:city_id]).count
@jobs = Job.where(city_id: params[:city_id]).page params[:page]
@search_conditions = "All jobs in #{City.find(params[:city_id]).name}"
end
if params[:category_id].present?
@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).page params[:page]
@search_conditions = "All jobs in #{Category.find(params[:category_id]).name}"
end
if params[:company_id].present?
@job_count = Job.all_jobs_in_company_id(params[:company_id]).count
@jobs = Job.where(company_id: params[:company_id]).page params[:page]
@search_conditions = "All jobs in #{Company.find(params[:company_id]).name}"
end
end end
def favorite def favorite
...@@ -80,6 +62,7 @@ class JobsController < ApplicationController ...@@ -80,6 +62,7 @@ class JobsController < ApplicationController
def favorited_jobs def favorited_jobs
@favorited_jobs = Favorite.where(user: current_user) @favorited_jobs = Favorite.where(user: current_user)
end end
def history_jobs def history_jobs
......
...@@ -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">
<%= link_to category.name, jobs_show_path(category_id: category.id) %> <%= link_to category.name, category_path(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 @@
<%- Area.get_city_by_area(area).each do |city| -%> <%- Area.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: city.id) %> <%= link_to city.name, city_path(city.id) %>
(<%= pluralize(city.job.count, 'job') %>) (<%= pluralize(city.job.count, 'job') %>)
</div> </div>
<%- end -%> <%- end -%>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<tbody> <tbody>
<%- @applied_jobs.each do |apply| -%> <%- @applied_jobs.each do |apply| -%>
<tr> <tr>
<td> <%= link_to apply.job.name, jobs_detail_path(id: apply.job.id) %> </td> <td> <%= link_to apply.job.name, job_path(apply.job.id) %> </td>
<td> <%= truncate(apply.job.description, length: 250) %> </td> <td> <%= truncate(apply.job.description, length: 250) %> </td>
<td> <%= apply.job.city.try(:name) %> </td> <td> <%= apply.job.city.try(:name) %> </td>
<td> <%= apply.job.salary %> </td> <td> <%= apply.job.salary %> </td>
......
<%- provide(:title, 'Job Detail') -%>
<div class="well">
<h2><%= @job.name %></h2>
<div class="row form-group">
<div class="col-md-9 col-md-offset-1">
<div class="row">
Company:
<%= link_to @job.company.try(:name), jobs_show_path(company_id: @job.company.id) unless @job.company.nil? %>
</div>
<div class="row">
Location:
<%= link_to @job.city.try(:name), jobs_show_path(city_id: @job.city.id) unless @job.city.nil? %>
</div>
<div class="row">
Salary:
<%= @job.salary %>
</div>
<div class="row">
Description:</br>
<%= @job.description %>
</div>
</div>
<div class="col-md-2">
<%- if user_signed_in? -%>
<%- if Apply.where(user: current_user, job: @job).blank? -%>
<%= link_to 'Apply', jobs_apply_path(job_id: @job.id), class: 'btn btn-primary' %>
<%- else -%>
<%= link_to 'Applied', '#', class: 'btn btn-primary' %>
<%- end -%>
<%- else -%>
<%= link_to 'Apply', new_user_session_path, class: 'btn btn-primary' %>
<%- end -%>
</div>
</div>
<div class="row">
<div class="col-md-offset-3 ">
<%- if user_signed_in? -%>
<%- if Apply.where(user: current_user, job: @job).blank? -%>
<%= link_to 'Apply', jobs_apply_path(job_id: @job.id), class: 'btn btn-primary' %>
<%- else -%>
<%= link_to 'Applied', '#', class: 'btn btn-primary' %>
<%- end -%>
<%- else -%>
<%= link_to 'Apply', new_user_session_path, class: 'btn btn-primary' %>
<%- end -%>
<%- if user_signed_in? -%>
<%- if Favorite.where(user: current_user, job: @job).blank? -%>
<%= link_to 'Favorite', '#', class: 'favorite_add btn btn-primary' %>
<%- else -%>
<%= link_to 'Favorite', '#', class: 'favorite_add btn btn-primary', disabled: true %>
<%- end -%>
<%- else -%>
<%= link_to 'Favorite', new_user_session_path, class: 'btn btn-primary' %>
<%- end -%>
<input type="hidden" id="job_id" name="job_id" value="<%= @job.id %>">
</div>
</div>
</div>
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<tbody> <tbody>
<%- @favorited_jobs.each do |favorite| -%> <%- @favorited_jobs.each do |favorite| -%>
<tr> <tr>
<td> <%= link_to favorite.job.name, jobs_detail_path(id: favorite.job.id) %> </td> <td> <%= link_to favorite.job.name, job_path(favorite.job.id) %> </td>
<td> <%= truncate(favorite.job.description, length: 250) %> </td> <td> <%= truncate(favorite.job.description, length: 250) %> </td>
<td> <%= favorite.job.city.try(:name) %> </td> <td> <%= favorite.job.city.try(:name) %> </td>
<td> <%= favorite.job.salary %> </td> <td> <%= favorite.job.salary %> </td>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<tbody> <tbody>
<%- @history_jobs.each do |history| -%> <%- @history_jobs.each do |history| -%>
<tr> <tr>
<td> <%= link_to history.job.name, jobs_detail_path(id: history.job.id) %> </td> <td> <%= link_to history.job.name, job_path(history.job.id) %> </td>
<td> <%= truncate(history.job.description, length: 250) %> </td> <td> <%= truncate(history.job.description, length: 250) %> </td>
<td> <%= history.job.city.try(:name) %> </td> <td> <%= history.job.city.try(:name) %> </td>
<td> <%= history.job.salary %> </td> <td> <%= history.job.salary %> </td>
......
<%- provide(:title, 'Job list') -%>
<div class="well">
<%= render 'layouts/search.html.erb' %>
</div>
<div class="well">
<div class="row">
<div class="col-md-2">
<h3>
Total: <%= @job_count %>
</h3>
</div>
<div class="col-md-6">
<h3>
Result for: <%= @search_conditions %>
</h3>
</div>
</div>
<%= paginate @jobs %>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Job</th>
<th>Description</th>
<th>Location</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<%- @jobs.each do |job| -%>
<tr>
<td> <%= link_to job.name, job_path(job.id) %> </td>
<td> <%= truncate(job.description, length: 250) %> </td>
<td> <%= job.city.try(:name) %> </td>
<td> <%= job.salary %> </td>
<td>
<%- if Favorite.where(user: current_user, job: job).blank? -%>
<div class="col-md-3">
<%- if user_signed_in? -%>
<%= link_to 'Favorite', '#', class: 'favorite_add' %>
<%- else -%>
<%= link_to 'Favorite', new_user_session_path %>
<%- end -%>
<input type="hidden" id="job_id" name="job_id" value="<%= job.id %>">
</div>
<%- end -%>
</td>
</tr>
<%- end -%>
</tbody>
</table>
</div>
<%= paginate @jobs %>
</div>
<%- provide(:title, 'Job list') -%> <%- provide(:title, 'Job Detail') -%>
<div class="well">
<%= render 'layouts/search.html.erb' %>
</div>
<div class="well"> <div class="well">
<h2><%= @job.name %></h2>
<div class="row form-group">
<div class="col-md-9 col-md-offset-1">
<div class="row">
Company:
<%= link_to @job.company.try(:name), company_path(@job.company.id) unless @job.company.nil? %>
</div>
<div class="row"> <div class="row">
Location:
<%= link_to @job.city.try(:name), city_path(@job.city.id) unless @job.city.nil? %>
</div>
<div class="row">
Salary:
<%= @job.salary %>
</div>
<div class="row">
Description:</br>
<%= @job.description %>
</div>
</div>
<div class="col-md-2"> <div class="col-md-2">
<h3>
Total: <%= @job_count %>
</h3>
</div>
<div class="col-md-6">
<h3>
Result for: <%= @search_conditions %>
</h3>
</div>
</div>
<%= paginate @jobs %>
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Job</th>
<th>Description</th>
<th>Location</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
<%- @jobs.each do |job| -%>
<tr>
<td> <%= link_to job.name, jobs_detail_path(id: job.id) %> </td>
<td> <%= truncate(job.description, length: 250) %> </td>
<td> <%= job.city.try(:name) %> </td>
<td> <%= job.salary %> </td>
<td>
<%- if Favorite.where(user: current_user, job: job).blank? -%>
<div class="col-md-3">
<%- if user_signed_in? -%> <%- if user_signed_in? -%>
<%= link_to 'Favorite', '#', class: 'favorite_add' %> <%- if Apply.where(user: current_user, job: @job).blank? -%>
<%= link_to 'Apply', jobs_apply_path(job_id: @job.id), class: 'btn btn-primary' %>
<%- else -%> <%- else -%>
<%= link_to 'Favorite', new_user_session_path %> <%= link_to 'Applied', '#', class: 'btn btn-primary' %>
<%- end -%> <%- end -%>
<input type="hidden" id="job_id" name="job_id" value="<%= job.id %>"> <%- else -%>
<%= link_to 'Apply', new_user_session_path, class: 'btn btn-primary' %>
<%- end -%>
</div>
</div> </div>
<div class="row">
<div class="col-md-offset-3 ">
<%- if user_signed_in? -%>
<%- if Apply.where(user: current_user, job: @job).blank? -%>
<%= link_to 'Apply', jobs_apply_path(job_id: @job.id), class: 'btn btn-primary' %>
<%- else -%>
<%= link_to 'Applied', '#', class: 'btn btn-primary' %>
<%- end -%> <%- end -%>
</td> <%- else -%>
</tr> <%= link_to 'Apply', new_user_session_path, class: 'btn btn-primary' %>
<%- end -%> <%- end -%>
</tbody>
</table>
</div>
<%= paginate @jobs %> <%- if user_signed_in? -%>
<%- if Favorite.where(user: current_user, job: @job).blank? -%>
<%= link_to 'Favorite', '#', class: 'favorite_add btn btn-primary' %>
<%- else -%>
<%= link_to 'Favorite', '#', class: 'favorite_add btn btn-primary', disabled: true %>
<%- end -%>
<%- else -%>
<%= link_to 'Favorite', new_user_session_path, class: 'btn btn-primary' %>
<%- end -%>
<input type="hidden" id="job_id" name="job_id" value="<%= @job.id %>">
</div>
</div>
</div> </div>
...@@ -2,12 +2,8 @@ Rails.application.routes.draw do ...@@ -2,12 +2,8 @@ Rails.application.routes.draw do
root 'static_pages#home' root 'static_pages#home'
get 'static_pages/home' get 'static_pages/home'
get '/cities', to: 'cities#show'
get '/categories', to: 'categories#show'
get 'jobs/applied_jobs', to: 'jobs#applied_jobs' get 'jobs/applied_jobs', to: 'jobs#applied_jobs'
get 'jobs/show/', to: 'jobs#show'
get 'jobs/detail/', to: 'jobs#detail'
get 'jobs/apply/', to: 'jobs#apply' get 'jobs/apply/', to: 'jobs#apply'
get 'jobs/confirm', to: 'jobs#confirm' get 'jobs/confirm', to: 'jobs#confirm'
post 'jobs/confirm', to: 'jobs#confirm' post 'jobs/confirm', to: 'jobs#confirm'
...@@ -17,8 +13,13 @@ Rails.application.routes.draw do ...@@ -17,8 +13,13 @@ Rails.application.routes.draw do
get 'jobs/favorite_remove', to: 'jobs#favorite_remove' get 'jobs/favorite_remove', to: 'jobs#favorite_remove'
get 'jobs/favorited_jobs', to: 'jobs#favorited_jobs' get 'jobs/favorited_jobs', to: 'jobs#favorited_jobs'
get 'jobs/history_jobs', to: 'jobs#history_jobs' get 'jobs/history_jobs', to: 'jobs#history_jobs'
resources :jobs, only: %i[index show]
resource :cities resources :cities, only: %i[index]
resources :cities, path: '/jobs/city', only: %i[show]
resources :categories, only: %i[index]
resources :categories, path: '/jobs/category', only: %i[show]
resources :companies, path: 'jobs/company', only: %i[show]
devise_scope :user do devise_scope :user do
post '/confirmations/update_confirm', to: 'confirmations#update_confirm' post '/confirmations/update_confirm', to: 'confirmations#update_confirm'
get '/registrations/show', to: 'registrations#show' get '/registrations/show', to: 'registrations#show'
......
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