Class: Qa::MarkdownController

Inherits:
QaController
  • Object
show all
Defined in:
app/controllers/qa/markdown_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

接口参数,接受一个data键值,以POST form形式提交,例如 data = ‘markdown document’



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/qa/markdown_controller.rb', line 6

def create
  @success = false
  begin
    if params[:data].blank?
      @data = "data参数不能为空"
    else
      @data = "<div class='markdown'>#{MarkdownTopicConverter.format(params[:data].to_s)}</div>"
      @success = true
    end
  rescue => e
    logger.info [e, e.backtrace].flatten.join("\n")
  end

  respond_to do |format|
    format.json { render :json => {:data => @data, :status => !!@success} }
  end
end