From 86829597b62980acf7bb8ae7f819e7aba6a7250f Mon Sep 17 00:00:00 2001 From: William Schey Date: Thu, 6 Feb 2014 19:35:42 +1000 Subject: [PATCH] fixes "undefined method `id' for nil:NilClass: searching model "dmsf_files"" seems sometimes dmsf_file.project is nil --- app/models/dmsf_file.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index a33ca3c7..898e4977 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -353,7 +353,11 @@ class DmsfFile < ActiveRecord::Base if x.is_a?(ActiveRecord::Relation) project_included = x.first.id == dmsf_file.project.id else - project_included = x[:id] == dmsf_file.project.id + if dmsf_file.project + project_included = x[:id] == dmsf_file.project.id + else + project_included = false + end end end end