On 11/26/05, Kaushik G. email@example.com wrote:
Oh you be good Peter!
Yes, that worked. Thanks for your prompt replies. Adding
<% @notes = Note.find(:all) %>
I think the view is not the best place to put this. You want this in
edit action (not view). Even if you do want it in your view try this in
your usual edit action code
add this line
@notes = Note.find(:all)
I’m still not sure why, though, since this code is not there in
list.rhtml and list still works
because “@notes = Note.find(:all)” is in the list action (not view).
for it. Find it. Scaffold put it there didn’t it? It doesn’t matter if
write the code or scaffold writes the code for you. In either case
has to be filled. Rails doesn’t fill it for you magically. Somewhere
When you had the nil error it was because Rails had never seen @notes
and yet you still try to iterate over it. You have to tell Rails to fill
@notes in the edit action if you want to use @notes in the edit view.
Instance variable in an action are available in the associated view.
I hope this makes more sense.