Form_for在new.html.erb文件中存在问题

时间:2014-01-18 21:51:23

标签: ruby-on-rails

正在发生的事情是我在localhost:3000中获得“形式中的第一个参数不能包含nil或为空”。这是我的代码:

def new
    @article=Article.new  

为控制器。 对于new.html.erb

<h1> Index </h1>

<%=form_for @article do |f| %>
<p><%=f.label :title %>:<%= f.text_field :title %></p>
<p><%=f.label :body %>:<%= f.text_area :body %></p>
<p><%=f.submit "Add article" %></p>
<% end %> 

0 个答案:

没有答案
相关问题