在text_field_tag中添加一个类

Dav*_*mar 27 ruby ruby-on-rails class form-helpers

我想给我的text_field_tag上课

我有这个

<%= text_field_tag :login_aei, class: 'form-control' %>
Run Code Online (Sandbox Code Playgroud)

但它不断产生这个:

<input type="text" name="login_aei" id="login_aei" value="{:class=>&quot;form-control&quot;}">
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么 ?

Aru*_*hit 56

你说错了.这是一个将工作.

<%= text_field_tag :login_aei, "", class: 'form-control' %>
Run Code Online (Sandbox Code Playgroud)

我将input字段的值作为空字符串给出,但您可以提供满足您业务需求的任何值.