小编dan*_*bez的帖子

如何使用Simple Form和Bootstrap在与输入相同的行上定位提交按钮?

使用Simple Form和Bootstrap,我希望以下内容显示为内联而不是输入选择下方的提交按钮.

<%= simple_form_for :select_rollout, :html => {:class => "form-inline"}, do |f| %>
  <%= f.input :rollout_id, collection: @rollout_options, :label => false %>
  <%= f.button :submit, "Apply" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)

以下解决方案仅适用于输入(提交按钮呈现在输入的div之外):

<%= form.input :city, label: 'City/State/Zip', input_html: {class: 'span3'}, wrapper_html: {class: 'controls controls-row'} do %>
  <%= form.input_field :city, class: 'span1' %>
  <%= form.input_field :state, class: 'span1' %>
<% end %>
Run Code Online (Sandbox Code Playgroud)

simple-form twitter-bootstrap

5
推荐指数
1
解决办法
2573
查看次数

如何设置simple_form时间输入的默认时间

我有以下simple_form输入(HAML):

= congress_detail_form.input :stand_setup_time, as: :time
Run Code Online (Sandbox Code Playgroud)

as :: time部分可能是冗余的,因为数据库列类型是TIME,我认为simple_form检测到.

它默认为当前时间(它显示两个选择,一个用于小时,另一个用于分钟).我无法使用默认值设置默认值00:00或值:.这甚至可能吗?

我一直无法找到simple_form代码库中的默认设置.任何帮助,将不胜感激.

我还发现没有与simple_form一起使用的timepicker.

ruby-on-rails-3 simple-form

5
推荐指数
1
解决办法
2561
查看次数

simple-form association为nil提供了"未定义的方法`klass":NilClass"错误

在我的Rails 3应用程序中,我有以下简单的关系结构:

class Rollout < ActiveRecord::Base
    has_many :items, :through => :rollout_items
end

class RolloutItem < ActiveRecord::Base
    belongs_to :rollout
    belongs_to :item
end

class Item < ActiveRecord::Base
    has_many :rollouts, :through => :rollout_items
end
Run Code Online (Sandbox Code Playgroud)

控制器:

def new
    @rollout = Rollout.new
end
Run Code Online (Sandbox Code Playgroud)

我使用以下表单得到上述错误:

<%= simple_form_for @rollout do |f| %>
    <%= f.association :items %>
<% end %>
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails-3 simple-form

4
推荐指数
1
解决办法
3229
查看次数