本文介绍了找不到FakeInput的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下建议(),但对我不起作用.

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.

这是我的HAML代码,用于添加假输入字段.

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

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

我将以下类放入app/inputs/fake_input.rb

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

我收到以下运行时错误

No input found for fake

我有两个由Rails Composer生成的初始化程序:simple_form.rb和simple_form_bootstrap.rb

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

如何让Rails找到我的FakeInput类?

How can I make Rails find my FakeInput class?

推荐答案

我遇到了同样的问题,并且服务器重新启动解决了该问题.

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

这篇关于找不到FakeInput的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 11:16