【发布时间】:2017-12-29 09:20:00
【问题描述】:
我无法将 bootstrap sass 加载到 users/new.html.erb 中的表单 在清单 7.15 / 7.16 中的 railstutorial.org 中,它看起来像这样:1`1
我的仓库: https://github.com/xt442/railstutorialorg
感谢您的帮助!
【问题讨论】:
标签: ruby-on-rails twitter-bootstrap sass
我无法将 bootstrap sass 加载到 users/new.html.erb 中的表单 在清单 7.15 / 7.16 中的 railstutorial.org 中,它看起来像这样:1`1
我的仓库: https://github.com/xt442/railstutorialorg
感谢您的帮助!
【问题讨论】:
标签: ruby-on-rails twitter-bootstrap sass
你必须 wrap 和 label & text field 与类 form-group 的 div。
& 按钮跨越父元素的整个宽度使用类btn-block
类似关注
<%= form_for(@user) do |f| %>
<%= content_tag :div, class: 'form-group' do %>
<%= f.label :name %>
<%= f.text_field :name, class: 'form-control' %>
<% end %>
<%= content_tag :div, class: 'form-group' do %>
<%= f.label :email %>
<%= f.email_field :email, class: 'form-control' %>
<% end %>
<%= content_tag :div, class: 'form-group' do %>
<%= f.label :password %>
<%= f.password_field :password, class: 'form-control' %>
<% end %>
<%= content_tag :div, class: 'form-group' do %>
<%= f.label :password_confirmation, "Confirmation" %>
<%= f.password_field :password_confirmation, class: 'form-control' %>
<% end %>
<%= f.submit "Create my account", class: "btn btn-primary btn-block" %>
<% end %>
【讨论】:
不知道它是否可以修复,但我注意到您错过了部分参数:
<%= render partial:'layouts/header' %>
和
<%= render partial:'layouts/footer' %>
应该可以的
【讨论】: