0
私は私のメッセージアプリケーションとしてMailboxerを使っています。Ruby on Railsは別のビューに値を渡します
このサイトについては、すべての分類は、私がnew_messageフォームにルーティングし、受信者の罰金にメッセージを書くために実装した連絡先販売者リンクを持っています!
ここで、連絡フォームが作成されたことに関する情報を追加したいと思います。
class MessagesController < ApplicationController
before_action :authenticate_user!
def new
@user = User.find_by(id: params[:recipient_id])
end
def name
first_name
end
def mailboxer_email(object)
email
end
def create
recipients = User.find_by(id: params[:recipient_id])
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
これは、new_message_pathを呼び出して、受信者を定義するuser_idを取得するビューです。
<div class="center-div">
<div class="col-lg-12" id="image">
<% @classified.photos.each do |p| %>
<h3 class="dark-grey"><%= @classified.title %></h3>
<h5 class="dark-grey">Loved by: <%= @classified.favorited_by.count %> </h5>
<%= image_tag p.image %>
<%end%>
</div>
<%= link_to "", new_message_path(:recipient_id => @classified.user_id), :class => "glyphicon glyphicon-envelope" , :style => "color:#EFCE7B" %>
<%if current_user.favorite_classifieds.collect(&:classified_id).include?(@classified.id) %>
<%= link_to "", favorite_classified_path(@classified, type: "unfavorite") , :class => "glyphicon glyphicon-heart" , :style => "color:#FF0000", method: :put %>
<%else%>
<%= link_to "", favorite_classified_path(@classified, type: "favorite") , :class => "glyphicon glyphicon-heart" , :style => "color:#000000", method: :put %>
<%end%>
<%= link_to "", editlisting_path(@classified) , :class => "glyphicon glyphicon-flag" , :style => "color:#EB573B" %>
<ul>
<h3 class="dark-grey">Model</h3>
<li><%= @classified.model %></li>
<h3 class="dark-grey">Description</h3>
<li><%= @classified.description %></li>
<li><%= link_to "Back", '/' , :class => "link" %></li>
<li><%= link_to @classified.user.first_name, profile_path(@classified.user_id) %></li>
</ul>
</div>
と、これは良い説明は私に多くのことを助ける任意の解決のためにも、私は分類
<div class="center-div">
<div class="messages-box">
<% page_header "Αποστολή μηνύματος" %>
<%= form_tag messages_path, method: :post do %>
<div class="form-group">
<%= label_tag 'message[subject]', 'Subject' %>
<%= text_field_tag 'message[subject]', nil, class: 'form-control', required: true %>
</div>
<div class="form-group">
<%= label_tag 'message[body]', 'Message' %>
<%= text_area_tag 'message[body]', nil, cols: 3, class: 'form-control', required: true %>
</div>
<div class="form-group">
<%= hidden_field_tag(:recipient_id, "#{@user.id}") %>
</div>
<%= submit_tag 'Send', class: 'btn btn-primary' %>
<% end %>
</div>
</div>
のデータを持つようにしたい私のmessage_new図です。
ありがとうございます。