I'm trying to post to the messages controller from a form rendered by the conversations controller I'm passing the conversation_id by hidden_field_tag but I get the error ActiveRecord::RecordNotFound (Couldn't find Mailboxer::Conversation with 'id'={:value=>8}
Here's my form:
<%= form_tag reply_to_conversation_for_chat_view_path, id: "chat_message_form", method: :post, remote: true, multipart: true do %>
<%= hidden_field_tag :recipients, value: @recipients.first.id %>
<%= hidden_field_tag :sender, value: current_user.id %>
<%= hidden_field_tag :subject, value: 'No subject' %>
<%= hidden_field_tag :conversation_id, value: @conversation.id %>
<div class="field">
<%= text_area_tag :body, nil, rows: 3, cols: 75 %>
</div>
<div class="field">
<%= label_tag 'Attachment' %><br>
<%= file_field_tag :attachment %>
</div>
<br>
<div class="submit">
<%= submit_tag 'Send' %>
</div>
<% end %>
And here's the set_conversation routine in the messages controller:
@conversation = current_user.mailbox.conversations.find(conversation_id)
I solved this by adding the conversation_id to the form definition