0

Rails 3.1 アプリで Mailboxer gem を動作させようとしています... New メッセージ機能は動作していますが、会話に返信するとundefined method 'is_trashed?' for nil:NilClassエラーが発生し続けます。

私は gem サイトの read me info をたどり、ここでメールボックス アプリの例を見てきまし

これが私のコントローラーです:

class ConversationsController < ApplicationController
  before_filter :authenticate_user!
  helper_method :mailbox, :conversation

  def show
    @conversation ||= mailbox.conversations.find(params[:id])
  end

  def create
    recipient_emails = conversation_params(:recipients).split(',')
    recipients = User.where(email: recipient_emails).all

    conversation = current_user.send_message(recipients, *conversation_params(:body, :subject)).conversation

    redirect_to conversation
  end

  def reply
    conversation = current_user.reply_to_conversation(conversation, *message_params(:body)).conversation
    redirect_to conversation
  end

  def trash
    conversation.move_to_trash(current_user)
    redirect_to :back
  end

  def untrash
    conversation.untrash(current_user)
    redirect_to :back
  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

そして、ここに私の返信フォームがあります:

<%= simple_form_for :message, url: [:reply, conversation] do |f| %>
  <%= f.input :body, as: :text, :input_html => { :cols => 50, :rows => 3 } %>
  <div >
    <%= f.button :submit, "Send", class: 'btn btn-primary' %>
  </div>
<% end %>

新しい会話は機能していますが、何らかの理由でreply_to_conversation機能に関するエラーが発生し続けます。どんな助けでも大歓迎です!

4

1 に答える 1

0

どうやら、サーバーを再起動する必要があったようです...理由はわかりません。これは、コントローラーとビュー側のみにあったためです。それは今働いています!

于 2013-11-11T22:34:37.593 に答える