解决blog删除、blog回复500问题
This commit is contained in:
parent
0a0b3fbf9b
commit
5a961c8ee7
|
@ -177,8 +177,7 @@ class BlogCommentsController < ApplicationController
|
|||
reply_user_id = params[:reply_id].nil? ? @blogComment.blog.author_id: params[:reply_id].to_i
|
||||
# 回复的作业与评论的作者不是同一人则发送消息
|
||||
if ( params[:reply_id].nil? && @blogComment.author.id != @blogComment.blog.author_id )|| (!params[:reply_id].nil? && @blogComment.author.id != params[:reply_id].to_i)
|
||||
BlogMessage.create(:user_id => reply_user_id, :blog_id => params[:blog_id].to_i, :content => params[:blog_comment][:content],
|
||||
:blog_commont_id => @blogComment.id, :blog_message_type => "BlogComment", :user_operator_id => @blogComment.author.id)
|
||||
BlogMessage.create(:user_id => reply_user_id, :blog_id => params[:blog_id].to_i, :content => params[:blog_comment][:content],:blog_message_id => @blogComment.id, :blog_message_type => "BlogComment", :user_operator_id => @blogComment.author.id)
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
|
|
|
@ -394,7 +394,7 @@ class UsersController < ApplicationController
|
|||
# 评论后,给回复人发消息(如果是本人就不发)
|
||||
if comment.author.id != BlogComment.find(comment.reply_id).author_id
|
||||
BlogMessage.create(:user_id => BlogComment.find(comment.reply_id).author_id,
|
||||
:blog_commont_id => comment.id,
|
||||
:blog_message_id => comment.id,
|
||||
:blog_id => comment.blog_id,
|
||||
:blog_message_type => "BlogComment",
|
||||
:content => comment.content,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class BlogMessage < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
attr_accessible :content, :blog_commont_id, :blog_message_type, :viewed, :user_id, :blog_id, :user_operator_id
|
||||
attr_accessible :content, :blog_message_id, :blog_message_type, :viewed, :user_id, :blog_id, :user_operator_id
|
||||
|
||||
belongs_to :blog_comment ,:polymorphic => true
|
||||
belongs_to :user
|
||||
|
@ -8,7 +8,7 @@ class BlogMessage < ActiveRecord::Base
|
|||
|
||||
validates :user_id, presence: true
|
||||
validates :blog_id, presence: true
|
||||
validates :blog_commont_id, presence: true
|
||||
validates :blog_message_id, presence: true
|
||||
validates :blog_message_type, presence: true
|
||||
after_create :add_user_message
|
||||
|
||||
|
|
|
@ -23,7 +23,10 @@
|
|||
<% end %>
|
||||
|
||||
<%# 博客消息 %>
|
||||
<%= render :partial => 'users/user_message_blog', :locals => {:ma => ma} %>
|
||||
<% if ma.class == BlogMessage %>
|
||||
<%= render :partial => 'users/user_message_blog', :locals => {:ma => ma} %>
|
||||
<% end %>
|
||||
|
||||
<!--公共贴吧-->
|
||||
<% if ma.class == MemoMessage %>
|
||||
<%= render :partial => 'users/user_message_forum', :locals => {:ma => ma} %>
|
||||
|
|
|
@ -1,22 +1,20 @@
|
|||
<% if ma.class == BlogMessage %>
|
||||
<% if ma.blog_message_type == "BlogComment" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<div class="longMessageWidth">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<%= link_to image_tag(url_to_avatar(User.find(ma.user_operator_id)), :width => "30", :height => "30"), user_path(ma.user_operator_id), :target => '_blank' %>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%= link_to User.find(ma.user_operator_id).show_name, user_path(ma.user_operator_id), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
|
||||
<span class="homepageNewsType fl">回复了博客:</span>
|
||||
</li>
|
||||
<li class="messageInformationContents">
|
||||
<% user_id = User.find(BlogComment.find(ma.blog_commont_id).blog.author_id) %>
|
||||
<% blog_id = BlogComment.find(ma.blog_commont_id).root_id %>
|
||||
<%= link_to message_content(ma.content), user_blog_blog_comment_path(:user_id => user_id, :blog_id => ma.blog_id, :id => blog_id),
|
||||
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
|
||||
</li>
|
||||
</div>
|
||||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if ma.blog_message_type == "BlogComment" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<div class="longMessageWidth">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<%= link_to image_tag(url_to_avatar(User.find(ma.user_operator_id)), :width => "30", :height => "30"), user_path(ma.user_operator_id), :target => '_blank' %>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%= link_to User.find(ma.user_operator_id).show_name, user_path(ma.user_operator_id), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
|
||||
<span class="homepageNewsType fl">回复了博客:</span>
|
||||
</li>
|
||||
<li class="messageInformationContents">
|
||||
<% user_id = User.find(BlogComment.find(ma.blog_commont_id).blog.author_id) %>
|
||||
<% blog_id = BlogComment.find(ma.blog_commont_id).root_id %>
|
||||
<%= link_to message_content(ma.content), user_blog_blog_comment_path(:user_id => user_id, :blog_id => ma.blog_id, :id => blog_id),
|
||||
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
|
||||
</li>
|
||||
</div>
|
||||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
class RenameBlogMessage < ActiveRecord::Migration
|
||||
def up
|
||||
rename_column :blog_messages, :blog_commont_id, :blog_message_id
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20170119072629) do
|
||||
ActiveRecord::Schema.define(:version => 20170119084215) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -280,7 +280,7 @@ ActiveRecord::Schema.define(:version => 20170119072629) do
|
|||
|
||||
create_table "blog_messages", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "blog_commont_id"
|
||||
t.integer "blog_message_id"
|
||||
t.integer "blog_id"
|
||||
t.string "blog_message_type"
|
||||
t.boolean "viewed", :default => false
|
||||
|
|
Loading…
Reference in New Issue