# HG changeset patch # User luisf # Date 1376925804 -3600 # Node ID 7e85f7988ab83180bbaa8c175fdc95233e229c5b # Parent 72b6d7a2383d3c969fabfbe6f3df82cea623a191 Fixes another possible cause for Bug #658 - was not saving publication when author was new... diff -r 72b6d7a2383d -r 7e85f7988ab8 plugins/redmine_bibliography/app/models/authorship.rb --- a/plugins/redmine_bibliography/app/models/authorship.rb Mon Aug 19 16:05:50 2013 +0100 +++ b/plugins/redmine_bibliography/app/models/authorship.rb Mon Aug 19 16:23:24 2013 +0100 @@ -47,31 +47,37 @@ protected def associate_author_user + + logger.error { "search_author_class '#{self.search_author_class}'" } + case self.search_author_class - when "User" - author = Author.new - author.save - self.author_id = author.id + when "" + logger.debug { "Unknown Author to be added..." } + when "User" + author = Author.new + author.save + self.author_id = author.id + + when "Author" + selected = self.search_results + selected_classname = Kernel.const_get(self.search_author_class) + selected_id = self.search_author_id + object = selected_classname.find(selected_id) + + if object.respond_to? :name_on_paper + # Authorship + self.author_id = object.author.id else - selected = self.search_results - selected_classname = Kernel.const_get(self.search_author_class) - selected_id = self.search_author_id - object = selected_classname.find(selected_id) - - if object.respond_to? :name_on_paper - # Authorship + # User + unless object.author.nil? self.author_id = object.author.id else - # User - unless object.author.nil? - self.author_id = object.author.id - else - author = Author.new - object.author = author - object.save - self.author_id = object.author.id - end + author = Author.new + object.author = author + object.save + self.author_id = object.author.id end + end end end end