<ul id = "subjects">
<% Subject.find(:all).each do |c| %>
<li><%= link_to c.name, :action => "show_subjects", :id => c.id %></li>
<% end %>
I have a code snippet in my list.html.erb file. It raises an exception 'Couldn't find Subject with 'id'=all'. What's the problem in this case? The thing I want to do is to list all subjects as the hyperlinks.
Thanks for help.Answer1:
The problem is you're using code that is ancient. Replace it with either of those two.
Subject.all.each do ...
Subject.find_each do ...
Explanation for error is that
find automatically searches by id and
:all is not a valid
id and so it can't find anything and raises and exception.