10
<p><%= f.input :terms, :as => :boolean, :label => false, :boolean_style => :inline %> 
Accept <%= link_to "Terms of use", terms_path,:remote => true %> 
and <%=link_to "privacy Policy", privacy_path, :remote => true%></p>

它最终看起来像这样

在此处输入图像描述

将它们排列在同一条线上的最佳方法是什么。

4

3 回答 3

23

这是一个相当简单的方法:

<%= content_for(:the_links) do %>
    Accept <%= link_to "Terms of use", terms_path,:remote => true %> 
    and <%=link_to "privacy Policy", privacy_path, :remote => true%>
<% end %>

<%= simple_form_for @user do |f| %>
  <%= f.input :email %>
  <%= f.input :password %>
  <%= f.input :terms, :as => :boolean, :label => content_for(:the_links)%> 
<% end%>

非样式输出

于 2012-10-24T17:11:20.817 回答
1

确保复选框和文本足够小以适合容器内的一行,然后设置display: inline;float:left;

于 2012-10-24T16:55:33.550 回答
0

尝试wrapper_html像这样使用:

<p>
  <%= f.input :terms, 
            :as => :boolean, 
            :label => false, 
            :boolean_style => :inline,     
            :wrapper_html => { :style => 'display: inline' } 
  %> 
  Accept <%= link_to "Terms of use", terms_path,:remote => true %> 
  and <%=link_to "privacy Policy", privacy_path, :remote => true%>
</p>
于 2012-10-24T16:56:10.063 回答