Commit c43b1e6e by Ngo Trung Hung

create error page

parent 5a946728
......@@ -2,7 +2,7 @@ $(document).on("turbolinks:load", function(){
// => btn-favorite
$('.btn_favorite_outline').click(function (e) {
$(this).toggleClass('active');
$(this).toggleClass('active');
});
// => end
......
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
.box_content_404 {
width: 100vw;
height: 100vh;
z-index: 2000;
// height: 900px;
position: fixed;
top: 60px;
left: 0;
right: 0;
bottom: 0;
background-color: #fff;
}
.box_content_404_img {
margin: auto;
width: 700px
}
.img_404 {
width: 100%;
}
.box_content_404_text {
text-align: center;
span {
font-size: 30px;
font-weight: 800;
color: #99a6d5;
}
}
.box_content_404_back_to_home {
text-align: center;
a {
font-size: 22px;
color: #1a2c55;
&:hover {
text-decoration: none;
color: red;
}
}
}
\ No newline at end of file
// Place all the styles related to the Errors controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
......@@ -3,4 +3,10 @@ class ApplicationController < ActionController::Base
require 'open-uri'
include CrawlerHelper
def page_not_found
respond_to do |format|
format.html { render template: 'errors/not_found_error', layout: 'layouts/application', status: 404 }
format.all { render nothing: true, status: 404 }
end
end
end
class ErrorsController < ApplicationController
def file_not_found
render 'errors/file_not_found'
end
def unprocessable
end
def internal_server_error
end
end
......@@ -23,7 +23,7 @@ class JobController < ApplicationController
@industries = Industry.sort_asc.all
@cities = City.all
id_industry = Industry.find_by(name: params[:key_industry])
@fill_data = id_industry.jobs.page(params[:page]).per(20)
@fill_data = id_industry.jobs.page(params[:page])
render 'find_data'
end
......@@ -31,7 +31,7 @@ class JobController < ApplicationController
@industries = Industry.sort_asc.all
@cities = City.all
id_city = City.find_by(name: params[:key_city])
@fill_data = id_city.jobs.page(params[:page]).per(20)
@fill_data = id_city.jobs.page(params[:page])
render 'find_data'
end
......@@ -39,7 +39,7 @@ class JobController < ApplicationController
@industries = Industry.sort_asc.all
@cities = City.all
company = Company.find_by(name: params[:key_company])
@fill_data = company.jobs.page(params[:page]).per(20)
@fill_data = company.jobs.page(params[:page])
render 'find_data'
end
end
module ErrorsHelper
end
<div class="box_content_404">
<div class="container">
<div class="col-lg-12">
<div class="box_content_404_img">
<%= image_tag '404', class: "img_404"%>
</div>
</div><br>
<div class="col-lg-12">
<div class="box_content_404_text">
<span>Chúng tôi không tìm thấy trang bạn bạn yêu cầu!</span>
</div>
</div>
<div class="col-lg-12">
<div class="box_content_404_back_to_home">
<%= link_to 'Cùng mình quay lại trang chủ nhé', root_path %>
</div>
</div>
</div>
</div>
\ No newline at end of file
<div class="box_content_404">
<div class="container">
<div class="col-lg-12">
<div class="box_content_404_img">
<%= image_tag '500', class: "img_404"%>
</div>
</div><br>
<div class="col-lg-12">
<div class="box_content_404_text">
<span>Có vài lỗi trong đường dẫn này<br>
Đừng lo lắng! Xin lỗi bạn vì sự bất tiện trên
</span>
</div>
</div>
<div class="col-lg-12">
<div class="box_content_404_back_to_home">
<%= link_to 'Cùng mình quay lại trang chủ nhé', root_path %>
</div>
</div>
</div>
</div>
\ No newline at end of file
<div class="box_content_404">
<div class="container">
<div class="col-lg-12">
<div class="box_content_404_img">
<%= image_tag '422', class: "img_404"%>
</div>
</div><br>
<div class="col-lg-12">
<div class="box_content_404_text">
<span>Xin lỗi bạn<br>
Máy chủ của chúng tôi đang gặp sự cố!
</span>
</div>
</div>
<div class="col-lg-12">
<div class="box_content_404_back_to_home">
<%= link_to 'Cùng mình quay lại trang chủ nhé', root_path %>
</div>
</div>
</div>
</div>
\ No newline at end of file
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="aaa">
<% @fill_data.each do |data| %>
<div class="box_detail_jobs_ajax">
<div class="box_jobs">
<div class="col-sm-12 d-block d-sm-none">
<button type="submit" class="btn_favorite_outline xs">
......@@ -46,7 +46,7 @@
</div>
</div>
</div>
<%end%>
</div>
</div>
</div>
......
......@@ -18,20 +18,16 @@
<div class="breadcrumb_total_search_pagination_jobs">
<div class="pagination_jobs">
<div class="paginator">
<%= paginate @fill_data, remote: true %>
<%= paginate @fill_data %>
</div>
</div>
</div>
</div>
</div>
</div>
<%= render 'block_info_job' %>
<% @fill_data.each do |item| %>
<%= render 'block_info_job', data: item%>
<%end%>
<div class="container">
<div class="row">
<div class="col-lg-12">
......@@ -39,7 +35,7 @@
<div class="breadcrumb_total_search_pagination_jobs">
<div class="pagination_jobs">
<div class="paginator">
<%= paginate @fill_data, remote: true %>
<%= paginate @fill_data%>
</div>
</div>
</div>
......
$('body .aaa').html("<%= j render('block_info_job', data: @fill_data) %>");
$(".paginator").html("<%= j paginate(@fill_data, remote: true) %>");
\ No newline at end of file
......@@ -14,7 +14,6 @@
<div class="col-sm-10 col-md-9 col-lg-10">
<div class="box_info">
<div class="lol">
<!-- <%= image_tag 'trophy',class: 'img_job_name' %> -->
<%= link_to val.name, "/detail/#{val.id}" , class: 'job_name' %>
</div>
<div class="cop">
......@@ -53,14 +52,5 @@
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="load_all_jobs">
<%= link_to '>> Xem tất cả việc làm <<', '#', class: 'load_all_jobs_text'%>
</div>
</div>
</div>
</div>
......@@ -10,7 +10,8 @@ module HungntVenjob
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 5.2
#
config.exceptions_app = self.routes
# Settings in config/environments/* take precedence over those specified here.
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
......
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
......@@ -11,8 +10,8 @@ Rails.application.configure do
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
# 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.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
......
# frozen_string_literal: true
Kaminari.configure do |config|
# config.default_per_page = 20
config.default_per_page = 20
# config.max_per_page = nil
# config.window = 4
config.window = 2
# config.outer_window = 0
# config.left = 0
# config.right = 0
......
Rails.application.routes.draw do
root 'home#index'
match "/404", to: "errors#file_not_found", via: :all
match "/422", to: "errors#unprocessable", via: :all
match "/500", to: "errors#internal_server_error", via: :all
root 'home#index'
# match 'jobs', to: 'job#index', via: 'get'
match 'detail/:id', to: 'job#detail', via: 'get'
match 'jobs/city/(:key_city)', to: 'job#find_data_by_city', via: 'get', constraints: { key_city: /.*/}
match 'jobs/industry/(:key_industry)', to: 'job#find_data_by_industry', via: 'get', constraints: { key_industry: /.*/}
......
......@@ -76,3 +76,35 @@ Net::OpenTimeout: execution expired
/home/hungnt/.rbenv/versions/2.6.6/bin/bundle:23:in `<main>'
Tasks: TOP => crawler:populate
(See full trace by running task with --trace)
rake aborted!
ArgumentError: You should not use the `match` method in your router without specifying an HTTP method.
If you want to expose your action to both GET and POST, add `via: [:get, :post]` option.
If you want to expose your action to GET, use `get` in the router:
Instead of: match "controller#action"
Do: get "controller#action"
/home/hungnt/venjob/config/routes.rb:4:in `block in <main>'
/home/hungnt/venjob/config/routes.rb:1:in `<main>'
/home/hungnt/venjob/config/environment.rb:5:in `<main>'
/home/hungnt/.rbenv/versions/2.6.6/bin/bundle:23:in `load'
/home/hungnt/.rbenv/versions/2.6.6/bin/bundle:23:in `<main>'
Tasks: TOP => crawler:populate => environment
(See full trace by running task with --trace)
rake aborted!
NoMethodError: undefined method `rescue_from' for #<ActionDispatch::Routing::Mapper:0x000055ef745fa5a0>
Did you mean? rescue
/home/hungnt/venjob/config/routes.rb:6:in `block in <main>'
/home/hungnt/venjob/config/routes.rb:1:in `<main>'
/home/hungnt/venjob/config/environment.rb:5:in `<main>'
/home/hungnt/.rbenv/versions/2.6.6/bin/bundle:23:in `load'
/home/hungnt/.rbenv/versions/2.6.6/bin/bundle:23:in `<main>'
Tasks: TOP => crawler:populate => environment
(See full trace by running task with --trace)
rake aborted!
SyntaxError: /home/hungnt/venjob/config/routes.rb:6: syntax error, unexpected tIDENTIFIER, expecting end
...to: "errors#unprocessable'" via: :all
... ^~~
/home/hungnt/venjob/config/environment.rb:5:in `<main>'
/home/hungnt/.rbenv/versions/2.6.6/bin/bundle:23:in `load'
/home/hungnt/.rbenv/versions/2.6.6/bin/bundle:23:in `<main>'
Tasks: TOP => crawler:populate => environment
(See full trace by running task with --trace)
require 'test_helper'
class ErrorsControllerTest < ActionDispatch::IntegrationTest
test "should get file_not_found" do
get errors_file_not_found_url
assert_response :success
end
test "should get unprocessable" do
get errors_unprocessable_url
assert_response :success
end
test "should get internal_server_error" do
get errors_internal_server_error_url
assert_response :success
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