0

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?

2 Answers 2

1

Why not just remove the erb tags?

<%= f.input :name, :input_html => { :value => @user.name } %>
Sign up to request clarification or add additional context in comments.

1 Comment

Cuz that gives me the literal text instead go the value
1

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 %>

1 Comment

The form is not for user which is why I have to force the attributes from user as defaults.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.