0

I'm using pg_search to do some basic search in my Rails app, but when I try and render certain things like the name attribute of each result, it also renders a pg_search hash of all the data for that result. Here's my search results page code:

<ul class="results">
    <%= @pg_search_documents.each do |pg_search_document| %>
    <%= pg_search_document.searchable.name %>
    <% end %>
</ul>

How can I just render the name attribute of the result, and not all the other data for that pg_search document?

Tom Maxwell
  • 9,273
  • 17
  • 55
  • 68

1 Answers1

0

do this

<ul class="results">
    <% @pg_search_documents.each do |pg_search_document| %>
    <%= pg_search_document.searchable.name %>
    <% end %>
</ul>

<%= %> is for output-ing

<% %> is evaluating . Since just you want to evaluate, use this

Paritosh Piplewar
  • 7,982
  • 5
  • 26
  • 41