`
freeport
  • 浏览: 59876 次
  • 性别: Icon_minigender_1
  • 来自: 宁波
社区版块
存档分类
最新评论

fckeditor on rails with 2.2

阅读更多

fckeditor http://rubyforge.org/frs/?group_id=2038&release_id=23116 最新版本 0.5.1

复制到plugins下面 执行 rake fckeditor:install

执行成功后重启web server



<%= javascript_include_tag :fckeditor %>


出现 undefined method `relative_url_root ' for ActionController::CgiRequest

 

是因为rails2.2已经没有 relative_url_root 这个方法了

 

所以要改2个地方

 

app/controllers/fckeditor_controller.rb

 

找到
uploaded = request.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}"

改成

uploaded =
ActionController::Base.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}"

 

找到

js_path = "#{request.relative_url_root}/javascripts"

改成

js_path = "#{ActionController::Base.relative_url_root}/javascripts"

 

重启web server

ok

 

上传图片

出现js错误

 

app/controllers/fckeditor_controller.rb

upload_file方法最后返回JS改成

 

render :text => %Q'<script>window.parent.OnUploadCompleted(#{@errorNumber},\"#{UPLOADED}/#{params[:Type]}/#{Time.now.year}/#{Time.now.month}/#{@new_file.original_filename}\",\"#{@new_file.original_filename}\",\"\");</script>'

 

修改上传文件夹

 def date_directory_path
    base_dir = "#{UPLOADED_ROOT}/#{params[:Type]}/#{Time.now.year}/#{Time.now.month}"
    FileUtils.mkdir_p base_dir
    "#{base_dir}"
  end

分享到:
评论
1 楼 yangzhihuan 2009-07-29  
我也碰到这个问题了,用楼主的方法搞定了.

相关推荐

Global site tag (gtag.js) - Google Analytics