How to set text in text_field_tag?

Simple problem but I can’t find a solution.

I have this tag:

<%=text_field_tag(“query”, params[:query], :autocomplete => “off” ) %>

Its a search field box.

Question: how do I update the text in the text field??? i.e is there a
rails equivalent like query.setText(“some text”)


The second argument is the value you want it to be … so, default
params[:query] in your controller, or do something like this

<%=text_field_tag(“query”, params[:query] || “Some
value”, :autocomplete => “off” ) %>

in-line || allows you to specify something if the value before the ||
is nil, another useful thing, e.g. in the controller

params[:query] ||= “Some value”

This will set the value if params[:query] is nil