完成设置博客信息的功能
This commit is contained in:
parent
812c8bc9ff
commit
5e5310bc93
|
@ -1,6 +1,7 @@
|
||||||
#encoding: utf-8
|
#encoding: utf-8
|
||||||
class BlogsController < ApplicationController
|
class BlogsController < ApplicationController
|
||||||
before_filter :require_login, only: [:set, :set_userinfo, :upload_img, :set_blog, :update_blog, :change_password, :update_password]
|
before_filter :require_login, only: [:set, :set_userinfo, :upload_img, :set_blog, :update_blog, :change_password, :update_password]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@articles = Article.order('updated_at desc').limit(10)
|
@articles = Article.order('updated_at desc').limit(10)
|
||||||
@new_comments = ArticleComment.order('updated_at desc').limit(10)
|
@new_comments = ArticleComment.order('updated_at desc').limit(10)
|
||||||
|
@ -37,7 +38,19 @@ class BlogsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_blog
|
def update_blog
|
||||||
|
param_hash = params.require(:blog).permit(:name, :blog_title, :email, :description)
|
||||||
|
@blog = BlogInfo.first
|
||||||
|
if @blog.present?
|
||||||
|
result = @blog.update_attributes param_hash
|
||||||
|
else
|
||||||
|
@blog = BlogInfo.new param_hash
|
||||||
|
result = @blog.save
|
||||||
|
end
|
||||||
|
if result
|
||||||
|
redirect_to set_blogs_path
|
||||||
|
else
|
||||||
|
render 'set_blog'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def about
|
def about
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
.row
|
||||||
|
%h3.set_title 设置
|
||||||
|
= render 'set_sidebar', obj: @blog
|
||||||
|
.col-md-8
|
||||||
|
= form_for @blog, as: 'blog', url: update_blog_blogs_path, method: 'post', role: 'form' do |f|
|
||||||
|
.form-group
|
||||||
|
%label{for: 'blog_name'} 博主
|
||||||
|
= f.text_field :name, placeholder: '博主名称', class: 'form-control'
|
||||||
|
.form-group
|
||||||
|
%label{for: 'blog_blog_title'} 博客名字
|
||||||
|
= f.text_field :blog_title, placeholder: '博客名称', class: 'form-control'
|
||||||
|
.form-group
|
||||||
|
%label{for: 'blog_email'} 联系邮箱
|
||||||
|
= f.text_field :email, placeholder: '联系邮箱', class: 'form-control'
|
||||||
|
.form-group
|
||||||
|
%label{for: 'blog_description'} 关于博主
|
||||||
|
= f.text_area :description, placeholder: '关于博主', class: 'form-control blog-description'
|
||||||
|
.form-group
|
||||||
|
= f.submit '修改', class: 'btn btn-primary set-btn'
|
Loading…
Reference in New Issue