我正在关注 http://www.railstutorial.org/book/_single-page 的 Rails 4.0.0 教程.
我检查了所有内容以匹配教程,但似乎无法找到问题。
我的 gem 文件:
gem 'rails', '4.0.0'
gem 'bootstrap-sass', '2.3.2.0'
所有 Bootstrap 似乎都有效,但错误的 @extend 似乎不起作用。我知道 bootstrap 2 和 3 之间存在差异。因此我严格按照这部分的教程进行操作:)
我的custom.css.scss
#error_explanation {
color:#f00;
ul {
list-style: none;
margin: 0 0 18px 0;
}
}
.field_with_errors {
@extend .control-group;
@extend .error;
}
生成的 HTML:
<...>
<div id="error_explanation">
<div class="alert alert-error">
The form contains 5 errors.
</div>
<ul>
<li>* Name can't be blank</li>
<li>* Email can't be blank</li>
<li>* Email is invalid</li>
<li>* Password can't be blank</li>
<li>* Password is too short (minimum is 6 characters)</li>
</ul>
</div>
<div class="field_with_errors"><label for="user_name">Name</label></div>
<div class="field_with_errors"><input id="user_name" name="user[name]" type="text" value="" /></div>
<div class="field_with_errors"><label for="user_email">Email</label></div>
<div class="field_with_errors"><input id="user_email" name="user[email]" type="text" value="" /></div>
<div class="field_with_errors"><label for="user_password">Password</label></div>
<div class="field_with_errors"><input id="user_password" name="user[password]" type="password" /></div>
<...>
最佳答案
我真是个傻子。当我开始这个元素时,我用脚手架生成了一些东西。完全忘记了。
如果您想摆脱脚手架,请按照说明操作:Getting rid of scaffold.css in rails
关于css - bootstrap-sass 2.3.2 与 Rails 4.0.0 : issue @extend . 控制组; &@extend.error;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23629360/