我无法使用邮箱gem工作发送邮件按钮。我将本教程用作指南“http://josephndungu.com/tutorials/private-inbox-system-in-rails-with-mailboxer”,其他人必须从所有用户列表中选择收件人。
我想要一个按钮直接发送没有列表的消息,所以我在页面上发送了“发送用户消息”按钮,将用户ID传递给新的会话表单。
邮件不会被发送,只会显示在发件人的已发送框中。
这是我的代码:
<%= link_to '', new_conversation_path(:recipients_id => @user), class: 'send-message-icon' %>
也尝试过:
<%= form_for :conversation, url: :conversations, html: { class: "" } do |f| %>
<div class="form-group">
<%= f.label :recipients %>
<%= f.text_field :recipients, :value => params[:recipients_id]%>
</div>
<div class="form-group">
<%= f.label :subject %>
<%= f.text_field :subject, placeholder: "Subject", class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :message %>
<%= f.text_area :body, class: 'form-control',placeholder: "Type your message here", rows: 4 %>
</div>
<%= f.submit "Send Message", class: "btn btn-success" %>
_form :(正确的用户ID显示在文本框中。我稍后会删除文本框)
def create
recipients = User.where(id: conversation_params[:recipients])
conversation = current_user.send_message(recipients, conversation_params[:body], conversation_params[:subject]).conversation
flash[:success] = "Your message was successfully sent!"
redirect_to conversation_path(conversation)
end
控制器:
acts_as_messageable
before_destroy { messages.destroy_all }
用户模型:
private async void Button_Click(object sender, RoutedEventArgs e)
{
// Initialize Media Capture and Settings Objects, mediaCapture declared global outside this method
var mediaCapture = new MediaCapture();
// Grab all available VideoCapture Devices and find rear device (usually has flash)
await mediaCapture.InitializeAsync();
var videoEncodingProperties = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Vga);
var videoStorageFile = await KnownFolders.VideosLibrary.CreateFileAsync("tempVideo.mp4", CreationCollisionOption.GenerateUniqueName);
await mediaCapture.StartRecordToStorageFileAsync(videoEncodingProperties, videoStorageFile);
await Task.Delay(TimeSpan.FromMilliseconds(500));
mediaCapture.VideoDeviceController.TorchControl.Enabled = true;
}
我无法理解为什么它不起作用。任何建议都将不胜感激,谢谢。
答案 0 :(得分:0)
经过几个小时的#$%“#”$%#$ @围绕我的工作。
从任何地方发送消息链接:
<%= link_to '', new_conversation_path(:recipient_id => @user.id), class: 'send-message-icon' %>
_form:
<%= form_for :conversation, url: :conversations, html: { class: "" } do |f| %>
<div class="form-group">
<%= f.label :recipients %>
<%= hidden_field_tag(:recipient_id, "#{@user.id}") %></div>
<div class="form-group">
<%= f.label :subject %>
<%= f.text_field :subject, placeholder: "Subject", class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :message %>
<%= f.text_area :body, class: 'form-control',placeholder: "Type your message here", rows: 4 %>
</div>
<%= f.submit "Send Message", class: "btn btn-success" %>
<% end %>
控制器:
def new
@user = User.find_by(id: params[:recipient_id])
end
def create
recipients = User.find_by(id: params[:recipient_id])
conversation = current_user.send_message(recipients, conversation_params[:body], conversation_params[:subject]).conversation
flash[:success] = "Your message was successfully sent!"
redirect_to conversation_path(conversation)
end