0

我正在尝试在 user_controller 的索引操作上显示所有 @user.notes,并在下面提供一个表单来添加新的注释,内联。我从一些教程中收集到的非常简单的代码,但发生的事情是我的观点完全重复了。它吐出相同 html 的 2 个副本。Rails 还是很新的,所以我很难调试这个。使用haml,仅供参考。

这是我的简单代码:

# 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它不再重复的块。如果您需要查看控制器代码或任何内容,请告诉我。

谢谢。

4

1 回答 1

4

它应该是

- remote_form_for

不是

= remote_form_for
于 2009-08-01T20:29:49.723 回答