connect link for industry and city

parent e3119670
...@@ -5,6 +5,7 @@ class JobsController < ApplicationController ...@@ -5,6 +5,7 @@ class JobsController < ApplicationController
@total_job = Job.count @total_job = Job.count
@jobs_list = Job.all_job.page(params[:page]).per(20) @jobs_list = Job.all_job.page(params[:page]).per(20)
end end
def city_jobs def city_jobs
@cities = City.all @cities = City.all
@industries = Industry.all @industries = Industry.all
...@@ -13,4 +14,13 @@ class JobsController < ApplicationController ...@@ -13,4 +14,13 @@ class JobsController < ApplicationController
@total_job = Job.count @total_job = Job.count
@result_for_job = @city.jobs.count @result_for_job = @city.jobs.count
end end
def industry_jobs
@cities = City.all
@industries = Industry.all
@industry = Industry.find(params[:id])
@jobs_list = @industry.jobs.all_job.page(params[:page]).per(20)
@total_job = Job.count
@result_for_job = @industry.jobs.count
end
end end
<div class="col-3 remove-decoration"> <div class="col-3 remove-decoration">
<%= link_to '#' do %> <%= link_to city_jobs_path(city.id) do %>
<div class="border border-dark rounded international-name"> <div class="border border-dark rounded international-name">
<div> <div>
<strong><%= city.name %></strong> <strong><%= city.name %></strong>
......
<div class="col-3 remove-decoration"> <div class="col-3 remove-decoration">
<%= link_to '#' do %> <%= link_to industry_jobs_path(industry.id) do %>
<div class="border border-dark rounded industry-details"> <div class="border border-dark rounded industry-details">
<div> <div>
<strong><%= industry.name %></strong> <strong><%= industry.name %></strong>
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
<div class="job-details"> <div class="job-details">
<div class="title"><strong><%= job.title %></strong></div> <div class="title"><strong><%= job.title %></strong></div>
<div class="row"> <div class="row">
<div class="col-4"> <div class="col-6">
<% job.cities.each do |city| %> <% job.cities.each do |city| %>
<%= city.name %> <%= city.name %>
<% end %> <% end %>
</div> </div>
<div class="col-4 salary">Salary: <%= job.salary %></div> <div class="col-4 salary">💲 Salary: <%= job.salary %></div>
<div class="col-10 introduction"> <div class="col-10 introduction">
<%= job_description(job.description) %><br> <%= job_description(job.description) %><br>
<%= link_to 'Read more..', '#'%> <%= link_to 'Read more..', '#'%>
......
<% provide(:title, 'Jobs') %> <% provide(:title, 'City Jobs') %>
<div class="container"> <div class="container">
<div class="search-bar"> <div class="search-bar">
<%= render 'layouts/search_bar' %> <%= render 'layouts/search_bar' %>
......
<% provide(:title, 'Industry Jobs') %>
<div class="container">
<div class="search-bar">
<%= render 'layouts/search_bar' %>
</div>
<div class="row total-jobs">
<div class="col-4">Total: <%= @total_job %> jobs</div>
<div class="col-4">Result for: <%= @result_for_job %> jobs</div>
</div>
<%= render "jobs/pagination" %>
<div class="job-list">
<%= render partial: "all_jobs", collection: @jobs_list, as: :job %>
</div>
<%= render "jobs/pagination" %>
</div>
<div class="col-4"> <div class="col-4">
<div class="row-table border border-dark rounded city-list"> <div class="row-table border border-dark rounded city-list">
<%= link_to "#{city_jobs_path}/cities/#{city.id}" do %> <%= link_to city_jobs_path(city.id) do %>
<div class="city-name"><strong><%= city.name %></strong></div> <div class="city-name"><strong><%= city.name %></strong></div>
<div class="count-job"><%= city.jobs.count %></div> <div class="count-job"><%= city.jobs.count %></div>
<% end %> <% end %>
......
<div class="col-4"> <div class="col-4">
<div class="row-table border border-dark rounded industry-list"> <div class="row-table border border-dark rounded industry-list">
<%= link_to '#' do %> <%= link_to industry_jobs_path(industry.id) do %>
<div class="industry-name"><strong><%= industry.name %></strong></div> <div class="industry-name"><strong><%= industry.name %></strong></div>
<div class="count-job"><%= industry.jobs.count %></div> <div class="count-job"><%= industry.jobs.count %></div>
<% end %> <% end %>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="job-details"> <div class="job-details">
<div class="title"><strong><%= job.title %></strong></div> <div class="title"><strong><%= job.title %></strong></div>
<div><%= job.company_name %></div> <div><%= job.company_name %></div>
<div class="salary">Salary: <%= job.salary %></div> <div class="salary">💲 Salary: <%= job.salary %></div>
<div> <div>
<% job.cities.each do |city| %> <% job.cities.each do |city| %>
<%= city.name %> <%= city.name %>
......
Rails.application.routes.draw do Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :jobs resources :jobs
get 'jobs/cities/:id', to: 'jobs#city_jobs' get 'jobs/cities/:id', to: 'jobs#city_jobs', as: :city_jobs
get 'jobs/industries/:id', to: 'jobs#industry_jobs', as: :industry_jobs
resources :top_pages resources :top_pages
resources :industries resources :industries
......
...@@ -9,9 +9,9 @@ namespace :import do ...@@ -9,9 +9,9 @@ namespace :import do
end end
desc 'Crontab' desc 'Crontab'
task auto: :environment do task auto: :environment do
crontab = JobParser.new(logger, url) parser = JobParser.new(logger, url)
csv_importer = CSVImporter.new(logger) csv_importer = CSVImporter.new(logger)
crontab.crawl_all parser.crawl_all
csv_importer.import csv_importer.import
end end
......
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