Search code examples
ruby-on-railsruby-on-rails-5

Why am I getting a Syntax Error when trying to add a placeholder to my Rails form?


I'm trying to add a placeholder to my Rails 5 form field but the following code is throwing a syntax error: <%= text_field_tag(:q), placeholder: 'Enter a city' %>

<%= text_field_tag(:q %> works as expected, but adding the placeholder throws the error.


Solution

  • Try with

    <%= text_field_tag :q, nil, placeholder: "Enter a city" %>
    

    For more information refer here