Simple_form& Twitter Bootstrap:表单标签未对齐,生产中缺少HTML?

时间:2012-03-07 13:31:15

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-3.1 simple-form

当我投入生产时,我的表单会发生变化,导致标签和字段彼此不对齐。在开发过程中,它可以正常工作,但不能在生产中使用。

这就是我的意思:

Development
<div class="control-group string required">
    <div class="control-label">
        <label for="store_business_name" class="string required">
            <abbr title="required">
                *
            </abbr> Business
        </label>
    </div>
    <div class="controls">
        <input type="text" size="50" name="store[business_name]" id="store_business_name" class="string required span3">
        <p class="help-block">
            The Business the store will belong to
        </p>
    </div>
</div>

Production
<div class="control-group string required">
    <label for="store_business_name" class="string required">
        <abbr title="required">
            *
        </abbr> Business
    </label>
    <div class="controls">
        <input type="text" size="50" name="store[business_name]" id="store_business_name" class="string required span3">
        <p class="help-block">
            The Business the store will belong to
        </p>
    </div>
</div>

仔细观察,<div class="control-label">在生产中消失。我没有使用任何类型的bootstrap gem(依赖于我无法安装的gems)。这是一个已知的问题,这是如何解决的?


<%= simple_form_for(@store, :html => { :class => 'form-horizontal' }) do |f| %>
    <%= render :partial => "shared/error_message", :locals => { :f => f } %>
    <div class="span12">
        <%= f.input :business_name, :label => 'Business', :input_html => { :class => "span3" }, :hint => "The Business the store will belong to" %>
        <%= f.input :online_store, :label => 'Online Store', :as => :boolean %>
        <%= f.input :address, :input_html => { :class => "span3" }, :placeholder => "451 University Avenue, Palo Alto, CA 94301", :hint => "For offline store" %>
        <%= f.input :website, :input_html => { :class => "span3" }, :placeholder => "www.somewebsite.com", :hint => "For online store" %>
        <%= f.input :phone_number, :input_html => { :class => "span3" }, :placeholder => "(650) 798-2800" %>
        <div class="form-actions">
            <%= f.button :submit, "Done", :class => 'btn btn-primary span2' %>
        </div>
    </div>
<% end %>

1 个答案:

答案 0 :(得分:1)

您使用的是什么版本的Simple_form?你是如何整合bootstrap的?

假设您使用了simple_form的wiki与twitter / bootstrap集成,请验证:

  1. lib / simple_form / contained_input_component.rb正在加载并按原样实现
  2. config / initializers / simple_form.rb正在调用上面的库
  3. config / initializers和config / production
  4. 中只有一个simple_form.rb

    如果以上所有内容都已订购,请使用您的观看代码更新问题。