I made those changes, but I am still getting this error: "You have a nil
object when you didn't expect it!"
It is pointing to the line with the loop:
<% @results.each do |result|
My model look like this:
class Author < ActiveRecord::Base
has_many :books
def author_age
@results = Author.find :all, :conditions => ["age = ?",
params[:authors]]
end
end
I have this in view\authors\show.html
<tr>
<td width="20%"><p align="center"><i><b>Author Name</b></i></td>
<td width="20%"><p align="center"><i><b>Age</b></i></td>
</tr>
<% @results.each do |result| %> // It is flagging this line.
<tr>
<td><%=h result.name %></td>
<td><%=h result.age %></td>
</tr>
<% end %>
Is something wrong with the private method in the model or something
else?
Please help.
Cypray
Thorsten Mueller wrote:
> <% @results.each do |result| %> // I am not sure if this is right!
>
> <tr>
>
> <td><%=h @result.name %></td>
> <td><%=h @result.age %></td>
> </tr>
>
> should be
>
> <% @results.each do |result| %> // I am not sure if this is right!
>
> <tr>
>
> <td><%=h result.name %></td>
> <td><%=h result.age %></td>
> </tr>
> <% end %>
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---