0

我刚刚在 ubunutu/nginx/postgres 上安装了 redmine,在创建新项目时出现此错误......有什么想法吗?(我是红宝石的新手,所以不能真正说出它想要发生的事情)

Started GET "/projects/new" for 50.116.19.7 at Tue Aug 14 08:31:52 +0200 2012
Processing by ProjectsController#new as HTML
  Rendered projects/_form.html.erb (4.2ms)
  Rendered projects/new.html.erb within layouts/base (6.0ms)
Completed 500 Internal Server Error in 131ms

ActionView::Template::Error (undefined local variable or method `self_and_descendants' for #<Project:0xb490ca54>):
    4: <!--[form:project]-->
    5: <p><%= f.text_field :name, :required => true, :size => 60 %></p>
    6: 
    7: <% unless @project.allowed_parents.compact.empty? %>
    8:     <p><%= label(:project, :parent_id, l(:field_parent)) %><%= parent_project_select_tag(@project) %></p>
    9: <% end %>
    10: 
  app/models/project.rb:333:in 'allowed_parents'
  app/views/projects/_form.html.erb:7:in
'_app_views_projects__form_html_erb___577557764__627958918'
  app/views/projects/new.html.erb:4:in     '_app_views_projects_new_html_erb___126828522__630632748'
  app/helpers/application_helper.rb:950:in `labelled_form_for'
  app/views/projects/new.html.erb:3:in     '_app_views_projects_new_html_erb___126828522__630632748'

来自 redmine/app/models/project.rb (抱歉,似乎无法弄清楚如何将格式代码设置为在此处显示

# Returns an array of projects the project can be moved to
   # by the current user
  def allowed_parents
    return @allowed_parents if @allowed_parents
    @allowed_parents = Project.find(:all, :conditions =>        Project.allowed_to_condition(User.current, :add_subprojects))
    @allowed_parents = @allowed_parents - self_and_descendants
    if User.current.allowed_to?(:add_project, nil, :global => true) || (!new_record? && parent.nil?)
  @allowed_parents << nil
end
unless parent.nil? || @allowed_parents.empty? || @allowed_parents.include?(parent)
  @allowed_parents << parent
end
@allowed_parents
  end

  # Sets the parent of the project with authorization check
  def set_allowed_parent!(p)
    unless p.nil? || p.is_a?(Project)
      if p.to_s.blank?
        p = nil
      else
        p = Project.find_by_id(p)
     return false unless p
  end
end
if p.nil?
  if !new_record? && allowed_parents.empty?
    return false
  end
elsif !allowed_parents.include?(p)
  return false
                                                                                            334,5         35%
elsif !allowed_parents.include?(p)
  return false
end
set_parent!(p)
  end
4

1 回答 1

0

正如您在项目模型中声明的那样,没有函数调用 self_and_descendants。

使用 self.descendants

查看此链接类后代

于 2012-08-14T12:08:41.253 回答