如何美化 Rails 中的验证 [英] how to beautify validations in rails
问题描述
我有一个简单的脚手架 rails 应用程序,它正在执行validataes_presence_of.
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 be displayed on top.
如何对验证进行这些类型的更改或颜色更改
How can I make these type of changes or color changes to the validation
推荐答案
Rails 应用程序存储它们的 CSS 在 [application_root]/public/stylesheets
中.一个新的 rails 应用程序将在此目录中有一个名为 default.css
的文件.该文件包含以下内容:
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;
}
如果您在这里尝试使用一些参数的值 - 特别是 border
- 您可能会发现一些看起来更合您口味的东西.
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.
这篇关于如何美化 Rails 中的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!