Commit 64d312c3 by Xuan Trung Le

update handling exception rails

parent 8d0f1d38
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
helper_method :clear_session_candidate helper_method :clear_session_candidate
rescue_from ActiveRecord::RecordNotFound, :with => :error_not_found
def clear_session_candidate def clear_session_candidate
session[:candidate] = {} session[:candidate] = {}
...@@ -14,4 +15,8 @@ class ApplicationController < ActionController::Base ...@@ -14,4 +15,8 @@ class ApplicationController < ActionController::Base
super super
end end
end end
def error_not_found
render file: 'public/404.html'
end
end end
...@@ -54,14 +54,17 @@ ...@@ -54,14 +54,17 @@
</style> </style>
</head> </head>
<body class="rails-default-error-page"> <body class="rails-default-error-page content">
<!-- This file lives in public/404.html --> <!-- This file lives in public/404.html -->
<div class="dialog"> <div class="dialog">
<div> <div>
<h1>The page you were looking for doesn't exist.</h1> <h1>The page you were looking for doesn't exist.</h1>
<p>You may have mistyped the address or the page may have moved.</p> <p>You may have mistyped the address or the page may have moved.</p>
</div> </div>
<p>If you are the application owner check the logs for more information.</p> <p>Go back to the previous page after 5s</p>
</div> </div>
</body> </body>
<script type="text/javascript">
setTimeout(function(){history.back();}, 5000)
</script>
</html> </html>
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