将HTML输入标记转换为Rails erb模板

时间:2014-08-09 17:42:05

标签: ruby-on-rails ruby erb

我有一个HTML表单,我希望转换为我的Ruby on Rails应用程序的ERB模板。我不确定如何将required autofocus属性转换为erb模板。其余的代码是直截了当的。

HTML

<input type="email" class="form-control" placeholder="Email address" required autofocus>

ERB

 <%= f.email_field :email, :class => 'form-control', :placeholder => 'Email address' %>

如何将required autofocus属性添加到ERB标记?

1 个答案:

答案 0 :(得分:4)

你需要使用 autofocus:true和required:true ,如下所示:

<%= f.email_field :email, :class => 'form-control', :placeholder => 'Email address', :autofocus => true, :required => true %>