0
我試圖在我的user_controller的索引操作上顯示所有@ user.notes,並提供了一個表單來添加一個新的註釋,內聯。非常簡單的代碼,我從一些教程中收集,但發生了什麼事情是我的觀點完全重複。它吐出2份相同的html。對於rails還是很新的,所以我很難調試它。使用haml,fyi。Rails複製視圖
這裏是我的簡單的代碼:
# views/users/index.html.haml
%p
Hi, #{@user.username}.
%h3#notes Notes
= render :partial => 'notes', :locals => {:notes => @user.notes}
%h3 Add Note
= remote_form_for([@user, @note]) do |f|
= f.error_messages
%ol.formList
%li
= f.label :body, "Note"
= f.text_field :body
%li
= f.submit 'Add Note'
不知道如果這是造成它的代碼。如果我刪除remote_form_for
塊,它不會重複。讓我知道你是否需要查看控制器代碼或任何東西。
謝謝。
看到控制器的代碼可以幫助幫助您。謝謝 – marcgg 2009-08-01 20:23:53