I've been trying to figure out how to pass a variable between two views and I've looked at all the examples on stack overflow and I can't seem to make it work.
I have this in my users -> index.html.erb
<% @users.each do |user| %>
<tr>
<td><%= user.name %></td>
<td><%= user.email %></td>
<td><%= user.id %></td>
<td><%= link_to 'Profile', user %></td>
<td><%= link_to 'Connect', new_relationship_path, :id => user.id %><td>
</tr>
<% end %>
I'm trying to pass user.id to my relationships -> new.html.erb view.
in my controller I have:
class RelationshipsController < ApplicationController
def new
@id = params[:id]
end
end
and finially I have relationships -> new.html.erb
<section id="main">
<h1>Sign Up</h1>
<td><%= @id %></td>
</section>
I believe :id isn't being passed correctly. What am I missing from all the other examples? I get no errors, just nothing is displayed.