Reputation: 2520
Good sirs:
I have this
<%= f.input :name, :input_html => { :value => '<%= @user.name %>' } %>
and the erb tags within erb tags brings joy to no one.
How to do it correctly?
Upvotes: 0
Views: 673
Reputation: 1652
Why not just remove the erb tags?
<%= f.input :name, :input_html => { :value => @user.name } %>
Upvotes: 1
Reputation: 38645
Use it as value: @user.name
:
<%= f.input :name, :input_html => { :value => @user.name } %>
If the form builder object f
in your case is for the @user
instance then the value will be pre-populated in case of validation errors. For example, the following will suffice:
<%= simple_form_for @user do |f| %>
<%= f.input :name %>
<% end %>
Upvotes: 1