0

當我投入生產時,我的形式發生變化,導致標籤和字段彼此未對齊。在開發中它可以正常工作,但不能用於生產。Simple_form&Twitter Bootstrap:表單標籤未對齊,生產中缺少HTML?

這裏是我的意思是:

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">消失生產。我沒有使用任何類型的引導寶石(取決於我無法安裝的寶石)。這是一個已知的問題,這是如何解決的?


<%= 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 %> 
+0

您可以通過生成此輸出的視圖嗎?你確定你的代碼在env中是一樣的嗎? – shingara 2012-03-07 14:26:15

回答

1

您正在使用什麼版本Simple_form的?你是如何整合自舉的?

假設你使用simple_form的維基與Twitter /引導整合,那麼請驗證:

  1. 的lib/simple_form/contained_input_component.rb被加載並實現,是
  2. 配置/初始化/ simple_form。 RB是在調用上述庫
  3. 僅存在一個在配​​置/初始化和配置/生產

simple_form.rb如果所有的上面是在或請使用您的查看代碼更新問題。

+0

這是一個與寶石問題。我正在使用2.0.0.rc.我升級到2.0.1,現在一切都很好。謝謝你的關心。 – LearningRoR 2012-03-07 16:36:46

+1

@Railslearner:不用擔心,在附註中 - 總是在集成任何新gem並在Gemfile中顯式定義gem版本時檢查最新的穩定版本。出血邊緣是家庭實驗,祕密實驗室和錯誤測試者:P – 2012-03-07 16:44:02