I have a link that takes an id of a user. This is kept in a div called NameID. The controller etc is all set up correctly but all I need to do is to be able to pass the NameID.innerHTML (which is a number) as the number that people.id represents. How can I do this?
index.html.erb (graph not shown)
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-4">
<p><a class="btn btn-lg btn-primary" id="BtnMessageNode" href="/messages/new">Start conversation</a></p>
<h2>NameID of Node</h2>
<div id="NameID_Div"></div>
</div>
</div>
</div>
</div>
</div>
<% page_header "Users" %>
<ul>
<% @peoples.each do |people| %>
<li>
<strong><%= people.name %></strong>
<% unless current_user == people %>
<%= link_to 'Send message', new_message_path(to: people.id), class: 'btn btn-default btn-sm' %>
<% end %>
</li>
<% end %>
</ul>
messages_controller.rb
class MessagesController < ApplicationController
before_action :authenticate_user!
def new
@chosen_recipient = User.find_by(id: params[:to].to_i) if params[:to]
end
def create
recipients = User.where(id: params['recipients'])
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