未定义的方法`html_safe?'使用带有formtastic的rails-ckeditor时出错

时间:2010-12-14 07:52:38

标签: ruby-on-rails ckeditor

我正试图让rails-ckeditor宝石工作。我按照README上的说明进行操作。 但是我得到了这个错误

undefined method `html_safe?' for #<String:0xb6b6d080>

这是我的形式代码:

<%= f.input :content, :as => :ckeditor %>

有什么想法吗?谢谢!

更新 我正在使用Rails 2.3.8。这是堆栈跟踪。

  /usr/lib/ruby/gems/1.8/gems/ckeditor-3.4.3/lib/ckeditor/safe_buffer.rb:6:in `<<'
  /usr/lib/ruby/gems/1.8/gems/ckeditor-3.4.3/lib/ckeditor/view_helper.rb:52:in `ckeditor_textarea'
  /usr/lib/ruby/gems/1.8/gems/ckeditor-3.4.3/lib/ckeditor/formtastic.rb:9:in `send'
  /usr/lib/ruby/gems/1.8/gems/ckeditor-3.4.3/lib/ckeditor/formtastic.rb:9:in `ckeditor_input'
  /usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:1281:in `send'
  /usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:1281:in `inline_input_for'
  /usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:109:in `send'
  /usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:109:in `input'
  /usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:108:in `map'
  /usr/lib/ruby/gems/1.8/gems/formtastic-1.1.0/lib/formtastic.rb:108:in `input'
  /home/shreyas/repos/citymgmt/app/views/articles/_form.html.erb:4
  /home/shreyas/repos/citymgmt/app/views/articles/_form.html.erb:2:in `_run_erb_app47views47articles47_form46html46erb_locals_form_object'
  /home/shreyas/repos/citymgmt/app/views/articles/_form.html.erb:1:in `_run_erb_app47views47articles47_form46html46erb_locals_form_object'
  /home/shreyas/repos/citymgmt/app/views/articles/new.html.erb:10
  /home/shreyas/repos/citymgmt/app/views/articles/new.html.erb:3:in `_run_erb_app47views47articles47new46html46erb'

2 个答案:

答案 0 :(得分:1)

你有堆栈跟踪吗?根据错误,我假设插件加载顺序导致字符串无法使用SafeBuffer支持进行实例化(这也让我相信你正在使用Rails 2)。

你能提供一些背景吗?

答案 1 :(得分:1)

您是否运行早于R 3.0的版本而不是3.0.0?您需要安装提供此功能的rails_xss插件。在Rails 3中,这是标准配置。

如果可能的话,我会建议您尽快升级到Rails 3。