memo controller.

This commit is contained in:
yanxd 2013-11-25 15:05:42 +08:00
parent 0a88d16a7d
commit 8218fde509
1 changed files with 35 additions and 3 deletions

View File

@ -1,19 +1,51 @@
class MemosController < ApplicationController
layout 'base_memos'
layout 'base_memos' ,except: [:new ]
def new
@forum = Forum.find(params[:forum_id])
@memo = Memo.new
@memo.forum_id = @forum.id
respond_to do |format|
format.html # new.html.erb
format.html {
render action: :new ,layout: 'base'
}# new.html.erb
format.json { render json: @memo }
end
end
def show
# @offset, @limit = api_offset_and_limit({:limit => 10})
# @forum = Forum.find(params[:id])
# @memos_all = @forum.topics
# @topic_count = @memos_all.count
# @topic_pages = Paginator.new @topic_count, @limit, params['page']
# @offset ||= @topic_pages.offset
# @memos = @memos_all.offset(@offset).limit(@limit).all
# respond_to do |format|
# format.html {
# render :layout => 'base_forums'
# }# show.html.erb
# format.json { render json: @forum }
# end
@memo = Memo.find_by_id(params[:id])
@offset, @limit = api_offset_and_limit({:limit => 10})
@forum = Forum.find(params[:forum_id])
@replies = @memo.replies
@replies_all = @memo.replies
@repliy_count = @replies_all.count
@repliy_pages = Paginator.new @repliy_count, @limit, params['page']
@offset ||= @repliy_pages.offset
@replies = @replies_all.offset(@offset).limit(@limit).all
@mome_new = Memo.new
# @memo = Memo.find_by_id(params[:id])
# @forum = Forum.find(params[:forum_id])
# @replies = @memo.replies
# @mome_new = Memo.new
respond_to do |format|
format.html # show.html.erb