This commit is contained in:
parent
3452a81971
commit
467545c85a
|
|
@ -1,7 +1,8 @@
|
||||||
class Article < ActiveRecord::Base
|
class Article < ActiveRecord::Base
|
||||||
|
|
||||||
|
belongs_to :user, :foreign_key => 'created_by'
|
||||||
|
|
||||||
before_create :b_create
|
before_create :b_create
|
||||||
before_update :b_update
|
|
||||||
before_destroy :b_destroy
|
before_destroy :b_destroy
|
||||||
|
|
||||||
def b_create
|
def b_create
|
||||||
|
|
@ -12,7 +13,7 @@ class Article < ActiveRecord::Base
|
||||||
#ToDo destroy comments
|
#ToDo destroy comments
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.created
|
def created
|
||||||
"#{self.email} (#{self.created_at})"
|
"#{self.user.email} (#{self.created_at})"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
class User < ActiveRecord::Base
|
class User < ActiveRecord::Base
|
||||||
|
|
||||||
|
has_many :articles, :foreign_key => 'created_by'
|
||||||
# Include default devise modules. Others available are:
|
# Include default devise modules. Others available are:
|
||||||
# :confirmable, :lockable, :timeoutable and :omniauthable
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue