searchkick show associations in view

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

searchkick show associations in view

fugee ohu
How do I show associations in a view with searchkick? I get error association not found even though user has_many_addresses
My user model has

scope :search_import, -> { includes(:addresses) }

search.html.erb:

<h3><%= (t 'search_results_for') %> <%= @terms %></h3>
<ul>
 <% @users.each do |u| %>
  <li>
      <%= link_to "#{u.first_name} #{u.middle_name} #{u.last_name}", page_path(name: u.name) %>
    <% ua=u.addresses.where("current=?, limit: 1", true)  %>
        <% if ua.country=="US" %>
            <%= ua.city %>, <%= ua.state %> <%= ISO3166::Country.find_country_by_alpha2(ua.country) %>
        <% else %>
            <%= ua.city %>, <%= ISO3166::Country.find_country_by_alpha2(ua.country) %>
        <% end %>
  </li>
 <% end %>
</ul>


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/34df3737-250d-4dfa-b9ed-3ffb06c7354b%40googlegroups.com.