名字为空的用户创建博客时博客名称为登录名

This commit is contained in:
cxt 2015-10-30 09:56:55 +08:00
parent b0aee8c92f
commit c4816a0414
1 changed files with 1 additions and 1 deletions

View File

@ -260,7 +260,7 @@ class User < Principal
@blog = Blog.where("author_id = #{self.id}").all[0]
if @blog.nil?
#如果某个user的blog不存在那么就创建一条并且跳转
@blog = Blog.create(:name=>(User.find(self.id).realname),
@blog = Blog.create(:name=>(User.find(self.id).realname.blank? ? User.find(self.id).login : User.find(self.id).realname ),
:description=>'',
:author_id=>self.id)
@blog.save