Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails ArticlesController中的ArgumentError#新建_Ruby On Rails_Ruby On Rails 3_Ruby On Rails 3.1 - Fatal编程技术网

Ruby on rails ArticlesController中的ArgumentError#新建

Ruby on rails ArticlesController中的ArgumentError#新建,ruby-on-rails,ruby-on-rails-3,ruby-on-rails-3.1,Ruby On Rails,Ruby On Rails 3,Ruby On Rails 3.1,我需要一些帮助。 该应用程序在ruby 1.8.7和rails 3.0.11下运行。 将Rails版本更新到3.1.11后,在新文章页面上出现了一个非常奇怪的错误: 然而,在控制器中,我有: class ArticlesController < ApplicationController def new @article = Article.new end 编辑2*new.html.erb: <%= form_for @article do |f| %>

我需要一些帮助。 该应用程序在ruby 1.8.7和rails 3.0.11下运行。 将Rails版本更新到3.1.11后,在新文章页面上出现了一个非常奇怪的错误:

然而,在控制器中,我有:

class ArticlesController < ApplicationController
  def new
    @article = Article.new
  end
编辑2*new.html.erb:

<%= form_for @article do |f| %>
  <%= render "shared/error_messages", :target => @article %>
  <% if admin? %>
    <p>
      <%= f.label :user_id %>
      <%= f.select :user_id,  User.authors_and_admins.collect {|p| [ p.username, p.id ] } %>
    </p>
  <% end %>
  <p>
    <%= f.label :category_id %><%= mark_required(@article, :category_id) %><br/>
    <%= f.select :category_id,  Category.all.collect {|p| [ p.name, p.id ] }, { :include_blank => true } %>
  </p>
  <p>
    <%= f.label :name %><%= mark_required(@article, :name) %><br/>
    <%= f.text_field :name %>
  </p>
  <p>
    <%= f.label :preview %><%= mark_required(@article, :preview) %><br/>
    <%= f.text_area :preview, :size => "70x6" %>
  </p>
  <p>
    <%= f.label :body %><%= mark_required(@article, :body) %><br/>
    <%= f.text_area :body, :class => "mceEditor", :size => "100x20" %>
  </p>
  <% if admin? %>
    <p>
      <%= f.label :publish_on_main %>
      <%= f.check_box :publish_on_main %>
    </p>
  <% end %>
  <%= f.submit %>
<% end %>

@第%>


真}%>



“70x6”%>


“mceEditor”,:size=>“100x20”%>


Show
Article
model。完整的跟踪也很好。我已经编辑了我的问题。你能在视图中发布你的
form_for
标签的代码吗?用表单视图更新了问题。你能在rails控制台中运行
Acticle.new
并发布完整的跟踪吗?
Started GET "/articles/new" for 127.0.0.1 at Sun May 26 18:47:43 +0400 2013
  Processing by ArticlesController#new as HTML
Completed 500 Internal Server Error in 270ms

ArgumentError (wrong number of arguments (1 for 0)):


Rendered /Users/iriskin/.rvm/gems/ree-1.8.7-2012.02@mednadom/gems/actionpack-3.1.11/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.9ms)
Rendered /Users/iriskin/.rvm/gems/ree-1.8.7-2012.02@mednadom/gems/actionpack-3.1.11/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (0.7ms)
Rendered /Users/iriskin/.rvm/gems/ree-1.8.7-2012.02@mednadom/gems/actionpack-3.1.11/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (3.4ms)
<%= form_for @article do |f| %>
  <%= render "shared/error_messages", :target => @article %>
  <% if admin? %>
    <p>
      <%= f.label :user_id %>
      <%= f.select :user_id,  User.authors_and_admins.collect {|p| [ p.username, p.id ] } %>
    </p>
  <% end %>
  <p>
    <%= f.label :category_id %><%= mark_required(@article, :category_id) %><br/>
    <%= f.select :category_id,  Category.all.collect {|p| [ p.name, p.id ] }, { :include_blank => true } %>
  </p>
  <p>
    <%= f.label :name %><%= mark_required(@article, :name) %><br/>
    <%= f.text_field :name %>
  </p>
  <p>
    <%= f.label :preview %><%= mark_required(@article, :preview) %><br/>
    <%= f.text_area :preview, :size => "70x6" %>
  </p>
  <p>
    <%= f.label :body %><%= mark_required(@article, :body) %><br/>
    <%= f.text_area :body, :class => "mceEditor", :size => "100x20" %>
  </p>
  <% if admin? %>
    <p>
      <%= f.label :publish_on_main %>
      <%= f.check_box :publish_on_main %>
    </p>
  <% end %>
  <%= f.submit %>
<% end %>