修改数据库后修复bug
This commit is contained in:
parent
87a6dd4938
commit
aed4b250a0
|
@ -37,7 +37,7 @@ class RelativeMemosController < ApplicationController
|
||||||
def show
|
def show
|
||||||
pre_count = REPLIES_PER_PAGE
|
pre_count = REPLIES_PER_PAGE
|
||||||
|
|
||||||
@memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示
|
# @memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示
|
||||||
@memo.update_column(:viewed_count_local, (@memo.viewed_count_local.to_i + 1))
|
@memo.update_column(:viewed_count_local, (@memo.viewed_count_local.to_i + 1))
|
||||||
|
|
||||||
page = params[:page]
|
page = params[:page]
|
||||||
|
@ -142,7 +142,7 @@ class RelativeMemosController < ApplicationController
|
||||||
|
|
||||||
def find_memo
|
def find_memo
|
||||||
return unless find_osp
|
return unless find_osp
|
||||||
@memo = @open_source_project.relative_memos.find(params[:id])
|
@memo = @open_source_project.topics.find(RelativeMemo.find(params[:id]).root.id)
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -12,7 +12,6 @@ class RelativeMemo < ActiveRecord::Base
|
||||||
has_many :no_uses, :as => :no_use, :dependent => :delete_all
|
has_many :no_uses, :as => :no_use, :dependent => :delete_all
|
||||||
|
|
||||||
acts_as_taggable
|
acts_as_taggable
|
||||||
acts_as_attachable
|
|
||||||
|
|
||||||
validates_presence_of :subject
|
validates_presence_of :subject
|
||||||
#validates :content, presence: true
|
#validates :content, presence: true
|
||||||
|
@ -83,6 +82,11 @@ class RelativeMemo < ActiveRecord::Base
|
||||||
:conditions => ["#{NoUse.table_name}.user_id = ?", user_id] }
|
:conditions => ["#{NoUse.table_name}.user_id = ?", user_id] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 获取帖子的回复
|
||||||
|
def replies
|
||||||
|
memos = RelativeMemo.where("parent_id = ?", id)
|
||||||
|
end
|
||||||
|
|
||||||
def no_use_for?(user)
|
def no_use_for?(user)
|
||||||
self.no_uses.each do |no_use|
|
self.no_uses.each do |no_use|
|
||||||
if no_use.user_id == user.id
|
if no_use.user_id == user.id
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
class RelativeMemoToOpenSourceProject < ActiveRecord::Base
|
class RelativeMemoToOpenSourceProject < ActiveRecord::Base
|
||||||
# attr_accessible :title, :body
|
# attr_accessible :title, :body
|
||||||
belongs_to :open_source_project, :foreign_key => "osp_id"
|
belongs_to :open_source_project, :foreign_key => "osp_id"
|
||||||
belongs_to :relative_memo, :foreign_key => 'relative_memo_id'
|
belongs_to :topic, :class_name => 'RelativeMemo', :foreign_key => 'relative_memo_id'
|
||||||
|
|
||||||
|
has_many :no_uses, :as => :no_use, :dependent => :delete_all
|
||||||
|
|
||||||
validates_presence_of :osp_id, :relative_memo_id
|
validates_presence_of :osp_id, :relative_memo_id
|
||||||
|
|
||||||
|
scope :no_use_for, lambda { |user_id|
|
||||||
|
{:include => :no_uses,
|
||||||
|
:conditions => ["#{NoUse.table_name}.user_id = ?", user_id] }
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
<td>
|
<td>
|
||||||
<table width="630px" border="0">
|
<table width="630px" border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="500px" class="<%= topic.sticky ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"><%= link_to h(topic.subject), open_source_project_relative_memo_path(topic.open_source_project, topic) %></td>
|
<td valign="top" width="500px" class="<%= topic.sticky ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"><%= link_to h(topic.subject), open_source_project_relative_memo_path(open_source_project, topic) %></td>
|
||||||
<td align="right" rowspan="3">
|
<td align="right" rowspan="3">
|
||||||
<table class="borad-count">
|
<table class="borad-count">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" class="borad-count-digit"><%= link_to (topic.replies_count), open_source_project_relative_memo_path(topic.open_source_project, topic) %></td>
|
<td align="center" class="borad-count-digit"><%= link_to (topic.replies_count), open_source_project_relative_memo_path(open_source_project, topic) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center">回答</td>
|
<td align="center">回答</td>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<td align="right" rowspan="3">
|
<td align="right" rowspan="3">
|
||||||
<table class="borad-count">
|
<table class="borad-count">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center" class="borad-count-digit"><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(topic.open_source_project, topic) %></td>
|
<td align="center" class="borad-count-digit"><%= link_to (topic.viewed_count_crawl+topic.viewed_count_local), open_source_project_relative_memo_path(open_source_project, topic) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center">浏览</td>
|
<td align="center">浏览</td>
|
||||||
|
@ -43,7 +43,8 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="left" colspan="2" ><span class="font_lighter">帖子来源:<%= link_to topic.url, topic.url%> </span></td>
|
<td align="left" colspan="2" ><span class="font_lighter">帖子来源:<%= link_to topic.url, topic.url%> </span></td>
|
||||||
<td align="left"><%= no_use_link(topic, User.current) %> </td>
|
<% relation_memo = RelativeMemoToOpenSourceProject.where("osp_id = ? and relative_memo_id = ?", open_source_project.id, topic.id).first %>
|
||||||
|
<td align="left"><%= no_use_link(relation_memo, User.current) %> </td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="left" colspan="2"> <%= image_tag( "/images/sidebar/tags.png") %>
|
<td align="left" colspan="2"> <%= image_tag( "/images/sidebar/tags.png") %>
|
||||||
|
|
|
@ -51,4 +51,4 @@
|
||||||
:title => l(:button_delete)
|
:title => l(:button_delete)
|
||||||
) if @forum.destroyable_by?(User.current) %>
|
) if @forum.destroyable_by?(User.current) %>
|
||||||
</div>
|
</div>
|
||||||
<%= render :partial => 'open_source_projects/show_topics', :locals => {:memos => @memos} %>
|
<%= render :partial => 'open_source_projects/show_topics', :locals => {:memos => @memos, :open_source_project => @open_source_project} %>
|
||||||
|
|
Loading…
Reference in New Issue