Mercurial > hg > soundsoftware-site
view vendor/plugins/redmine_bibliography/app/models/authorship.rb @ 557:2fe129b04d82 feature_36
Fixes Bug #222.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Wed, 03 Aug 2011 16:09:27 +0100 |
parents | ce1614b19759 |
children | 82a6e3756383 |
line wrap: on
line source
class Authorship < ActiveRecord::Base belongs_to :author belongs_to :publication accepts_nested_attributes_for :author accepts_nested_attributes_for :publication # setter and getter for virtual attribute :user_id def user_id end def user_id=(uid) unless uid.blank? user = User.find(uid) if user.author.nil? # TODO: should reflect the name_on_paper parameter author = Author.new :name => user.name author.save! user.author = author user.save! end self.author_id = user.author.id end end end