我有一个按钮,可以将当前用户发送到链接。我希望将相同的链接作为消息发送给另一个用户。我使用Mailboxer作为消息传递部分。
我的show.html.erb中的按钮:
Product.id:1, Product.name:watch, Product.price:100, Product.sale_price:nil
Product.id:2, Product.name:Bag, Product.price:200, Product.sale_price:50
Product.id:3, Product.name:Shoes, Product.price:300, Product.sale_price:nil
按钮的控制器:
<%= form_tag zoom_index_path do %>
<%= submit_tag 'Start a session' %>
<% end %>
消息控制器:
class ZoomController < ApplicationController
require 'zoomus'
def index
end
def create
zoomus_client = Zoomus.new
meeting = zoomus_client.meeting_create(host_id: 'dWkVNB2tQvic4YcPYK6tDA', topic: 'topic1', type: 1)
redirect_to meeting["start_url"]
end
对话控制器:编辑以缩短代码。
class MessagesController < ApplicationController
before_action :authenticate_user!
def new
@chosen_recipient = User.find_by(id: params[:to].to_i) if params[:to]
end
def create
recipients = User.where(id: params['recipients'])
conversation = current_user.send_message(recipients, params[:message][:body], params[:message][:subject]).conversation
flash[:success] = "Message has been sent!"
redirect_to conversation_path(conversation)
end
end