Ruby on Rails Tuesday, December 24, 2019

I'm trying to create a chat view where if the sender of the message is the current user then the message is displayed on the right side and if the sender is the other user then the message is displayed on the left So far what I have doesn't right or left float the messages, they all appear in the same column

chat.html.erb:

<div>
<h3>Conversation with <%= @conversation_with.name %>

<div id="message_holder">
    <% @messages.each do |m| %>
        <% if m.sender=@conversation_with %>
            <div><span class="left-float"><%= m.content %></span><br></div>
        <% else %>
            <div><span class="right-float"><%= m.content %></span><br></div>
        <% end %>
    <% end %>
</div>

application.scss:
   
.left-float
{
float: left;
}

.right-float
{
float: right;
}


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5cee16be-a1df-4748-b842-7bfab60c9e5c%40googlegroups.com.

No comments:

Post a Comment