Cannot find FakeInput

我是研究僧i 提交于 2019-12-23 05:27:44

问题


I am trying add a fake input to simple_form using the following suggestion (rails simple_form fields not related to the model), but it does not work for me.

This is my HAML code for adding a fake input field.

= f.input :agrees_to_terms, :as => :fake

I put the following class in app/inputs/fake_input.rb

class FakeInput < SimpleForm::Inputs::StringInput
  # This method only create a basic input without reading any value from object
  def input
    template.text_field_tag(attribute_name, nil, input_html_options)
  end
end

I get the following runtime error

No input found for fake

I have two initializers that were generated by Rails Composer: simple_form.rb and simple_form_bootstrap.rb

How can I make Rails find my FakeInput class?


回答1:


I had the same issue, and a server restart resolved it.



来源:https://stackoverflow.com/questions/15170785/cannot-find-fakeinput

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!