title: Replying to conversations with Mailboxer gem in Rails 4
body: <p>I'm having trouble replying to conversations with the Mailboxer gem in Rails 4. There isn't a whole lot of documentation on this gem, or maybe I'm just not experienced enough, but I've been stuck on this for a while now.</p>
  
  <p><strong>view/conversations/index:</strong>
  <em>(shows list of all current user's conversations)</em></p>
  
  <pre><code>&lt;% @conversations.each do |conversation| %&gt;
  &lt;%= link_to conversation.subject, reply_conversation_path(conversation.id) %&gt;
  &lt;%= conversation.updated_at.strftime("%a, %m/%e/%Y %I:%M %p") %&gt;
  &lt;%= link_to "Move to Trash", {:controller =&gt; "conversations", :action =&gt; 
      "trash", :id =&gt; conversation.id}, :title=&gt; "Move to Trash", :method=&gt;'post' %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>When I click the first <code>link_to</code> in the above view, I receive the routing error: <code>No route matches [GET] "/conversations/68/reply"</code>. </p>
  
  <p>I was hoping to have it render the following view, and have the correct conversation passed to it: </p>
  
  <p><strong>view/messages/_form/</strong>
  (used to reply to existing conversations)</p>
  
  <pre><code>Reply:
  &lt;%= form_for :message, url: :conversation do |f| %&gt;
  &lt;%= f.text_area :body %&gt;
  &lt;%= f.submit "Send Message", class: 'btn btn-primary' %&gt;
  &lt;%= submit_tag 'Clear Reply Box', type: :reset, class: 'btn btn-danger' %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p><strong>Routes:</strong></p>
  
  <pre><code>resources :users
  root to: 'profiles#index'
  
  resources :messages do
    member do
        post :new
    end
  end
  resources :conversations do
    member do
        post :reply
        post :trash
        post :untrash
    end
    collection do
        get :trashbin
        post :empty_trash
    end
  end
  </code></pre>
  
  <p><strong>Conversations Controller:</strong></p>
  
  <pre><code>class ConversationsController &lt; ApplicationController
  before_filter :authenticate_user!
  helper_method :mailbox, :conversation
  def index
      @conversations ||= current_user.mailbox.inbox.all
  end
  
  def reply
      current_user.reply_to_conversation(conversation, *message_params(:body, :subject))
      redirect_to conversation
  end
  
  def trashbin
      @trash ||= current_user.mailbox.trash.all
  end
  
  def trash
      conversation.move_to_trash(current_user)
  redirect_to :conversations
  end
  
  def untrash
      conversation.untrash(current_user)
  redirect_to :back
  end
  
  def empty_trash
      current_user.mailbox.trash.each do |conversation|
          conversation.receipts_for(current_user).update_all(:deleted =&gt; true)
      end
  redirect_to :conversations
  end
  
  private
  
  def mailbox
      @mailbox ||= current_user.mailbox
  end
  
  def conversation
  
      @conversation ||= mailbox.conversations.find(params[:id])
  end
  
  def conversation_params(*keys)
      fetch_params(:conversation, *keys)
  
  end
  
  def message_params(*keys)
      fetch_params(:message, *keys)
  end
  
  def fetch_params(key, *subkeys)
      params[key].instance_eval do
          case subkeys.size
              when 0 then self
              when 1 then self[subkeys.first]
              else subkeys.map{|k| self[k] }
          end
      end
  end
  end
  </code></pre>
  
  <p><strong>Messages Controller:</strong></p>
  
  <pre><code>class MessagesController &lt; ApplicationController
  
  # GET /message/new
  def new
  
      @request = Request.find(params[:request])
      @message = current_user.messages.new
      @user = @request.user
  end
  
  # POST /message/create
  def create
  
  @user = User.find(params[:user])
  @body = params[:body]
  @subject = params[:subject]
  
  current_user.send_message(@user, params[:body], params[:subject])
  flash[:notice] = "Message has been sent!"
  redirect_to :conversations
  end
  end
  </code></pre>
  
  <p><strong>relevant rake routes:</strong></p>
  
  <pre><code>                    users GET    /users(.:format)                     users#index
                        POST   /users(.:format)                     users#create
               new_user GET    /users/new(.:format)                 users#new
              edit_user GET    /users/:id/edit(.:format)            users#edit
                   user GET    /users/:id(.:format)                 users#show
                        PATCH  /users/:id(.:format)                 users#update
                        PUT    /users/:id(.:format)                 users#update
                        DELETE /users/:id(.:format)                 users#destroy
                   root GET    /                                    profiles#index
                message POST   /messages/:id(.:format)              messages#new
               messages GET    /messages(.:format)                  messages#index
                        POST   /messages(.:format)                  messages#create
            new_message GET    /messages/new(.:format)              messages#new
           edit_message GET    /messages/:id/edit(.:format)         messages#edit
                        GET    /messages/:id(.:format)              messages#show
                        PATCH  /messages/:id(.:format)              messages#update
                        PUT    /messages/:id(.:format)              messages#update
                        DELETE /messages/:id(.:format)              messages#destroy
     reply_conversation POST   /conversations/:id/reply(.:format)   conversations#reply
     trash_conversation POST   /conversations/:id/trash(.:format)   conversations#trash
   untrash_conversation POST   /conversations/:id/untrash(.:format) conversations#untrash
  trashbin_conversations GET    /conversations/trashbin(.:format)    conversations#trashbin
  empty_trash_conversations POST   /conversations/empty_trash(.:format) conversations#empty_trash
          conversations GET    /conversations(.:format)             conversations#index
                        POST   /conversations(.:format)             conversations#create
       new_conversation GET    /conversations/new(.:format)         conversations#new
      edit_conversation GET    /conversations/:id/edit(.:format)    conversations#edit
           conversation GET    /conversations/:id(.:format)         conversations#show
                        PATCH  /conversations/:id(.:format)         conversations#update
                        PUT    /conversations/:id(.:format)         conversations#update
                        DELETE /conversations/:id(.:format)         conversations#destroy
  </code></pre>
  
  <p>To give you an idea of how I've gotten this far, I've been following this tutorial: <a href="http://jamestansley.com/2014/02/22/customizing-the-mailboxer-ruby-gem-2/" rel="nofollow noreferrer">http://jamestansley.com/2014/02/22/customizing-the-mailboxer-ruby-gem-2/</a> </p>
  
  <p>I'm guessing that I need to study routing more, but I need to finish this by the end of the weekend, so you're help is greatly appreciated. </p>
  
  <p>In case I've left anything out, here's my github repo:
  <a href="https://github.com/portOdin/GoFavorIt-Heroku/tree/stackflow/app" rel="nofollow noreferrer">https://github.com/portOdin/GoFavorIt-Heroku/tree/stackflow/app</a>.</p>
  
  <p>UPDATE:</p>
  
  <p>I solved the problem, as I mentioned below, though I have another now.</p>
  
  <p>'undefined method `[]' for nil:NilClass'</p>
  
  <p><img src="https://i.stack.imgur.com/eFXa6.png" alt="enter image description here"></p>
  
  <p>This question's getting pretty large so I'll probably open another later, unless you can help me out here.</p>