我有一个使用SimpleForm gem的Rails应用程序。当前的SimpleForm 3.0.0.rc版本使用Bootstrap 2.3提供了引人注目的表单样式。但是当我使用Bootstrap 3.0时,我失去了漂亮的表单样式。如何将SimpleForm与Bootstrap 3一起使用?
答案 0 :(得分:8)
https://github.com/plataformatec/simple_form/issues/857 - 这可能会有所帮助。
您需要更改简单表单初始值设定项。 Here是我在其中一个项目中使用的
UPD 2014年4月22日
答案 1 :(得分:8)
这个要点:
https://gist.github.com/tokenvolt/6599141
对我很有帮助!
编辑 - 将要点的当前内容粘贴到SO中,因为主持人评论不喜欢仅链接响应。但是,最好从要点中提取它。
非常感谢@Tokenvolt
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
]
inputs.each do |input_type|
superclass = "SimpleForm::Inputs::#{input_type}".constantize
new_class = Class.new(superclass) do
def input_html_classes
super.push('form-control')
end
end
Object.const_set(input_type, new_class)
end
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.boolean_style = :nested
config.wrappers :bootstrap3, tag: 'div', class: 'form-group', error_class: 'has-error',
defaults: { input_html: { class: 'default_class' } } do |b|
b.use :html5
b.use :min_max
b.use :maxlength
b.use :placeholder
b.optional :pattern
b.optional :readonly
b.use :label_input
b.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
b.use :error, wrap_with: { tag: 'span', class: 'help-block has-error' }
end
config.wrappers :prepend, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.wrapper tag: 'div', class: 'controls' do |input|
input.wrapper tag: 'div', class: 'input-group' do |prepend|
prepend.use :label , class: 'input-group-addon' ###Please note setting class here fro the label does not currently work (let me know if you know a workaround as this is the final hurdle)
prepend.use :input
end
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
input.use :error, wrap_with: { tag: 'span', class: 'help-block has-error' }
end
end
config.wrappers :append, tag: 'div', class: 'form-group', error_class: 'has-error' do |b|
b.use :html5
b.use :placeholder
b.wrapper tag: 'div', class: 'controls' do |input|
input.wrapper tag: 'div', class: 'input-group' do |prepend|
prepend.use :input
prepend.use :label , class: 'input-group-addon' ###Please note setting class here fro the label does not currently work (let me know if you know a workaround as this is the final hurdle)
end
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
input.use :error, wrap_with: { tag: 'span', class: 'help-block has-error' }
end
end
config.wrappers :checkbox, tag: :div, class: "checkbox", error_class: "has-error" do |b|
# Form extensions
b.use :html5
# Form components
b.wrapper tag: :label do |ba|
ba.use :input
ba.use :label_text
end
b.use :hint, wrap_with: { tag: :p, class: "help-block" }
b.use :error, wrap_with: { tag: :span, class: "help-block text-danger" }
end
# Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
# Check the Bootstrap docs (http://getbootstrap.com/)
# to learn about the different styles for forms and inputs,
# buttons and other elements.
config.default_wrapper = :bootstrap3
end
答案 2 :(得分:1)
为项目添加初始化程序以获取简单表单(config/initializers/simple_form.rb
)并输入此要点的内容:
https://gist.github.com/tommarshall/6308327/0141a600a93a1711d4762a04dd0d85a3ee14041e
我刚刚完成了这个,并且这个要点围绕着bootstraps新的布局/类名。
答案 3 :(得分:0)
您需要通过使用以下内容创建config / initializers / simple_form.rb来创建特定于bootstrap的simple_form设置:
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
config.wrappers :bootstrap, tag: 'div', class: 'form-group', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper tag: 'div', class: 'col-lg-6' do |ba|
ba.use :input
ba.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
ba.use :hint, wrap_with: { tag: 'p', class: 'help-block' }
end
end
# div class="form-group"
# label class="col-sm-3 control-label no-padding-right" for="form-field-1" Text Field
# div class="col-sm-9"
# input type="text" id="form-field-1" placeholder="Username" class="col-xs-10 col-sm-5"
# div class="space-4"
config.wrappers :prepend, tag: 'div', class: "form-group", error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper tag: 'div', class: 'col-lg-6' do |input|
input.wrapper tag: 'div', class: 'input-prepend' do |prepend|
prepend.use :input
end
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
end
end
config.wrappers :append, tag: 'div', class: "form-group", error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.wrapper tag: 'div', class: 'col-lg-6' do |input|
input.wrapper tag: 'div', class: 'input-append' do |append|
append.use :input
end
input.use :hint, wrap_with: { tag: 'span', class: 'help-block' }
input.use :error, wrap_with: { tag: 'span', class: 'help-inline' }
end
end
# Wrappers for forms and inputs using the Twitter Bootstrap toolkit.
# Check the Bootstrap docs (http://twitter.github.com/bootstrap)
# to learn about the different styles for forms and inputs,
# buttons and other elements.
config.default_wrapper = :bootstrap
end
答案 4 :(得分:0)
Active Admin实际上可能会引发如下错误:
ArgumentError - wrong number of arguments (6 for 4..5):
formtastic (2.3.0.rc3) lib/formtastic/helpers/input_helper.rb:241:in `input'
enumerize (0.8.0) lib/enumerize/hooks/formtastic.rb:23:in `input_with_enumerize'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/form_builder.rb:26:in `block in input'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/form_builder.rb:150:in `with_new_form_buffer'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/form_builder.rb:26:in `input'
app/admin/comment.rb:12:in `block (3 levels) in <top (required)>'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/form_builder.rb:142:in `block in field_set_and_list_wrapping'
actionview (4.1.1) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionview (4.1.1) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
haml (4.0.5) lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
actionview (4.1.1) lib/action_view/helpers/capture_helper.rb:38:in `capture'
haml (4.0.5) lib/haml/helpers/action_view_mods.rb:52:in `capture_with_haml'
formtastic (2.3.0.rc3) lib/formtastic/helpers/fieldset_wrapper.rb:32:in `field_set_and_list_wrapping'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/form_builder.rb:141:in `field_set_and_list_wrapping'
formtastic (2.3.0.rc3) lib/formtastic/helpers/inputs_helper.rb:297:in `inputs'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/form_builder.rb:20:in `block in inputs'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/form_builder.rb:150:in `with_new_form_buffer'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/form_builder.rb:20:in `inputs'
app/admin/comment.rb:9:in `block (2 levels) in <top (required)>'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/form.rb:23:in `block in main_content'
actionview (4.1.1) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionview (4.1.1) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
haml (4.0.5) lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
actionview (4.1.1) lib/action_view/helpers/capture_helper.rb:38:in `capture'
haml (4.0.5) lib/haml/helpers/action_view_mods.rb:52:in `capture_with_haml'
actionview (4.1.1) lib/action_view/helpers/form_helper.rb:434:in `form_for'
haml (4.0.5) lib/haml/helpers/action_view_mods.rb:139:in `form_for_with_haml'
haml (4.0.5) lib/haml/helpers/action_view_xss_mods.rb:28:in `form_for_with_haml_xss'
/usr/local/Cellar/rbenv/0.4.0/versions/2.1.1/lib/ruby/gems/2.1.0/gems/formtastic-2.3.0.rc3/lib/formtastic/helpers/form_helper.rb:174:in `block in semantic_form_for'
/usr/local/Cellar/rbenv/0.4.0/versions/2.1.1/lib/ruby/gems/2.1.0/gems/formtastic-2.3.0.rc3/lib/formtastic/helpers/form_helper.rb:197:in `with_custom_field_error_proc'
/usr/local/Cellar/rbenv/0.4.0/versions/2.1.1/lib/ruby/gems/2.1.0/gems/formtastic-2.3.0.rc3/lib/formtastic/helpers/form_helper.rb:173:in `semantic_form_for'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/view_helpers/form_helper.rb:9:in `active_admin_form_for'
arbre (1.0.1) lib/arbre/element.rb:175:in `method_missing'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/form.rb:22:in `main_content'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/base.rb:83:in `block (2 levels) in build_main_content_wrapper'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/base.rb:82:in `block in build_main_content_wrapper'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/base.rb:81:in `build_main_content_wrapper'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/base.rb:65:in `block in build_page_content'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/base.rb:64:in `build_page_content'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/base.rb:47:in `block (2 levels) in build_page'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/base.rb:44:in `block in build_page'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/base.rb:43:in `build_page'
() usr/local/opt/rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/lib/active_admin/views/pages/base.rb:10:in `build'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
/usr/local/Cellar/rbenv/0.4.0/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/app/views/active_admin/resource/edit.html.arb:1:in `block in __usr_local__ellar_rbenv_______versions_______lib_ruby_gems_______bundler_gems_active_admin_ad__a_f_c____app_views_active_admin_resource_edit_html_arb___673488922967484373_70297770858860'
arbre (1.0.1) lib/arbre/context.rb:45:in `initialize'
/usr/local/Cellar/rbenv/0.4.0/versions/2.1.1/lib/ruby/gems/2.1.0/bundler/gems/active_admin-ad33a0f6c772/app/views/active_admin/resource/edit.html.arb:1:in `__usr_local__ellar_rbenv_______versions_______lib_ruby_gems_______bundler_gems_active_admin_ad__a_f_c____app_views_active_admin_resource_edit_html_arb___673488922967484373_70297770858860'
actionview (4.1.1) lib/action_view/template.rb:145:in `block in render'
activesupport (4.1.1) lib/active_support/notifications.rb:161:in `instrument'
actionview (4.1.1) lib/action_view/template.rb:339:in `instrument'
actionview (4.1.1) lib/action_view/template.rb:143:in `render'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
actionview (4.1.1) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionview (4.1.1) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
actionview (4.1.1) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionview (4.1.1) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.1.1) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.1.1) lib/action_view/rendering.rb:99:in `_render_template'
actionpack (4.1.1) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.1.1) lib/action_view/rendering.rb:82:in `render_to_body'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.1.1) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
actionpack (4.1.1) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.1.1) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/usr/local/opt/rbenv/versions/2.1.1/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
activesupport (4.1.1) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.1.1) lib/action_controller/metal/responder.rb:238:in `default_render'
actionpack (4.1.1) lib/action_controller/metal/responder.rb:165:in `to_html'
responders (1.0.0) lib/responders/flash_responder.rb:104:in `to_html'
actionpack (4.1.1) lib/action_controller/metal/responder.rb:158:in `respond'
actionpack (4.1.1) lib/action_controller/metal/responder.rb:151:in `call'
actionpack (4.1.1) lib/action_controller/metal/mime_responds.rb:400:in `respond_with'
/usr/local/Cellar/rbenv/0.4.0/versions/2.1.1/lib/ruby/gems/2.1.0/gems/inherited_resources-1.4.1/lib/inherited_resources/actions.rb:25:in `edit'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.1) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
dragonfly (1.0.4) lib/dragonfly/middleware.rb:14:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.1) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
airbrake (3.1.16) lib/airbrake/rails/middleware.rb:13:in `call'
better_errors (1.1.0) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (1.1.0) lib/better_errors/middleware.rb:56:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
dragonfly (1.0.4) lib/dragonfly/cookie_monster.rb:9:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
airbrake (3.1.16) lib/airbrake/user_informer.rb:16:in `_call'
airbrake (3.1.16) lib/airbrake/user_informer.rb:12:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/usr/local/opt/rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/usr/local/opt/rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/usr/local/opt/rbenv/versions/2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
如果您遇到此问题,可以在初始化程序中使用它:
inputs = %w[
CollectionSelectInput
DateTimeInput
FileInput
GroupedCollectionSelectInput
NumericInput
PasswordInput
RangeInput
StringInput
TextInput
]
inputs.each do |input_type|
"SimpleForm::Inputs::#{input_type}".constantize.class_eval do
alias_method :__input_html_classes, :input_html_classes
define_method(:input_html_classes) do
__input_html_classes.push('form-control')
end
end
end