ruby on rails - add an associated record to search results -
i trying query solr index users. have usersphoto model associated user model. when query index want able the associated user photo each result.
here search method:
def json_index_searches_users_profile_with_limit_and_offset_and_keyword search_term = params[:keyword] search_term.downcase! @search = sunspot.search(users) fulltext search_term end @users = @search.results respond_to |format| format.json { render json: @ users } end end @users = [#<user id: 25, email: "********.com", created_at: "2013-07-16 22:32:23", updated_at: "2014-04-18 18:36:46", password_digest: "$2a$10$ceq3u7pi8n23mhesli2kiovyodag86txv6utggmhcsle...", remember_token: "7t6pim-btus9- usjm314fa", admin: true, username: "********", password_reset_token: nil, password_reset_sent_at: nil, provider: nil, uid: nil, generated_password: false>, #<user id: 37690, email: "********.com", created_at: "2014-06-09 16:07:59", updated_at: "2014- 06-09 16:07:59", password_digest: "$2a$10$g8f9qjmgwhkmdomuwidguekvzgrfme7acmzil0mzsbjm...", remember_token: "l3g9p- 1vh5byosb8c2azxg", admin: false, username: "********", password_reset_token: nil, password_reset_sent_at: nil, provider: nil, uid: nil, generated_password: false>, #<user id: 41480, email: "********.com", created_at: "2014-06-14 00:44:55", updated_at: "2014- 06-14 00:44:55", password_digest: "$2a$10$jqpt/jhxp9cq81ttt0p ....
Comments
Post a Comment