Michael P.
Michael P.

Reputation: 1413

How do I add an Rails form helper HTML attribute that does not contain a quoted value?

For example, "required."

Rails chokes on any attempt to add the attribute thus:

<%= f.email_field :email, :"ng-model" => "whatever", :class => "form-control input-lg", :"required" %>

Upvotes: 1

Views: 98

Answers (2)

Alejandro Babio
Alejandro Babio

Reputation: 5229

You must do the same as you do with class, add html_attribute => value

<%= f.email_field :email, :"ng-model" => "whatever", :class => "form-control input-lg", :"required" => true %>

Upvotes: 1

Claudi
Claudi

Reputation: 5416

Just use boolean values:

<%= f.email_field :email, :"ng-model" => "whatever", :class => "form-control input-lg", :"required" => true %>

Upvotes: 4

Related Questions