So I'm trying to set the default search field value to the pre-existing one if it exists
<%= form_tag universities_path, :method => "get", :class => "form-search" do %>
<%= label_tag :query, "Search by name" %>
<%= text_field_tag :query, :input => params[:query] unless params[:query].nil? %>
<%= text_field_tag :query if params[:query].nil? %>
<%= label_tag :state %>
<%= select_tag :state, options_for_select(@states, params[:state]) %>
<%= submit_tag "Search", :class => 'btn' %>
<% end %>
The above code outputs a hash that looks like this ({:input=>"coastal"}
). When I run the x.values
where x = params[:query] I get a "undefined method `values' for "coastal":String".
Running params[:query].class yields this (to the input field), btw ({:input=>String}
)