I have a simple search form:
<%= form_with(url: recherche_path, method: "get", class: "side-box", local: true) do %>
<div id="search-container">
<%= text_field_tag(:q, nil, placeholder: "Rechercher un mot dans le dictionnaire...", id: "search") %>
<ul id="search-results"></ul>
</div>
<% end %>
It redirects to this controller method:
def recherche
@results = Word.search(params['q']).first(20)
end
Which uses this model scope:
scope :search, ->(content) {
quoted_content = ActiveRecord::Base.connection.quote_string(content)
where("content % :content", content: content).
order(Arel.sql("similarity(content, '#{quoted_content}') DESC"))
}
Everything works fine in development but in production I get the following error:
no implicit conversion of nil into String
It seems the params[:q] returns nil, but I can't find why?
EDIT
Here is the HTML form rendered (see it in action here):
<form class="side-box" action="/dictionnaire/recherche" accept-charset="UTF-8" data-remote="true" method="get">
<div id="search-container" data-children-count="1">
<input type="text" name="q" id="search" placeholder="Rechercher un mot dans le dictionnaire..." class="">
<ul id="search-results"></ul>
</div>
</form>