First argument in form cannot contain nil or be empty - Rails 4

前端 未结 7 1736
刺人心
刺人心 2020-12-04 19:24

I receive this error with my contact form in rails:

First argument in form cannot contain nil or be empty

View:

7条回答
  •  独厮守ぢ
    2020-12-04 20:13

    I had the same problem. I have a Comment model, a CommentsController, a 'show' action and a 'show' view for the comment. I also have a '_show' partial rendered inside the 'show' view with following local:

    :locals => {:comment => @comment}
    

    and inside the '_show' partial I have a

    <%= form_for(comment, :remote => true) do |f| %>
    

    which troughs the "First argument in form cannot contain nil or be empty". I only could solve the problem by renaming the local:

    :locals => {:new_comment => @comment}
    

    and within the partial:

    <%= form_for(new_comment, :remote => true) do |f| %>
    

    It seems using the same name for the Model and the partial local caused some conflict for me.

提交回复
热议问题