and thanks for Help!!
I´m Building my fisrt Rails app, and have this problem:
I made an Scaffold for a Class called “Expediente”, from the index.html.erb I can gain acces over @expedientes but I cant do it from new.html.erb.
Here´s the code:
//index.html.erb, this run great:
.
.
.
<% @expedientes.each do |expediente| %>
<tr>
<td class="custom"> <%= expediente.id %> </td>
<td class="custom"> <%= expediente.tipo_expediente %> </td>
<td class="custom">
<% expediente.pacientes.each do |paciente| %>
<%= paciente.nombre_completo %><br/>
<% end %>
.
.
.
//new.html.erb, this doesnt works at all and sends undefined method `each’ for nil:NilClass error message:
.
.
.
<% @expedientes.each do |expediente| %>
<%if expediente.individual?%>
<% expediente.pacientes.each do |paciente| %>
<option value=126><%= paciente.nombre_completo %></option>
<%end%>
<%end%>
<%end%>
.
.
.
Again thanks fot your Help!!
Because the index action in your ExpedientesController (which renders the index.html.erb view) defines the variable
@expedientes, but your new action (which renders the new.html.erb view) does not.