Ari53nN3o
Ari53nN3o

Reputation: 1202

sunspot solr, rails 3.1.1: Why do my results have the entire db record printed automatically?

I did the standard procedure in setting up Sunspot Solr for my rails app but when I print the results, I get the entire db record printed automatically.

Here is my results.html.erb:

<%= @users.each do |result| %>
    <%= link_to "#{result.first_name}", user_path(result) %>
<% end %>

The view rendered is:

Test [#<User id: 38, first_name: "Test", last_name: "Test", email: "[email protected]", encrypted_password: "b519f1c58f8f5b9fffa0ada91ac7ca8316ebb8f8cec548404b8...", salt: "7f6287c48f49ac0a55c2cdc00803caaaa463c3b5efb88b57f40...", created_at: "2011-11-28 07:00:32", updated_at: "2011-11-28 07:00:32">

Can you please tell me how can I get rid of the hash and just be able to display the first name?

Thanks in advance

Upvotes: 0

Views: 130

Answers (1)

ahhhbuddye
ahhhbuddye

Reputation: 86

take out the = at <%= @users.each do |result| %>

so instead

<% @users.each do |result| %>
    <%= link_to "#{result.first_name}", user_path(result) %>
<% end %>

Upvotes: 3

Related Questions