0

I'm trying to add a variable(Post title) to my string for my input text field's value.

I just get to see #{@post.title} though, instead of the true title.

What am I doing wrong?

In my form.html.erb:

<%= f.text_field :title, :value => 'Enquiry about post #{@post.title}' %>

1 Answer 1

2

You're not using the right quotes, you need to use double quotes " for string interpolation:

<%= f.text_field :title, :value => "Enquiry about post #{@post.title}" %>

Please find some further information on Interpolation at wikibooks.

Sign up to request clarification or add additional context in comments.

Comments

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.