Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 使用Rails 4中的Mailboxer gem发送电子邮件_Ruby On Rails_Email_Mailboxer - Fatal编程技术网

Ruby on rails 使用Rails 4中的Mailboxer gem发送电子邮件

Ruby on rails 使用Rails 4中的Mailboxer gem发送电子邮件,ruby-on-rails,email,mailboxer,Ruby On Rails,Email,Mailboxer,我已经使用Mailboxer设置了我的站点,以创建一个站点内消息传递系统。现在我想实现Mailboxer的电子邮件功能,这样当在我的站点中发送消息时,用户也会收到一封通知他们的电子邮件 我已经搜索了文档,但似乎没有关于设置邮件方面的文档。到目前为止,我已经从gem的app/mailer/目录中获取了mailer类,并将它们放在我的app/mailer/目录中,在它们的mailboxer文件夹中。(app/mailer/mailboxer/)。现在我不知道如何使用这些邮件中的方法 以下是我为ins

我已经使用Mailboxer设置了我的站点,以创建一个站点内消息传递系统。现在我想实现Mailboxer的电子邮件功能,这样当在我的站点中发送消息时,用户也会收到一封通知他们的电子邮件

我已经搜索了文档,但似乎没有关于设置邮件方面的文档。到目前为止,我已经从gem的
app/mailer/
目录中获取了mailer类,并将它们放在我的
app/mailer/
目录中,在它们的mailboxer文件夹中。(
app/mailer/mailboxer/
)。现在我不知道如何使用这些邮件中的方法

以下是我为insite消息设置的控制器,它们工作正常:

消息控制器:

class MessagesController < ApplicationController

    # GET /message/new
    def new
        @request = Request.find(params[:request])
        @message = current_user.messages.new
        @user = @request.user
    end

    def reply
        @conversation ||= current_user.mailbox.conversations.find(params[:id])
    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
class ConversationsController < 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_path(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 => 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)
        # debugger
        params[key].instance_eval do
            # debugger
            case subkeys.size
                when 0 then
                    self
                when 1 then
                    self[subkeys.first]
                else
                    subkeys.map { |k| self[k] }
            end
        end
    end
end

但是它给了我一个错误
未定义的方法“new#message_email”,用于#
,所以显然我不知道我在做什么。有人能告诉我需要做什么来设置这个吗?非常感谢您的建议。

即使我也有同样的问题。你能设置你的应用程序来发送电子邮件吗?我最终花了25美元给别人帮我做了这件事。虽然我当时更像是个傻瓜,现在也许能弄明白;我会尽力给你回电的。你运气好吗?
def create
    @user = User.find(params[:user])
    @body = params[:body]
    @subject = params[:subject]
    current_user.send_message(@user, params[:body], params[:subject])
            new_message_mailer(@subject, @user)
    flash[:notice] = "Message has been sent!"
    redirect_to :conversations
end