fix logic favorite job

parent 44262ce9
Pipeline #1077 failed with stages
in 0 seconds
.error-banner-ground{
position: relative;
width: 100%;
height: 100vh;
}
.error-500-banner {
background-image: url('500errorpage.jpg');
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-size: cover;
}
.error-404-banner {
background-image: url('404errorpage.jpg');
width: 100%;
height: 100%;
background-repeat: no-repeat;
background-size: cover;
}
class ErrorsController < ApplicationController
def error_404
end
def error_500
end
end
......@@ -8,6 +8,7 @@ class FavoriteJobsController < ApplicationController
@count = current_user.favorite_jobs.count
@favorited_jobs = current_user.favorite_jobs.order_favorite.page(page).per(Job::LIMIT_PAGE)
return redirect_to error_404_path if @favorited_jobs.blank?
end
def create
......@@ -24,8 +25,10 @@ class FavoriteJobsController < ApplicationController
current_page_count = @count % Job::LIMIT_PAGE
remain_page = @count / Job::LIMIT_PAGE
return redirect_to favorite_jobs_path(page: remain_page) if current_page_count == Job::DIVISIBLE && params[:page] == remain_page + 1
return redirect_to favorite_jobs_path(page: remain_page) if current_page_count == Job::DIVISIBLE
if current_page_count == Job::DIVISIBLE
return redirect_to favorite_jobs_path(page: remain_page) if params[:page].to_i == remain_page + 1
redirect_to favorite_jobs_path(page: params[:page])
end
end
respond_to { |format| format.js }
......
......@@ -22,6 +22,7 @@ class JobAppliedsController < ApplicationController
def show
@users = current_user.job_applieds.order("job_applieds.updated_at DESC").page(params[:page]).per(Job::LIMIT_PAGE)
redirect_to error_404_path if @users.blank?
end
def confirmation
......
......@@ -4,23 +4,27 @@ class JobsController < ApplicationController
def index
@jobs_list = Job.all.page(params[:page]).per(Job::LIMIT_PAGE)
return redirect_to error_404_path if @jobs_list.blank?
end
def city_jobs
@city = City.find_by(converted_name: params[:converted_name])
@jobs_list = @city.jobs.page(params[:page]).per(Job::LIMIT_PAGE)
return redirect_to error_404_path if @jobs_list.blank?
@result_for_job = @city.jobs.count
end
def industry_jobs
@industry = Industry.find_by(converted_name: params[:converted_name])
@jobs_list = @industry.jobs.page(params[:page]).per(Job::LIMIT_PAGE)
return redirect_to error_404_path if @jobs_list.blank?
@result_for_job = @industry.jobs.count
end
def company_jobs
@company = Company.find_by(converted_name: params[:converted_name])
@jobs_list = @company.jobs.page(params[:page]).per(Job::LIMIT_PAGE)
return redirect_to error_404_path if @jobs_list.blank?
@result_for_job = @company.jobs.count
redirect_to jobs_path unless @company
......
<div class="container">
<div class="error-banner-ground">
<div class="error-404-banner">
</div>
</div>
</div>
<div class="container">
<div class="error-banner-ground">
<div class="error-500-banner">
</div>
</div>
</div>
......@@ -21,7 +21,7 @@
<div class="salary col-3">
Salary: <%= favorite_job.job.salary %>
</div>
<%= link_to "Remove", unfavorite_job_path(job_id: favorite_job.job.id, page: params[:page]), method: :delete, remote: true, class: "btn btn-danger", id: "button-remove" %>
<%= link_to "Remove", unfavorite_job_path(job_id: favorite_job.job.id, page: params[:page] || "1"), method: :delete, remote: true, class: "btn btn-danger", id: "button-remove" %>
</div>
</div>
</div>
......
<div class="container">
<%= render 'layouts/flash' %>
<% if @favorited_jobs.count > 0 %>
<% if @count > 0 %>
<h1 class="text-center my-job-label">Favorite Job (<span class="count-favorite-jobs"><%= @count %></span> jobs)</h1>
<%= paginate @favorited_jobs, outer_window: 2, window: 1 %>
<div class="favorite-page">
......
<div class="container">
<% if @history_jobs.count > 0 %>
<% if @count > 0 %>
<h1 class="text-center my-job-label">History(<span class="count-histories-jobs"><%= @count %></span> jobs)</h1>
<div class="history-page">
<%= form_tag apply_job_path(job_id: params[:job_id]), method: :get, enforce_utf8: false do %>
......
......@@ -10,6 +10,7 @@ module Venjob
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
config.exceptions_app = self.routes
config.before_configuration do
env_file = File.join(Rails.root, 'config', 'local_env.yml')
YAML.load(File.open(env_file)).each do |key, value|
......
......@@ -10,7 +10,7 @@ Rails.application.configure do
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
config.consider_all_requests_local = false
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
......
......@@ -48,6 +48,12 @@ Rails.application.routes.draw do
resources :industries, only: [:index]
resources :cities, only: [:index]
root to: "top_pages#index"
get 'error_404', to: 'errors#error_404', as: :error_404
get 'error_500', to: 'errors#error_500', as: :error_500
match '/404', via: :all, to: 'errors#error_404'
match '/500', via: :all, to: 'errors#error_500'
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