问题
I am using Rails 4 with Ransack.
I cant make to work searching for integer and string values.
So far I tried this code.
In view:
<%= search_form_for @search do |f| %>
<div class="field">
<%= f.label :name_cont, "Nepieciešama meklēšāna pēc ID, vārda un telefona nr" %>
<%= f.text_field :name_or_phone_number_cont_or_id_eq, :placeholder => 'Meklēt pēc ID,vārda vai tel.nr.' %>
</div>
<div class="actions"><%= f.submit "Search" %></div>
<% end %>
In controller :
def index
@search = Advertisement.search(params[:q])
@advertisements = @search.result
respond_with(@advertisements)
end
This gives me error:
undefined method `name_or_phone_number_cont_or_id_eq' for
Is there any workaround to this problem? Or I need to convert id to string for search purposes ?
Thanks in advance.
来源:https://stackoverflow.com/questions/27148185/ransack-search-for-integer-and-string-values-from-single-search-field