I have a User model which act_as_messageable using the Mailboxer gem.
In my users#index view, I would like to add a link for each user to the first user conversation
Right now, I have my link which looks like this :
<%= link_to conversation_path(user.mailbox.conversations.first) do %>Button to conv<% end %>
It works but, since I didn't include the conversations when I requested the users, I see a lot of n+1 queries.
How can I load the conversations at the same time than the users ?
I already tried User.all.includes(mailbox: :conversations) with no luck
Thank you in advance for your help !
Join 31,575+ developers who get early access to new screencasts, articles, guides, updates, and more.