how to beautify validations in rails

后端 未结 3 2057
长情又很酷
长情又很酷 2021-02-11 09:19

I have a simple scaffold rails application that is doing validataes_presence_of.

The validation is making each textfield bordered. I just want the error messages to b

3条回答
  •  失恋的感觉
    2021-02-11 09:56

    Rails applications store their CSS in [application_root]/public/stylesheets. A new rails app will have a file called default.css in this directory. This file contains the following:

    #errorExplanation {
      width: 400px;
      border: 2px solid red;
      padding: 7px;
      padding-bottom: 12px;
      margin-bottom: 20px;
      background-color: #f0f0f0;
    }
    
    #errorExplanation h2 {
      text-align: left;
      font-weight: bold;
      padding: 5px 5px 5px 15px;
      font-size: 12px;
      margin: -7px;
      background-color: #c00;
      color: #fff;
    }
    
    #errorExplanation p {
      color: #333;
      margin-bottom: 0;
      padding: 5px;
    }
    
    #errorExplanation ul li {
      font-size: 12px;
      list-style: square;
    }
    

    If you play about with the values of some of the parameters here - in particular border - you might find something that looks more to your taste.

提交回复
热议问题