Soy nuevo en Rails y lo intento por mucho tiempo. Estoy siguiendo el tutorial para crear una función de chat simple para rieles https://medium.com/@carly_l/how-to-build-a-simple-chat-messaging-system-in-rails-2958efcea047 , y cada vez que hago clic nuevo mensaje no está enrutando correctamente.
conversaciones.index.html.erb
<h3>Mailbox</h3>
<% @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.first_name, conversation_messages_path(conversation)%>
<% end %>
<% end %>
</div>
</div>
Todos los usuarios
<% @users.each do |user| %>
<% if user.id != current_user.id %>
<div class="item">
<%= user.first_name %> <%= link_to 'Message me!', conversations_path(sender_id: current_user.id, recipient_id: user.id), method: 'post'%>
</div>
<% end %>
<% end %>
**índice de conversaciones**
@users = User.all
@conversations = Conversation.all
función de creación de conversaciones
def create
byebug
@user = current_user
if Conversation.between(params[:sender_id],params[:recipient_id]).present?
@conversation = Conversation.between(params[:sender_id], params[:recipient_id]).first
else
@conversation = Conversation.create!(conversation_params)
end
redirect_to conversation_messages_path(@conversation)
end
**rutas.rb **
resources :conversations do
resources :messages
end
cuando hago clic en enviarme un mensaje, la ruta es
http://localhost:3000/conversations?recipient_id=1&sender_id=6
y no hace nada