Mercurial > hg > soundsoftware-site
view vendor/plugins/redmine_bibliography/app/models/authorship.rb @ 546:7c4b96efa402 feature_36
Closes Feature #240 (adding a new publication from the project's main page).
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Fri, 29 Jul 2011 18:14:28 +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