在邮箱gem中添加自定义属性

时间:2017-10-25 11:55:05

标签: ruby-on-rails spree mailboxer

我已经将mailboxer gem用于我网站中用户之间的消息传递。

哪个基于狂欢模块。

我想在会话中添加产品ID,以便用户根据产品过滤对话。

我怎样才能做到这一点?

以下是message_controller文件的代码:

module Spree
module Admin
    class MessagesController < Spree::BaseController
      before_action :authenticate_spree_user!

     def index
        filtered_messages = Mailboxer::Message.ads_id(params[:ad_id])
     end

      def new
        @chosen_recipient = Spree::User.find_by(id: params[:to].to_i) if params[:to]

      end

      def create
        product_id = params[:product_id]
        recipients = Spree::User.where(id: params['recipients'])
        conversation = current_spree_user.send_message(recipients, params[:message][:body], params[:message][:subject], params[:product_id]).conversation
        flash[:success] = 'Message has been sent!'
        redirect_to '/admin/conversations'
      end



      private

       def conversation_params
        #params.require(:mailboxer_conversations).permit(:ad_id)
        params.permit(:ad_id)
      end

    end
end

0 个答案:

没有答案