Commit dd62ee75 by nnnghia98

jobs based on city/industry

parent 784cd563
class JobsController < ApplicationController class JobsController < ApplicationController
def index def index
@jobs = Job.page(params[:page]).per(Settings.job.per_page).decorate if params[:city_id]
redirect_to jobs_path if params[:city_id].blank?
@city_name = City.find(params[:city_id])
@jobs = @city_name.jobs
elsif params[:industry_id]
redirect_to jobs_path if params[:industry_id].blank?
@industry_name = Industry.find(params[:industry_id])
@jobs = @industry_name.jobs
else
@jobs = Job.all
end
@jobs = @jobs.page(params[:page]).per(Settings.job.per_page).decorate
end end
def show def show
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="job_data"> <div class="job_data">
<dl class="job_data_row"> <dl class="job_data_row">
<dt>Title</dt> <dt>Title</dt>
<dd><%= job.title %></dd> <dd><%= link_to job.title, jobs_path %></dd>
</dl> </dl>
<dl class="job_data_row"> <dl class="job_data_row">
<dt>Short description</dt> <dt>Short description</dt>
......
<h3>Total: <%= Job.count %></h3> <h3>Total: <%= @jobs.count %></h3>
<h3>Result for: </h3> <h3>Result for: </h3>
<%= paginate @jobs %> <%= paginate @jobs %>
......
<div class="breadcrump"> <div class="breadcrumb">
<%= link_to "Top", root_path %> > <%= link_to "Top", root_path %> >
<%= link_to "City", cities_path %> > <%= link_to "City", cities_path %> >
<%= link_to "Industry", industries_path %> > <%= link_to "Industry", industries_path %> >
......
...@@ -3,6 +3,8 @@ Rails.application.routes.draw do ...@@ -3,6 +3,8 @@ Rails.application.routes.draw do
resources :industries, only: :index resources :industries, only: :index
resources :cities, only: :index resources :cities, only: :index
resources :jobs, only: [:index, :show] resources :jobs, only: [:index, :show]
get "jobs/city/:city_id", to: "jobs#index", as: :city_jobs
get "jobs/industry/:industry_id", to: "jobs#index", as: :industry_jobs
devise_for :users devise_for :users
root "tops#index" root "tops#index"
namespace :users do namespace :users 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