ruby on rails - "Couldn't find User without an ID" accessing related model -


updated issue:

i trying access id instance of class , use instance. here context:

  <% @affinity.each |a| %>     <tr>       <td><%= a.user_a_id %></td>       <td><%= user.find(a.user_a_id).nickname %></td>       <td><%= a.user_b_id %></td>       <td><%= user.find(a.user_b_id).nickname %></td>       ... 

each affinity has variable called user_a_id , user_b_id, represent ids of users , b. want use these ids able access instances of user , user b, , subsequently nickname of each. how can this?

i error:

couldn't find user without id 

thanks!

if have correct relations defined, can access users directly:

<%= a.user_a.nickname %> 

and btw, shouldn't have convert ids symbols make code work, , have used user.find(a.user_a_id) since where returns array , find returns object if found.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -