From 060da59bbb0a31c8277da871bdd186a070113c51 Mon Sep 17 00:00:00 2001 From: zmagod Date: Thu, 11 Aug 2016 09:19:12 +0200 Subject: [PATCH] fixes migration error --- app/models/experiment.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/models/experiment.rb b/app/models/experiment.rb index b3b35f165..fbf861cc4 100644 --- a/app/models/experiment.rb +++ b/app/models/experiment.rb @@ -1,11 +1,10 @@ -require 'graphviz' - class Experiment < ActiveRecord::Base include ArchivableModel, SearchableModel belongs_to :project, inverse_of: :experiments belongs_to :created_by, foreign_key: :created_by_id, class_name: 'User' - belongs_to :last_modified_by, foreign_key: :last_modified_by_id, class_name: 'User' + belongs_to :last_modified_by, foreign_key: :last_modified_by_id, + class_name: 'User' belongs_to :archived_by, foreign_key: :archived_by_id, class_name: 'User' belongs_to :restored_by, foreign_key: :restored_by_id, class_name: 'User' @@ -15,7 +14,8 @@ class Experiment < ActiveRecord::Base has_attached_file :workflowimg validates_attachment :workflowimg, - content_type: { content_type: ["image/png"] } + content_type: { content_type: ['image/png'] }, + if: :workflowimg_check validates :name, presence: true, @@ -204,6 +204,8 @@ class Experiment < ActiveRecord::Base # This method generate the workflow image and saves it as # experiment attachment def generate_workflow_img + require 'graphviz' + graph = GraphViz.new(:G, type: :digraph, use: :neato) @@ -611,4 +613,10 @@ class Experiment < ActiveRecord::Base my_module_groups.reload true end + + def workflowimg_check + workflowimg_content_type + rescue + false + end end