10%
This commit is contained in:
parent
6e1913d00d
commit
c6f4dbbafa
|
@ -10,7 +10,7 @@ class MemosController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@memo = Memo.find(params[:id])
|
@memo = Memo.find_by_id(params[:id])
|
||||||
@replies = @memo.replies
|
@replies = @memo.replies
|
||||||
@mome_new = Memo.new
|
@mome_new = Memo.new
|
||||||
|
|
||||||
|
@ -26,16 +26,18 @@ class MemosController < ApplicationController
|
||||||
@memo.author_id = User.current.id
|
@memo.author_id = User.current.id
|
||||||
|
|
||||||
if @memo.parent_id
|
if @memo.parent_id
|
||||||
@back_memo_id ||= @memo.parent_id
|
|
||||||
@parent_memo = Memo.find_by_id(@memo.parent_id)
|
@parent_memo = Memo.find_by_id(@memo.parent_id)
|
||||||
@parent_memo.replies_count += 1
|
@parent_memo.replies_count += 1
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @memo.save
|
if @memo.save
|
||||||
@back_memo_id = @memo.id
|
@back_memo_id = (@memo.parent_id.nil? ? @memo.id : @memo.parent_id)
|
||||||
@parent_memo.last_reply_id = @memo.id if @parent_memo
|
if @parent_memo
|
||||||
@parent_memo.save if @parent_memo
|
@parent_memo.last_reply_id = @memo.id
|
||||||
|
@parent_memo.save
|
||||||
|
end
|
||||||
|
|
||||||
format.html { redirect_to forum_memo_path(@memo.forum_id, @back_memo_id), notice: 'Memo was successfully created.' }
|
format.html { redirect_to forum_memo_path(@memo.forum_id, @back_memo_id), notice: 'Memo was successfully created.' }
|
||||||
format.json { render json: @memo, status: :created, location: @memo }
|
format.json { render json: @memo, status: :created, location: @memo }
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<!-- <p id="notice">
|
<!-- <p id="notice">
|
||||||
< %= notice %>
|
< %= notice %>
|
||||||
</p> -->
|
</p> -->
|
||||||
<ul class="lz" style="background:red" >
|
<ul class="lz" style="background:grey" >
|
||||||
<!-- <li class="title">title ==> <%= link_to @memo.subject, forum_memo_path(@memo) %></li>
|
<!-- <li class="title">title ==> <%= link_to @memo.subject, forum_memo_path(@memo) %></li>
|
||||||
<li class="content">content ==> <%= @memo.content %></li>
|
<li class="content">content ==> <%= @memo.content %></li>
|
||||||
<li class="author">author ==> <%= @memo.author %></li>
|
<li class="author">author ==> <%= @memo.author %></li>
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<hr/>
|
<h3 class="comments"><%= l(:label_reply_plural) %> (<%= @replies.nil? ? 0 : @replies.size %>)</h3>
|
||||||
|
|
||||||
<div class="replies">
|
<div class="replies">
|
||||||
<% @replies.each do |reply| %>
|
<% @replies.each do |reply| %>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
image_tag('edit.png'),
|
image_tag('edit.png'),
|
||||||
{:action => 'edit', :id => reply},
|
{:action => 'edit', :id => reply},
|
||||||
:title => l(:button_edit)
|
:title => l(:button_edit)
|
||||||
) if reply.editable_by?(User.current) %>
|
) if reply.destroyable_by?(User.current) %>
|
||||||
<%= link_to(
|
<%= link_to(
|
||||||
image_tag('delete.png'),
|
image_tag('delete.png'),
|
||||||
{:action => 'destroy', :id => reply},
|
{:action => 'destroy', :id => reply},
|
||||||
|
|
|
@ -439,7 +439,7 @@ ActiveRecord::Schema.define(:version => 20131122132942) do
|
||||||
t.string "subject", :null => false
|
t.string "subject", :null => false
|
||||||
t.text "content", :null => false
|
t.text "content", :null => false
|
||||||
t.integer "author_id", :null => false
|
t.integer "author_id", :null => false
|
||||||
t.integer "replies_count"
|
t.integer "replies_count", :default => 0
|
||||||
t.integer "last_reply_id"
|
t.integer "last_reply_id"
|
||||||
t.boolean "lock", :default => false
|
t.boolean "lock", :default => false
|
||||||
t.boolean "sticky", :default => false
|
t.boolean "sticky", :default => false
|
||||||
|
|
Loading…
Reference in New Issue