Module: Ckeditor::BaseHelper

Defined in:
app/helpers/ckeditor/base_helper.rb

Instance Method Summary collapse

Instance Method Details

#ckeditor_attachment_path(kind) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/ckeditor/base_helper.rb', line 2

def ckeditor_attachment_path(kind)
  path = case kind
    when :image then Ckeditor.file_manager_image_upload_uri
    when :file  then Ckeditor.file_manager_upload_uri
    else '/ckeditor/attachments'
  end
  
  session_key = Rails.application.config.send(:session_options)[:key]
  
  options = Rails.application.routes.recognize_path(path, :method => :post)
  options[:protocol] = "http://"
  options[session_key] = Rack::Utils.escape(cookies[session_key])
  
  if protect_against_forgery?
    options[request_forgery_protection_token] = Rack::Utils.escape(form_authenticity_token)
  end
  
  url_for(options)
end