Buenas tardes, pido perdón de antemano por si cometo errores tontos, es que
soy bastante nuevo en esto.
El tema es asi, tengo el siguiente metodo:
______________________________________________
def current_degree
current_date = degree_changes.find(:first, :select => 'max(date) as
max').max
change = degree_changes.where(:date => current_date).first
change.degree
end
__________________________________________
y en la vista quiero mostrarlo:
.....
<% @students.each do |student| %>
<tr>
<td><%= student.surname %></td>
<td><%= student.name %></td>
<td><%= student.current_degree %></td>
.........
__________________________________________
Pero me da el siguiente error:
undefined method `degree' for nil:NilClass
Extracted source (around line *#25*):
22: <tr>
23: <td><%= student.surname %></td>
24: <td><%= student.name %></td>
25: <td><%= student.current_degree %></td>
26: <td><%= student.birthday %></td>
27: <td><%= student.dni %></td>
28: <td><%= student.phone_number %></td>
_____________________________________________________
Tengo las clases relacionadas con has_many y belongs_to
tambien lo probe mediante una consola(rails c)
que podra ser?
salud!!!
poli
_______________________________________________
Ruby mailing list
[email protected]
http://lista.rubyargentina.com.ar/listinfo.cgi/ruby-rubyargentina.com.ar