2014-02-21 75 views
0

所以,我已經爲404頁面定製了設計 - 但是,我在實現它時遇到了問題。實現自定義404錯誤頁面

我很快就瞭解到,您必須將CSS直接嵌入到HTML中 - 其次,它看起來不像我可以使用html.erb或嵌入式ruby換句話說。這就是說,對我來說,在我的404.html頁面上實現以下設計代碼的最佳方式是什麼?

<!DOCTYPE html> 
<html lang="en"><head> 
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"> 
    <meta name="description" content=""> 
    <meta name="author" content=""> 
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300,700' rel='stylesheet' type='text/css'> 
    <title>New Error Design</title> 

    <!-- Bootstrap core CSS --> 
    <link href="css/bootstrap.css" rel="stylesheet"> 
    <!-- Custom styles for this template --> 
    <link href="css/mystyle.css" rel="stylesheet"> 
    <link href="css/mediaquery.css" rel="stylesheet"> 

    <link rel="stylesheet" href="css/selectify.css" /> 
</head> 

<body> 
    <header class="navbar navbar-inverse"> 
     <div class="container"> 
     <div class="row"> 
     <div class="col-md-3 logo"> 
      <a href="index.html"><img src="images/logo.png" alt="logo"></a> 
     </div> 



     <div class="col-md-3 pull-right"> 
      <a href="sign-in.html"><button type="button" class="btn btn-info sign-i-u">Sign IN</button></a> 
      <a href="sign-up.html"><button type="button" class="btn btn-info sign-i-u">Sign Up</button></a> 
     </div> 

     </div> 
     </div> 
    </header> 

    <div class="container"> 
     <div class="row"> 
     <div class="col-md-12 error_text"> 
      <h1> Sorry, the page you requested is not found</h1> 

      <div class="col-md-12"> 
       <div class="col-md-6 col-md-offset-3 text-center"> 
       <%= link_to 'sign Up', new_user_registration_path, class: "btn btn-primary buttons_style" %> 
       <%= link_to 'Login', new_user_session_path, class: "btn btn-primary buttons_style" %> 
       <%= link_to 'Return To Home', root_path, class: "btn btn-primary buttons_style" %> 
       </div> 
      </div> 

     </div> 
     </div> 
    </div> 


    <footer> 
     <div class="container"> 
     <p class="f-logo"><a href="index.html"><img src="images/footer_logo.png" alt="logo-image"></a></p> 
     <p class="links"> 
     <a href="#">Blog</a> 
     <a href="#">About</a> 
     <a href="#">Privacy</a> 
     <a href="#">Terms</a> 
     <a href="#">Copyright</a> 
     </p> 
     <p class="copy">2014 © Company name. All Rights Reserved</p> 
     </div> 
    </footer> 
</body> 
</html> 

回答

1

雖然這將主要依據的意見,這裏是如何我已經做到了......

我希望有,我可以用它來生成一個404頁面的HTML Rails的模板,然後只需將該頁保存在應用程序的public/文件夾中即可。這樣,當應用發生變化時,我可以快速訪問路由以生成404頁面,然後將HTML保存到public/目錄。

確保您設置您的應用程序以使用自定義頁面。 Rambling Labs has a good example如何做到這一點。