I have developed a social media site, much like Facebook/Instagram, etc… I am tried to develope a MAILBOX LIKE FACEBOOK. The problem I have is with developing the Mailbox. I do not get the option to send an email!!!!!
I am using Rails 7. a copy by this guy: https://github.com/KhanradCoder/mailbox/blob/master/app/views/messages/index.html.erb
and this guy : https://github.com/danarmulder/simple_rails_messaging_tutorial .
Which are basically the same code. However, I can not get my system to work. I can see the conversation home page, but when I click on the user’s email to message the users, I do not get the form to send an email. For some reason it is not reading message.index.html Any thoughts?
Here is the code:
<div class="ui segment">
<h3>My Mailbox</h3>
<div class="ui list">
<div class="item">
<% @conversations.each do |conversation| %>
<% if conversation.sender_id == current_user.id || conversation.recipient_id ==
current_user.id %>
<% if conversation.sender_id == current_user.id %>
<% recipient = User.find(conversation.recipient_id) %>
<% else %>
<% recipient = User.find(conversation.sender_id) %>
<% end %>
<%= link_to recipient.email, conversation_messages_path(conversation)%>
<% end %>
<% end %>
</div>
</div>
</div>
<div class="ui segment">
<h3>All Users</h3>
<div class="ui list">
<% @users.each do |user| %>
<% if user.id != current_user.id %>
<div class="item">
<%= user.email %> <%= link_to 'Message me!', conversations_path(sender_id:
current_user.id, recipient_id: user.id), method:"post"%>
</div>
<% end %>
<% end %>
</div>
</div>
messages/index.html
<% if @over_10 %>
<%= link_to 'Show Previous', '?m=all' %>
<% end %>
<div class="ui segment">
<% @messages.each do |message| %>
<% if message.body %>
<% user = User.find(message.user_id) %>
<div class="item">
<div class="content">
<div class="header"><strong><%= user.first_name
%></strong> <%= message.message_time %></div>
<div class="list">
<div class="item">
<i class="right triangle icon"></i>
<%= message.body %>
</div>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
<%= form_for [@conversation, @message], html: {class: "ui
reply form"} do |f| %>
<div class="field">
<%= f.text_area :body, class: "form-control" %>
</div>
<%= f.text_field :user_id, value: current_user.id,
type: "hidden" %>
<div>
<%= f.submit "Add Reply", class: "ui blue labeled
submit icon button" %>
</div>
<% end %>
3