ActionView :: Template :: Error(错误的参数数量(6 for 4..5))with rails,active admin和simple form

时间:2015-10-03 15:26:43

标签: ruby-on-rails-3.2 activeadmin simple-form formtastic

我有一个带有rails4,activeadmin和simpleform的应用程序。我已经改变了我的simple_form.rb配置。从那时起,当我访问localhost:3000 / admin / login时,我得到:

ActionView::Template::Error (wrong number of arguments (6 for 4..5)):
    5:   <%= active_admin_form_for(resource, :as => resource_name, :url => send(:"#{scope}_session_path"), :html => { :id => "session_new" }) do |f|
    6:     f.inputs do
    7:       resource.class.authentication_keys.each { |key| f.input key, :input_html => {:autofocus => true}}
    8:       f.input :password
    9:       f.input :remember_me, :label => t('active_admin.devise.login.remember_me'), :as => :boolean, :if =>  false  #devise_mapping.rememberable? }
    10:     end
    11:     f.actions do
  simple_form (2.1.0) lib/simple_form/inputs/base.rb:50:in `initialize'
  formtastic (2.2.1) lib/formtastic/helpers/input_helper.rb:240:in `new'
  formtastic (2.2.1) lib/formtastic/helpers/input_helper.rb:240:in `input'
...

Gemfile.lock的:

...
rails (3.2.13)
activeadmin (0.6.0)
formtastic (2.2.1)
simple_form (2.1.0)

导致错误的原因是什么?

1 个答案:

答案 0 :(得分:0)

在这个主题:https://github.com/activeadmin/activeadmin/issues/2703,SpecialCyCi有一个修复问题的黑客。

config/initializers/simple_form.rb的顶部,输入以下内容:

inputs = %w[
  CollectionSelectInput
  DateTimeInput
  FileInput
  GroupedCollectionSelectInput
  NumericInput
  PasswordInput
  RangeInput
  StringInput
  TextInput
]

inputs.each do |input_type|
  superclass = "SimpleForm::Inputs::#{input_type}"
  hack = %|
    module SimpleForm
      module Inputs
        class #{superclass}
          def input_html_classes
            super.push('form-control')
          end
        end
      end
    end
  |
  eval(hack)

end

SimpleForm.setup do |config|
  # your config here...
  # ...
end