rails之FCKEditor插件(转载)

zsbfree posted @ 2007年12月20日 21:07 in rails with tags rails fckeditor , 8349 阅读

环境:ubuntu linux 7.0.4  +  ruby 1.8.5 + Rails 1.2.3 + FCKeditor 0.4.1

直接从它的subversion库里取得该Rails插件。先进入到你的项目根目录,再执行如下命令

ruby script/plugin install svn://rubyforge.org/var/svn/fckeditorp/trunk/fckeditor


其他说明:
(1)你的linux必须先安装了subversion。(ubuntu里用新立得搜subversion即得)
(2)把命令中的install 改为 destory,可以删除安装。
(3)我取到的是2007年4月份最后更新的, v 0.4.1版
(4)FCKeditor安装在项目根目录下的vendor/plugins/fckeditor 里,
(5)vendor/plugins/fckeditor里的README很值得一读,我碰到Ajax问题,查了所以网上的中文资料都没有提到,在这个README却有。


用如下语句在页面里含入它的javascript库

<%= javascript_include_tag :fckeditor %>  


<%= javascript_include_tag "fckeditor/fckeditor" %>



在需要富文本的Form表单用如下语句生成一个富文件编辑框:

<%= fckeditor_textarea("topic""content", :toolbarSet => 'Simple', :width => '100%', :height => '200px') %>


说明:topic对应模型对象,content对应它的字段。也就是要求当前页要有@topic这个实例变量。


如果是用了ajax,则需要在form_remote_tag加上一个before项

  <%= form_remote_tag(:update => update,
                      :before 
=> fckeditor_before_js('topic', 'content'),
                      :url 
=> {:controller => 'topics', :action => 'create', :template => 'show'} )%>


并且富文件编辑框要加一个ajax=true的选项:

<%= fckeditor_textarea(:topic, :content, :ajax => true:toolbarKit => 'Simple', :width => '100%', :height => '600px') %>



在使上传图片的功能时碰到了错误。弹出出alert对话框,显示:Error on file upload.Error number: 403

在日志里显示如下,表面上看好象是路由配置的问题

ActionController::RoutingError (no route found to match "/fckblank.html" with {:method=>:get}):
/var/lib/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb:1292:in `recognize_path'
/var/lib/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb:1282:in `recognize'
/var/lib/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:40:in `dispatch'
/var/lib/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:113:in `handle_dispatch'
/var/lib/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:79:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'


最后在http://blog.caronsoftware.com/articles/2006/12/03/fckeditor-0-4-0-released#comment-1745找到了答案,这是一个BUG

解决方法 :

修改:vendor/plugins/fckeditor/app/controller/fckeditor_controller.rb
将原来的

unless "#{file.class}" == "Tempfile"


改为

unless "#{file.class}" == "Tempfile" || "#{file.class}" == "StringIO"
Avatar_small
deep cleaning servic 说:
2020年2月22日 21:34

They're more versatile than the usual vacuum solution. Steam simply leaves no poisonous residues upon surfaces as well as won’t spot clothing. Along with Classy Eco-friendly Cleaning Support, it’s complete steam forward: whether within the Baby space, Bathroom, Kitchen area, on Flooring, Carpets as well as Mattress. If your house is cleaned along with steam, you may be sure that the baby keeps growing up within safe atmosphere.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter