simple_form:指定文本字段的id

我在下面有简单的simple_form。 我正在尝试将输入字段的ID设为’my-id’,但下面的解决方案不起作用(id为’comment_body’)。 如何指定该输入字段的ID?

= simple_form_for(@comment) do |f| = f.input :body, as: :string, html: {id: "my-id"} = f.button :submit 

我也试过了

  = f.input :body, as: :string, id: "my-id" 

无济于事。

:input_html有效,不是:html

  = f.input :body, as: :string, input_html: {id: "my-id"} 

自首次回答此问题以来,向simpleform输入字段添加ID的方法已更改。

最新的语法(版本3.2.0)将是op尝试的:

  = f.input :body, as: :string, id: "my-id" 

我想我会在这个问题上添加一个更新,因为它在搜索’simpleform id’时接近谷歌的顶部。