Search code examples
ruby-on-railsmailboxer

Default path to look for partial


In my app/views/conversations/index.html.erb, I am writing:

<%= render @conversations %>

hoping that it would find a partial named _conversation.html.erb inside the same directory, and use it to render each elements in @conversations. (The usual Rails way)

But I get a missing template error: Missing partial mailboxer/conversations/_conversation.

I am using a Mailboxer gem, and there were no documentations for this. I know I could render a partial explicitly by <%= render partial: 'conversation', locals: { conversations: @conversations } %>.

Yet still, I would like to know why my app is looking for a partial for @conversations in mailboxer/conversations/, not conversations/, and if there is a way to change this behavior.

More information

<% @conversations.each do |conversation| %>
  <%= div_for conversation %>
<% end %>

produces HTML:

<div class="mailboxer_conversation" id="mailboxer_conversation_16"> ... </div>
<div class="mailboxer_conversation" id="mailboxer_conversation_17"> ... </div>
....

Perhaps the mailboxer_ in front of conversation has something to do with this situation also?


Solution

  • This happens because, in later versions of Mailboxer, models are namespaced under Mailboxer. (e.g. Mailboxer::Conversation, Mailboxer::Message.)

    I commented on the GitHub issue also.