I would like to set a rails form text_field property to read only when the model already contains a value.
Here is my code
<%= f.text_field :domain, class="span4", readonly: "true" %>
I want to avoid doing something verbose like:
<%if @model.domain.empty? %>
<%= f.text_field :domain, class="span4"%>
<%else%>
<%= f.text_field :domain, class="span4", readonly: "true" %>
<%end%>
Thanks!
1 Answer