2012-08-14 29 views
0

我剛剛在ubunutu/nginx/postgres上安裝了redmine,創建新項目時出現此錯誤...任何想法? (我是新來的紅寶石因此不能真正告訴它要發生)創建新項目時redmine或ruby 500內部錯誤:undefined local variable

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' 

從管理平臺/應用/模型/ 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 
+0

的錯誤是在項目模型'應用程序/模型/ project.rb:333:在「allowed_pa​​rents'' 你可以請粘貼項目模型這裏? – 2012-08-14 10:47:48

+0

謝謝!!!因爲這裏沒有太多允許的字符,所以不要粘貼上面的代碼片段。 – petergus 2012-08-14 11:46:09

回答

0

沒有函數調用self_and_descendants爲您的項目模型已經宣佈。

使用self.descendants

退房此鏈接Class descendants

+0

aha ... hm,以及我剛纔註釋掉的那一行,並且我到達了頁面我可以創建項目,但是在保存新項目時又出現錯誤。 #@ allowed_pa​​rents = @allowed_pa​​rents - self_and_descendants – petergus 2012-08-14 12:45:11

+0

您對視圖文件或模型中發生錯誤的地方有何評論。正如你所說,你仍然得到錯誤,那麼你必須評論視圖文件行。該錯誤不在您的視圖中。 – 2012-08-14 12:53:54

+0

in project.rb:333 它做了一些事情,我能夠看到頁面創建一個新項目,然後在保存新項目時出現新錯誤: NameError(未定義的局部變量或方法'store_new_parent'for#): app/controllers/projects_controller.rb:79:在'create'--- 讓我覺得正確的路線不是評論事情。奇怪的是,這是redmine的全新安裝。 – petergus 2012-08-14 13:05:35