Cannot find FakeInput

2019-06-08 17:09发布

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条回答
一纸荒年 Trace。
2楼-- · 2019-06-08 17:18

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

查看更多
登录 后发表回答