This commit is contained in:
ahinz 2014-12-11 15:56:40 +01:00
parent 3452a81971
commit 467545c85a
2 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,8 @@
class Article < ActiveRecord::Base
belongs_to :user, :foreign_key => 'created_by'
before_create :b_create
before_update :b_update
before_destroy :b_destroy
def b_create
@ -12,7 +13,7 @@ class Article < ActiveRecord::Base
#ToDo destroy comments
end
def self.created
"#{self.email} (#{self.created_at})"
def created
"#{self.user.email} (#{self.created_at})"
end
end

View File

@ -1,4 +1,6 @@
class User < ActiveRecord::Base
has_many :articles, :foreign_key => 'created_by'
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,