如何使用Rails best_in_place使文本框更宽?

时间:2013-12-20 20:40:12

标签: ruby-on-rails ruby-on-rails-4

我尝试过以下操作:

<%= current_user.first_name %>
<%= current_user.last_name %>
<span class="bubble">
  <%= best_in_place current_user,
        :blurb,
        type: :textarea,
        :cols => "30",
        :rows => "50",
        :inner_class => 'occupation-edit',
        nil: 'Add a short blurb (max 140)'
  %>
</span>

但是,这不起作用。是否可以将文本区域设置为垂直长度?看起来它不能用'best_in_place'宝石定制。

1 个答案:

答案 0 :(得分:6)

使用html_attrs,您可以设置这些类型的参数,如下所示:

<%= best_in_place current_user,
      :blurb,
      :type => :textarea,
      :html_attrs => { :cols => '30', :rows => '50' }
%>

如果rowscols属性不起作用,您可能需要尝试style属性,如下所示:

<%= best_in_place current_user,
      :blurb,
      :type => :textarea,
      :html_attrs => { :style => 'width:500px; height:500px;' }
%>